Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,10 +1,49 @@
|
|
| 1 |
-
from flask import
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
-
app = Flask(__name__)
|
| 4 |
|
| 5 |
@app.route('/')
|
| 6 |
-
|
| 7 |
-
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
-
if __name__ == '__main__':
|
| 10 |
-
app.run()
|
|
|
|
| 1 |
+
from flask import *
|
| 2 |
+
import seaborn as sns
|
| 3 |
+
from sklearn.linear_model import LogisticRegression
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
app = Flask(__name__)
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
@app.route('/predict', methods =['POST'])
|
| 12 |
+
def predictflower():
|
| 13 |
+
# receive all four values
|
| 14 |
+
# send these 4 values to predict method of model
|
| 15 |
+
# return the flower type returned by predict method
|
| 16 |
+
# def greet_json():
|
| 17 |
+
iris1 =sns.load_dataset("iris")
|
| 18 |
+
modlog= LogisticRegression (max_iter=300)
|
| 19 |
+
|
| 20 |
+
irisarr = iris1.values
|
| 21 |
+
X = irisarr[:,0:4]
|
| 22 |
+
Y = irisarr[:,4]
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
modlog.fit(X,Y)
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
sl = float(request.form['sl'])
|
| 30 |
+
sw = float(request.form['sw'] )
|
| 31 |
+
pl = float(request.form['pl'])
|
| 32 |
+
pw = float(request.form['pw'])
|
| 33 |
+
res = modlog.predict([[ sl , sw ,pl ,pw ] ])
|
| 34 |
+
|
| 35 |
+
return render_template("form.html" , result = res )
|
| 36 |
+
|
| 37 |
|
|
|
|
| 38 |
|
| 39 |
@app.route('/')
|
| 40 |
+
def hello_world():
|
| 41 |
+
return render_template("form.html")
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
if __name__ == '__main__':
|
| 48 |
+
app.run()
|
| 49 |
|
|
|
|
|
|