I have created an ML model for House price prediction using Flask. It is a Web Application. When I run it locally it works perfectly fine but after deploying it in Heroku the ML model doesn't work at all perhaps the web application runs perfectly.
Here is the link of my Web App: https://ml-housepriceprediction.herokuapp.com/
I have created a Flask server for my web app as well as ML model in a single file named as "app.py"
app.py
from flask import Flask, request, jsonify
from website import create_app
import util
import util_2
import util_3
app = create_app()
# bangalore
@app.route('/get_location_names', methods=['GET'])
def get_location_names():
response = jsonify({
'locations': util.get_location_names()
})
response.headers.add('Access-Control-Allow-Origin', '*')
return response
@app.route('/predict_home_price', methods=['POST'])
def predict_home_price():
total_sqft = float(request.form['total_sqft'])
location = request.form['location']
bhk = int(request.form['bhk'])
bath = int(request.form['bath'])
response = jsonify({
'estimated_price': util.get_estimated_price(location, total_sqft, bhk, bath)
})
response.headers.add('Access-Control-Allow-Origin', '*')
return response
#mumbai
@app.route('/get_location_names_m', methods=['GET'])
def get_location_names_m():
response = jsonify({
'locations': util_2.get_location_names()
})
response.headers.add('Access-Control-Allow-Origin', '*')
return response
@app.route('/predict_home_price_m', methods=['POST'])
def predict_home_price_m():
total_sqft = float(request.form['total_sqft'])
location = request.form['location']
bhk = int(request.form['bhk'])
bath = int(request.form['bath'])
response = jsonify({
'estimated_price': util_2.get_estimated_price(location, total_sqft, bhk, bath)
})
response.headers.add('Access-Control-Allow-Origin', '*')
return response
#delhi
@app.route('/get_location_names_d', methods=['GET'])
def get_location_names_d():
response = jsonify({
'locations': util_3.get_location_names()
})
response.headers.add('Access-Control-Allow-Origin', '*')
return response
@app.route('/predict_home_price_d', methods=['POST'])
def predict_home_price_d():
total_sqft = float(request.form['total_sqft'])
location = request.form['location']
bhk = int(request.form['bhk'])
bath = int(request.form['bath'])
response = jsonify({
'estimated_price': util_3.get_estimated_price(location, total_sqft, bhk, bath)
})
response.headers.add('Access-Control-Allow-Origin', '*')
return response
if __name__ == "__main__":
print("Starting Python Flask Server For Home Price Prediction...")
util.load_saved_artifacts()
util_2.load_saved_artifacts()
util_3.load_saved_artifacts()
app.run()
Procfile
web: gunicorn app:app
requirements.txt
asgiref==3.3.1
astroid==2.5
autopep8==1.5.6
beautifulsoup4==4.9.3
bs4==0.0.1
certifi==2020.12.5
chardet==4.0.0
click==7.1.2
colorama==0.4.4
Django==3.0.4
Flask==1.0.2
Flask-Login==0.5.0
Flask-SQLAlchemy==2.5.1
greenlet==1.0.0
gunicorn==20.1.0
html5lib==1.1
idna==2.10
isort==5.7.0
itsdangerous==1.1.0
Jinja2==2.11.3
joblib==1.0.1
lazy-object-proxy==1.5.2
MarkupSafe==1.1.1
mccabe==0.6.1
MouseInfo==0.1.3
numpy==1.20.1
Pillow==8.2.0
PyAutoGUI==0.9.52
pycodestyle==2.7.0
PyGetWindow==0.0.9
pylint==2.7.0
PyMsgBox==1.0.9
pyperclip==1.8.2
PyRect==0.1.4
PyScreeze==0.1.27
PyTweening==1.0.3
pytz==2021.1
pywhatkit==4.7
requests==2.25.1
scikit-learn==0.24.2
scipy==1.6.2
six==1.15.0
sklearn==0.0
soupsieve==2.2.1
SQLAlchemy==1.4.12
sqlparse==0.4.1
threadpoolctl==2.1.0
toml==0.10.2
urllib3==1.26.4
webencodings==0.5.1
Werkzeug==1.0.1
wikipedia==1.4.0
wrapt==1.12.1