AbdelrahmanRagab commited on
Commit
efb0d36
·
verified ·
1 Parent(s): 3f2290a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -23
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
- # Define Gradio interface for both calculator and predictor
 
19
  interface = gr.Interface(
20
- fn=[calculate_area, predict_price],
21
- inputs=[
22
- gr.inputs.Number(name="length", label="Length"),
23
- gr.inputs.Number(name="width", label="Width")
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 combined interface
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()