forked from gerchristko/Machine-Learning-Web-App
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
35 lines (24 loc) · 844 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
31
32
33
34
35
from flask import Flask, request, render_template
import pandas as pd
import joblib
# Declare a Flask app
app = Flask(__name__)
@app.route('/', methods=['GET', 'POST'])
def main():
# If a form is submitted
if request.method == "POST":
# Unpickle classifier
clf = joblib.load("clf.pkl")
# Get values through input bars
height = request.form.get("height")
weight = request.form.get("weight")
# Put inputs to dataframe
X = pd.DataFrame([[height, weight]], columns = ["Height", "Weight"])
# Get prediction
prediction = clf.predict(X)[0]
else:
prediction = ""
return render_template("website.html", output = prediction)
# Running the app
if __name__ == '__main__':
app.run(debug = True)