-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
30 lines (23 loc) · 863 Bytes
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import pandas as pd
from flask import Flask, render_template, request
import pickle
import numpy as np
app = Flask(__name__)
data = pd.read_csv('Cleaned_data.csv')
pipe = pickle.load(open("RidgeModel.pkl", "rb"))
@app.route('/')
def index():
locations = sorted(data['location'].unique())
return render_template('index.html', locations=locations)
@app.route('/predict', methods=['POST'])
def predict():
location = request.form.get('location')
bhk = request.form.get('bhk')
bath = request.form.get('bath')
sqft = request.form.get('total_sqft')
print(location, bhk, bath, sqft)
input = pd.DataFrame([[location, sqft, bath, bhk]], columns=['location', 'total_sqft', 'bath', 'bhk'])
prediction = pipe.predict(input)[0] * 1e5
return str(np.round(prediction,2))
if __name__ == "__main__":
app.run(debug=True, port=5001)