Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,10 +1,6 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import pickle
|
| 3 |
|
| 4 |
-
# Function to calculate the area of a rectangle
|
| 5 |
-
def calculate_area(length, width):
|
| 6 |
-
return length * width
|
| 7 |
-
|
| 8 |
# Load the trained model
|
| 9 |
with open('model.pkl', 'rb') as file:
|
| 10 |
model = pickle.load(file)
|
|
@@ -15,26 +11,15 @@ def predict_price(area, bedrooms, bathrooms):
|
|
| 15 |
prediction = model.predict(features)
|
| 16 |
return float(prediction[0])
|
| 17 |
|
| 18 |
-
|
|
|
|
| 19 |
interface = gr.Interface(
|
| 20 |
-
fn=
|
| 21 |
-
inputs=[
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
gr.inputs.Number(name=name, label=label) for name, label in [
|
| 26 |
-
("area", "Area (sqft)"),
|
| 27 |
-
("bedrooms", "Number of Bedrooms"),
|
| 28 |
-
("bathrooms", "Number of Bathrooms")
|
| 29 |
-
]
|
| 30 |
-
],
|
| 31 |
-
outputs=["number", "number"], # Outputs for both functions
|
| 32 |
-
title="Combined Interface",
|
| 33 |
-
description=[
|
| 34 |
-
"Enter the length and width of a rectangle to calculate its area.",
|
| 35 |
-
"Enter the area (in sqft), number of bedrooms, and number of bathrooms to predict the house price."
|
| 36 |
-
]
|
| 37 |
)
|
| 38 |
|
| 39 |
-
# Launch the
|
| 40 |
interface.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import pickle
|
| 3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
# Load the trained model
|
| 5 |
with open('model.pkl', 'rb') as file:
|
| 6 |
model = pickle.load(file)
|
|
|
|
| 11 |
prediction = model.predict(features)
|
| 12 |
return float(prediction[0])
|
| 13 |
|
| 14 |
+
|
| 15 |
+
# Create a Gradio interface
|
| 16 |
interface = gr.Interface(
|
| 17 |
+
fn=predict_price,
|
| 18 |
+
inputs=["number", "number", "number"],
|
| 19 |
+
outputs="number",
|
| 20 |
+
title="House Price Predictor",
|
| 21 |
+
description="Enter the area (in sqft), number of bedrooms, and number of bathrooms to predict the house price."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
)
|
| 23 |
|
| 24 |
+
# Launch the interface
|
| 25 |
interface.launch()
|