iris / app.py
simran19's picture
Update app.py
8568103 verified
raw
history blame contribute delete
854 Bytes
from flask import Flask,render_template,request
import joblib
from sklearn.linear_model import LogisticRegression
app=Flask(__name__)
#predicting using saved model
model=joblib.load('iris_model.pkl')
@app.route('/')
def home():
return render_template('index.html')
@app.route('/predict', methods=['POST'])
def predict():
# Get form values and convert them to float
sepal_length = float(request.form['sl'])
sepal_width = float(request.form['sw'])
petal_length = float(request.form['pl'])
petal_width = float(request.form['pw'])
# Make prediction
prediction = model.predict([[sepal_length, sepal_width, petal_length, petal_width]])
result = prediction[0]
return render_template('index.html', result=result)
if __name__ == '__main__':
app.run(debug=True, host='0.0.0.0')