roshanalichandio commited on
Commit
951505b
1 Parent(s): f7664e5
Files changed (1) hide show
  1. app.py +74 -11
app.py CHANGED
@@ -1,12 +1,75 @@
1
- import numpy as np
 
 
2
  import gradio as gr
3
- #function to predict the input hours
4
- def predict_score(hours):
5
- #hours = np.array(hours)
6
- pred_score = -0.5738734424645411 + 2.1659122905141825*hours
7
- return pred_score #np.round(pred_score[0], 2)
8
- input = gr.inputs.Number(label='Number of Hours studied')
9
- output = gr.outputs.Textbox(label='Predicted Score')
10
- gr.Interface( fn=predict_score,
11
- inputs=input,
12
- outputs=output).launch();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ pip install -q gradio nltk
2
+
3
+
4
  import gradio as gr
5
+
6
+ def house_price_estimation(area, rooms, kitchens, doors, washrooms, manzalas, land_measurement, garden=False, garage=False, storage_room=False, electricity=False, gas=False, water=False, ac=False, geyser=False, roof=False):
7
+ # Perform calculations to estimate the house price based on the provided details
8
+ price = area * 100 + rooms * 2000 + kitchens * 1500
9
+
10
+ # Increase price based on land measurement
11
+ if land_measurement == "Marlas":
12
+ price += 500 * area
13
+ elif land_measurement == "Canals":
14
+ price += 1000 * area
15
+
16
+ # Increase price based on optional facilities
17
+ if garden:
18
+ price += 5000
19
+ if garage:
20
+ price += 4000
21
+ if storage_room:
22
+ price += 3000
23
+ if electricity:
24
+ price += 2000
25
+ if gas:
26
+ price += 3000
27
+ if water:
28
+ price += 2000
29
+ if ac:
30
+ price += 2000
31
+ if geyser:
32
+ price += 1000
33
+ if roof:
34
+ price += 2000
35
+
36
+ return price
37
+
38
+ input_area = gr.inputs.Slider(minimum=0, maximum=5000, step=100, default=1000, label="Area (in square feet)")
39
+ input_rooms = gr.inputs.Slider(minimum=0, maximum=10, step=1, default=3, label="Number of Rooms")
40
+ input_kitchens = gr.inputs.Slider(minimum=0, maximum=5, step=1, default=1, label="Number of Kitchens")
41
+ input_doors = gr.inputs.Slider(minimum=0, maximum=20, step=1, default=4, label="Number of Doors")
42
+ input_washrooms = gr.inputs.Slider(minimum=0, maximum=10, step=1, default=2, label="Number of Washrooms")
43
+ input_manzalas = gr.inputs.Slider(minimum=0, maximum=5, step=1, default=1, label="Number of Manzalas")
44
+ input_land_measurement = gr.inputs.Radio(["Marlas", "Canals"], label="Land Measurement")
45
+
46
+ input_garden = gr.inputs.Checkbox(label="Garden")
47
+ input_garage = gr.inputs.Checkbox(label="Garage")
48
+ input_storage_room = gr.inputs.Checkbox(label="Storage Room")
49
+ input_electricity = gr.inputs.Checkbox(label="Electricity")
50
+ input_gas = gr.inputs.Checkbox(label="Gas")
51
+ input_water = gr.inputs.Checkbox(label="Water")
52
+ input_ac = gr.inputs.Checkbox(label="Air Conditioning (AC)")
53
+ input_geyser = gr.inputs.Checkbox(label="Geyser")
54
+ input_roof = gr.inputs.Checkbox(label="Roof")
55
+
56
+ output_price = gr.outputs.Textbox(label="Estimated House Price")
57
+
58
+ demo = gr.Interface(
59
+ fn=house_price_estimation,
60
+ inputs=[
61
+ input_area, input_rooms, input_kitchens, input_doors, input_washrooms, input_manzalas,
62
+ input_land_measurement, input_garden, input_garage, input_storage_room,
63
+ input_electricity, input_gas, input_water, input_ac, input_geyser, input_roof
64
+ ],
65
+ outputs=output_price,
66
+ examples=[
67
+ [1000, 3, 1, 4, 2, 1, "Marlas", True, False, True, True, False, True, False, False, True],
68
+ [1500, 4, 2, 6, 3, 1, "Canals", False, True, False, False, True, True, False, False, True],
69
+ [800, 2, 1, 2, 1, 1, "Marlas", True, False, False, True, True, True, False, True, False]
70
+ ],
71
+ title="House Price Estimation",
72
+ description="Estimate the price of a house based on the provided requirements."
73
+ )
74
+
75
+ demo.launch()