-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
35 lines (24 loc) · 901 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
34
35
# flask , scikit-learn, pandas, pickle-mixin
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('totally 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(prediction)
if __name__ == "__main__":
app.run(debug=True, port=5000)