File size: 688 Bytes
b733494
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from sklearn.linear_model import LogisticRegression
import joblib

app = Flask(__name__)

# Load model
model = joblib.load('iris_model1.joblib')


@app.route('/')
def home():
    return render_template('index.html')

@app.route('/predict', methods=['POST'])
def predict():
  sl = float(request.form['sepal_length'])
  sw = float(request.form['sepal_width'])
  pl = float(request.form['petal_length'])
  pw = float(request.form['petal_width'])

  # Predict species
  input_data = [[sl, sw, pl, pw]]
  pred = model.predict(input_data)

  return render_template('index.html', data=pred[0])

if __name__ == '__main__':
    app.run(debug=True)