-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
32 lines (27 loc) · 1.05 KB
/
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
from flask import Flask, render_template, request, jsonify
import joblib
import numpy as np
app = Flask(__name__)
@app.route("/", methods=['GET', 'POST'])
def iris_prediction():
if request.method == 'GET':
return render_template("iris-prediction.html")
elif request.method == 'POST':
print(dict(request.form))
iris_features = dict(request.form).values() #string
iris_features = np.array([float(x) for x in iris_features]) #float
model, std_scaler = joblib.load("model-development/iris-classification-using-logistic-regression.pkl")
iris_features = std_scaler.transform([iris_features])
print(iris_features)
result = model.predict(iris_features)
iris = {
'0': 'Iris Setosa',
'1': 'Iris Versicolor',
'2': 'Iris Virginica'
}
result = iris[str(result[0])]
return render_template('iris-prediction.html', result=result)
else:
return "Unsupported Request Method"
if __name__ == '__main__':
app.run(port=5000, debug=True)