Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
ecubeproject authored Mar 2, 2024
1 parent 121772a commit 1c66ed9
Show file tree
Hide file tree
Showing 4 changed files with 588 additions and 0 deletions.
127 changes: 127 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
import pickle
import numpy as np
from flask import Flask, render_template, request

app = Flask(__name__)


# Helper function to get location code
def get_location_code(location):
# Define the mapping of locations to integers
location_mapping = {
'Baguiati': 68,
'Barsat': 79,
'Behala': 86,
'Bhadreswar': 90,
'Chkravarti Para': 138,
'Dum Dum Park': 175,
'Dum Dum': 174,
'Garia': 197,
'Gariahat': 198,
'Hooghly Chinsurah': 237,
'Hussainpur': 241,
'Joka': 272,
'Keshtopur': 320,
'Konnagar': 348,
'Kutighat': 374,
'Lake Gardens': 380,
'Madhyamgram': 392,
'Madurdaha Hussainpur': 396,
'Mukundapur': 450,
'Narendrapur': 480,
'New Alipore': 493,
'New Town': 495,
'Rajarhat': 565,
'Santoshpur': 604,
'Sarsuna': 609,
'Sodepur': 719,
'Sonarpur': 721,
'south dum dum': 842,
'Tangra': 737,
'Tollygunge': 763,
'Ultadanga': 768,
'Uttarpara Kotrung': 778
}
# Return the integer code for the given location, or 0 if location not found
return location_mapping.get(location, 0)


# Load the trained model
with open("models/best_xgb_kolkata.pkl", "rb") as f:
model = pickle.load(f)
# Print model information
# print("Loaded model:", model)

# Define route for index page
@app.route('/')
def index():
return render_template('index.html')

# Handle prediction request
@app.route('/predict', methods=['POST'])
def predict():
print("Prediction endpoint triggered")
# Get user input from the form
area = int(request.form['area'])
bedrooms = int(request.form['bedrooms'])
location = request.form['location']
club_house = 1 if request.form['club-house'] == 'Yes' else 0
rain_water_harvesting = 1 if request.form['rain-water-harvesting'] == 'Yes' else 0
swimming_pool = 1 if request.form['swimming-pool'] == 'Yes' else 0
resale = 1 if request.form['resale'] == 'Yes' else 0
cafeteria = 1 if request.form['Cafeteria'] == 'Yes' else 0
lift_available = 1 if request.form['LiftAvailable'] == 'Yes' else 0
maintenance_staff = 1 if request.form['MaintenanceStaff'] == 'Yes' else 0
jogging_track = 1 if request.form['JoggingTrack'] == 'Yes' else 0
landscaped_gardens = 1 if request.form['LandscapedGardens'] == 'Yes' else 0
vaastu_compliant = 1 if request.form['VaastuCompliant'] == 'Yes' else 0
multipurpose_room = 1 if request.form['MultipurposeRoom'] == 'Yes' else 0
power_backup = 1 if request.form['PowerBackup'] == 'Yes' else 0
indoor_games = 1 if request.form['IndoorGames'] == 'Yes' else 0
washing_machine = 1 if request.form['WashingMachine'] == 'Yes' else 0
car_parking = 1 if request.form['CarParking'] == 'Yes' else 0
sports_facility = 1 if request.form['SportsFacility'] == 'Yes' else 0
gymnasium = 1 if request.form['Gymnasium'] == 'Yes' else 0

# Preprocess user input
location_code = get_location_code(location)

# Print received form data
'''
print("Received Form Data:")
print("Area:", area)
print("Bedrooms:", bedrooms)
print("Location:", location)
print("Club House:", club_house)
print("Rain Water Harvesting:", rain_water_harvesting)
print("Swimming Pool:", swimming_pool)
print("Resale:", resale)
print("Cafeteria:", cafeteria)
print("Lift Available:", lift_available)
print("Maintenance Staff:", maintenance_staff)
print("Jogging Track:", jogging_track)
print("Landscaped Gardens:", landscaped_gardens)
print("Vaastu Compliant:", vaastu_compliant)
print("Multipurpose Room:", multipurpose_room)
print("Power Backup:", power_backup)
print("Indoor Games:", indoor_games)
print("Washing Machine:", washing_machine)
print("Car Parking:", car_parking)
print("Sports Facility:", sports_facility)
print("Gymnasium:", gymnasium)
'''
# Make prediction
features = np.array([[area, swimming_pool, resale, club_house, rain_water_harvesting, cafeteria, lift_available,
maintenance_staff, location_code, jogging_track, landscaped_gardens, bedrooms,
vaastu_compliant, multipurpose_room, power_backup, indoor_games, washing_machine, car_parking,
sports_facility, gymnasium]])
predicted_price = model.predict(features)[0]
print("Predicted Price:", predicted_price)

# Return prediction result
return render_template('index.html', predicted_price=predicted_price)


if __name__ == '__main__':

app.run(debug=True)
Binary file added models/best_xgb_kolkata.pkl
Binary file not shown.
206 changes: 206 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
absl-py==2.1.0
annotated-types==0.6.0
anyio==4.2.0
argon2-cffi==23.1.0
argon2-cffi-bindings==21.2.0
arrow==1.3.0
asttokens==2.4.1
astunparse==1.6.3
async-lru==2.0.4
attrs==23.2.0
autopep8==2.0.4
autoviz==0.1.806
Babel==2.14.0
beautifulsoup4==4.12.3
bleach==6.1.0
bokeh==2.4.3
Brotli==1.1.0
cachetools==5.3.2
certifi==2024.2.2
cffi==1.16.0
charset-normalizer==3.3.2
click==8.1.7
colorcet==3.0.1
comm==0.2.1
contourpy==1.2.0
cycler==0.12.1
dacite==1.8.1
dash==2.15.0
dash-bootstrap-components==1.3.1
dash-colorscales==0.0.4
dash-core-components==2.0.0
dash-daq==0.5.0
dash-html-components==2.0.0
dash-table==5.0.0
debugpy==1.8.0
decorator==5.1.1
defusedxml==0.7.1
dtale==3.10.0
emoji==2.10.1
et-xmlfile==1.1.0
exceptiongroup==1.2.0
executing==2.0.1
fastjsonschema==2.19.1
Flask==2.2.5
Flask-Compress==1.14
flask-ngrok==0.0.25
flatbuffers==23.5.26
fonttools==4.48.1
fqdn==1.5.1
fsspec==2024.2.0
future==0.18.3
gast==0.5.4
google-auth==2.28.0
google-auth-oauthlib==1.2.0
google-pasta==0.2.0
grpcio==1.60.1
h11==0.14.0
h5py==3.10.0
holoviews==1.14.9
htmlmin==0.1.12
httpcore==1.0.2
httpx==0.26.0
hvplot==0.7.3
idna==3.6
ImageHash==4.3.1
importlib-metadata==7.0.1
importlib-resources==6.1.1
ipykernel==6.29.1
ipython==8.18.1
isoduration==20.11.0
itsdangerous==2.1.2
jedi==0.19.1
Jinja2==3.1.3
joblib==1.3.2
json5==0.9.14
jsonpointer==2.4
jsonschema==4.21.1
jsonschema-specifications==2023.12.1
jupyter-events==0.9.0
jupyter-lsp==2.2.2
jupyter_client==8.6.0
jupyter_core==5.7.1
jupyter_server==2.12.5
jupyter_server_terminals==0.5.2
jupyterlab==4.1.0
jupyterlab_server==2.25.2
kaleido==0.2.1
keras==2.15.0
kiwisolver==1.4.5
libclang==16.0.6
llvmlite==0.41.1
lz4==4.3.3
Markdown==3.5.2
MarkupSafe==2.1.5
matplotlib==3.7.4
matplotlib-inline==0.1.6
missingno==0.5.2
mistune==3.0.2
ml-dtypes==0.2.0
multimethod==1.11
nbclient==0.9.0
nbconvert==7.15.0
nbformat==5.9.2
nest-asyncio==1.6.0
networkx==3.2.1
nltk==3.8.1
notebook==7.0.7
notebook_shim==0.2.3
numba==0.58.1
numpy==1.24.4
oauthlib==3.2.2
openpyxl==3.1.2
opt-einsum==3.3.0
overrides==7.7.0
packaging==23.2
pandas==2.2.0
pandas-dq==1.29
pandas-profiling==3.6.6
pandocfilters==1.5.1
panel==0.14.4
param==1.13.0
parso==0.8.3
patsy==0.5.6
pexpect==4.9.0
phik==0.12.4
pillow==10.2.0
platformdirs==4.2.0
plotly==5.18.0
prometheus-client==0.19.0
prompt-toolkit==3.0.43
protobuf==4.25.3
psutil==5.9.8
ptyprocess==0.7.0
pure-eval==0.2.2
pyamg==5.0.1
pyarrow==15.0.0
pyasn1==0.5.1
pyasn1-modules==0.3.0
pycodestyle==2.11.1
pycparser==2.21
pyct==0.5.0
pydantic==2.6.1
pydantic-settings==2.1.0
pydantic_core==2.16.2
Pygments==2.17.2
pyparsing==3.1.1
python-dateutil==2.8.2
python-dotenv==1.0.1
python-json-logger==2.0.7
pytz==2024.1
pyviz_comms==3.0.1
PyWavelets==1.5.0
PyYAML==6.0.1
pyzmq==25.1.2
referencing==0.33.0
regex==2023.12.25
requests==2.31.0
requests-oauthlib==1.3.1
retrying==1.3.4
rfc3339-validator==0.1.4
rfc3986-validator==0.1.1
rpds-py==0.17.1
rsa==4.9
scikit-learn==1.4.0
scipy==1.11.4
seaborn==0.12.2
Send2Trash==1.8.2
six==1.16.0
sniffio==1.3.0
soupsieve==2.5
squarify==0.4.3
stack-data==0.6.3
statsmodels==0.14.1
strsimpy==0.2.1
sweetviz==2.3.1
tabulate==0.9.0
tangled-up-in-unicode==0.2.0
tenacity==8.2.3
termcolor==2.4.0
terminado==0.18.0
textblob==0.17.1
threadpoolctl==3.2.0
tinycss2==1.2.1
tomli==2.0.1
tornado==6.4
tqdm==4.66.2
traitlets==5.14.1
typeguard==4.1.5
types-python-dateutil==2.8.19.20240106
typing_extensions==4.9.0
tzdata==2023.4
uri-template==1.3.0
urllib3==2.2.0
visions==0.7.5
wcwidth==0.2.13
webcolors==1.13
webencodings==0.5.1
websocket-client==1.7.0
Werkzeug==3.0.1
wordcloud==1.9.3
wrapt==1.14.1
xarray==2024.1.1
xgboost==1.6.2
xlrd==2.0.1
ydata-profiling==4.6.4
zipp==3.17.0
Loading

0 comments on commit 1c66ed9

Please sign in to comment.