Spaces:
Sleeping
Sleeping
beerth21624
commited on
Commit
•
d177e0a
1
Parent(s):
8ac1cb3
Add artifacts
Browse files- 6_model_deployment (Updated).ipynb +0 -0
- app.py +43 -0
- cities.joblib +0 -0
- house_prices.csv +0 -0
- label_pipeline.joblib +0 -0
- pipeline.joblib +0 -0
- requirements.txt +94 -0
6_model_deployment (Updated).ipynb
ADDED
The diff for this file is too large to render.
See raw diff
|
|
app.py
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# !pip install gradio ipywidgets
|
2 |
+
import pandas as pd
|
3 |
+
import gradio as gr
|
4 |
+
import joblib
|
5 |
+
|
6 |
+
# "Artifacts"
|
7 |
+
pipeline = joblib.load("pipeline.joblib")
|
8 |
+
label_pipeline = joblib.load("label_pipeline.joblib")
|
9 |
+
cities = joblib.load("cities.joblib")
|
10 |
+
|
11 |
+
def predict(city, location, area, bedrooms, baths):
|
12 |
+
sample = dict()
|
13 |
+
sample["city"] = city
|
14 |
+
sample["location"] = location
|
15 |
+
sample["Area_in_Marla"] = area # Column names matching feature names
|
16 |
+
sample["bedrooms"] = bedrooms
|
17 |
+
sample["baths"] = baths
|
18 |
+
|
19 |
+
price = pipeline.predict(pd.DataFrame([sample]))
|
20 |
+
price = label_pipeline.inverse_transform([price])
|
21 |
+
|
22 |
+
return int(price[0][0])
|
23 |
+
|
24 |
+
# https://www.gradio.app/guides
|
25 |
+
with gr.Blocks() as blocks:
|
26 |
+
city = gr.Dropdown(cities, value=cities[0], label="City")
|
27 |
+
location = gr.Textbox(label="Location")
|
28 |
+
area = gr.Number(label="Area", value=1, minimum=0.5, step=0.5)
|
29 |
+
bedrooms = gr.Slider(label="Bedrooms", minimum=0, maximum=10, step=1)
|
30 |
+
baths = gr.Slider(label="Baths", minimum=0, maximum=10, step=1)
|
31 |
+
|
32 |
+
price = gr.Number(label="Price")
|
33 |
+
|
34 |
+
inputs = [city, location, area, bedrooms, baths]
|
35 |
+
outputs = [price]
|
36 |
+
|
37 |
+
predict_btn = gr.Button("Predict")
|
38 |
+
predict_btn.click(predict, inputs=inputs, outputs=outputs)
|
39 |
+
|
40 |
+
if __name__ == "__main__":
|
41 |
+
blocks.launch() # Local machine only
|
42 |
+
# blocks.launch(server_name="0.0.0.0") # LAN access to local machine
|
43 |
+
# blocks.launch(share=True) # Public access to local machine
|
cities.joblib
ADDED
Binary file (73 Bytes). View file
|
|
house_prices.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
label_pipeline.joblib
ADDED
Binary file (1.56 kB). View file
|
|
pipeline.joblib
ADDED
Binary file (37.5 kB). View file
|
|
requirements.txt
ADDED
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
aiofiles==23.2.1
|
2 |
+
altair==5.2.0
|
3 |
+
annotated-types==0.6.0
|
4 |
+
anyio==4.2.0
|
5 |
+
appnope==0.1.3
|
6 |
+
asttokens==2.4.1
|
7 |
+
attrs==23.2.0
|
8 |
+
certifi==2023.11.17
|
9 |
+
charset-normalizer==3.3.2
|
10 |
+
click==8.1.7
|
11 |
+
colorama==0.4.6
|
12 |
+
comm==0.2.1
|
13 |
+
contourpy==1.2.0
|
14 |
+
cycler==0.12.1
|
15 |
+
debugpy==1.8.0
|
16 |
+
decorator==5.1.1
|
17 |
+
executing==2.0.1
|
18 |
+
fastapi==0.109.0
|
19 |
+
ffmpy==0.3.1
|
20 |
+
filelock==3.13.1
|
21 |
+
fonttools==4.47.2
|
22 |
+
fsspec==2023.12.2
|
23 |
+
gradio==4.16.0
|
24 |
+
gradio_client==0.8.1
|
25 |
+
h11==0.14.0
|
26 |
+
httpcore==1.0.2
|
27 |
+
httpx==0.26.0
|
28 |
+
huggingface-hub==0.20.3
|
29 |
+
idna==3.6
|
30 |
+
importlib-resources==6.1.1
|
31 |
+
ipykernel==6.29.0
|
32 |
+
ipython==8.20.0
|
33 |
+
jedi==0.19.1
|
34 |
+
Jinja2==3.1.3
|
35 |
+
joblib==1.3.2
|
36 |
+
jsonschema==4.21.1
|
37 |
+
jsonschema-specifications==2023.12.1
|
38 |
+
jupyter_client==8.6.0
|
39 |
+
jupyter_core==5.7.1
|
40 |
+
kiwisolver==1.4.5
|
41 |
+
markdown-it-py==3.0.0
|
42 |
+
MarkupSafe==2.1.4
|
43 |
+
matplotlib==3.8.2
|
44 |
+
matplotlib-inline==0.1.6
|
45 |
+
mdurl==0.1.2
|
46 |
+
nest-asyncio==1.6.0
|
47 |
+
numpy==1.26.3
|
48 |
+
orjson==3.9.12
|
49 |
+
packaging==23.2
|
50 |
+
pandas==2.2.0
|
51 |
+
parso==0.8.3
|
52 |
+
pexpect==4.9.0
|
53 |
+
pillow==10.2.0
|
54 |
+
platformdirs==4.1.0
|
55 |
+
prompt-toolkit==3.0.43
|
56 |
+
psutil==5.9.8
|
57 |
+
ptyprocess==0.7.0
|
58 |
+
pure-eval==0.2.2
|
59 |
+
pydantic==2.6.0
|
60 |
+
pydantic_core==2.16.1
|
61 |
+
pydub==0.25.1
|
62 |
+
Pygments==2.17.2
|
63 |
+
pyparsing==3.1.1
|
64 |
+
python-dateutil==2.8.2
|
65 |
+
python-multipart==0.0.6
|
66 |
+
pytz==2023.4
|
67 |
+
PyYAML==6.0.1
|
68 |
+
pyzmq==25.1.2
|
69 |
+
referencing==0.33.0
|
70 |
+
requests==2.31.0
|
71 |
+
rich==13.7.0
|
72 |
+
rpds-py==0.17.1
|
73 |
+
ruff==0.1.15
|
74 |
+
scikit-learn==1.4.0
|
75 |
+
scipy==1.12.0
|
76 |
+
semantic-version==2.10.0
|
77 |
+
shellingham==1.5.4
|
78 |
+
six==1.16.0
|
79 |
+
sniffio==1.3.0
|
80 |
+
stack-data==0.6.3
|
81 |
+
starlette==0.35.1
|
82 |
+
threadpoolctl==3.2.0
|
83 |
+
tomlkit==0.12.0
|
84 |
+
toolz==0.12.1
|
85 |
+
tornado==6.4
|
86 |
+
tqdm==4.66.1
|
87 |
+
traitlets==5.14.1
|
88 |
+
typer==0.9.0
|
89 |
+
typing_extensions==4.9.0
|
90 |
+
tzdata==2023.4
|
91 |
+
urllib3==2.1.0
|
92 |
+
uvicorn==0.27.0.post1
|
93 |
+
wcwidth==0.2.13
|
94 |
+
websockets==11.0.3
|