-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
33 lines (22 loc) · 864 Bytes
/
main.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
31
32
33
import pandas as pd
import pickle
import numpy as np
from flask import Flask, render_template, request
app = Flask(__name__)
data= pd.read_csv('Cleaned_bhp.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():
locations = request.form.get('location')
bhk = request.form.get('bhk')
bath = request.form.get('bath')
sqft = request.form.get('total_sqft')
input = pd.DataFrame([[locations,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)