-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
29 lines (22 loc) · 877 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
from flask import Flask, render_template, request
import numpy as np
import pickle
app = Flask(__name__, template_folder="templates")
model = pickle.load(open('model.pkl', 'rb'))
@app.route('/')
def index():
return render_template('index.html')
@app.route('/predict', methods=['GET', 'POST'])
def predict():
columns = [
'bedrooms', 'bathrooms', 'sqft_living', 'sqft_lot', 'floors',
'waterfront', 'view', 'condition', 'grade', 'sqft_above',
'sqft_basement', 'yr_built', 'yr_renovated', 'zipcode', 'lat', 'long',
'sqft_living15', 'sqft_lot15'
]
values = [request.form[col] for col in columns]
arr = np.array(values, dtype=np.float64)
pred = -1 * model.predict([arr])
return render_template('index.html', data=int(pred))
if __name__ == '__main__':
app.run(debug=True)