umanr18075's picture
Create app.py
396f14c verified
raw
history blame contribute delete
975 Bytes
import streamlit as st
import joblib
import numpy as np
# Load the model from Hugging Face Model Hub (replace with your model's Hugging Face repository URL)
model = joblib.load('random_forest_model.pkl') # If model is uploaded directly in the Space, this works.
# Streamlit App Title
st.title("Power Prediction App")
st.subheader("Enter the values for Current (I) and Resistance (R) to predict Power (P)")
# Input fields for Current (I) and Resistance (R)
current = st.number_input("Current (I in Amps)", min_value=0.1, max_value=10.0, value=5.0, step=0.1)
resistance = st.number_input("Resistance (R in Ohms)", min_value=1.0, max_value=100.0, value=50.0, step=1.0)
# Button to make prediction
if st.button("Predict Power"):
# Predict the power using the trained model
prediction = model.predict([[current, resistance]])
# Display the result
st.write(f"Predicted Power (P) for I = {current} A and R = {resistance} Ω is: {prediction[0]:.2f} Watts")