umanr18075 commited on
Commit
396f14c
1 Parent(s): a434da5

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -0
app.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import joblib
3
+ import numpy as np
4
+
5
+ # Load the model from Hugging Face Model Hub (replace with your model's Hugging Face repository URL)
6
+ model = joblib.load('random_forest_model.pkl') # If model is uploaded directly in the Space, this works.
7
+
8
+ # Streamlit App Title
9
+ st.title("Power Prediction App")
10
+ st.subheader("Enter the values for Current (I) and Resistance (R) to predict Power (P)")
11
+
12
+ # Input fields for Current (I) and Resistance (R)
13
+ current = st.number_input("Current (I in Amps)", min_value=0.1, max_value=10.0, value=5.0, step=0.1)
14
+ resistance = st.number_input("Resistance (R in Ohms)", min_value=1.0, max_value=100.0, value=50.0, step=1.0)
15
+
16
+ # Button to make prediction
17
+ if st.button("Predict Power"):
18
+ # Predict the power using the trained model
19
+ prediction = model.predict([[current, resistance]])
20
+
21
+ # Display the result
22
+ st.write(f"Predicted Power (P) for I = {current} A and R = {resistance} Ω is: {prediction[0]:.2f} Watts")