Upload 4 files
Browse files- app.py +37 -0
- irismodel.joblib +3 -0
- templates/index.html +16 -0
- templates/predictpage.html +21 -0
app.py
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from flask import Flask, render_template, request
|
| 2 |
+
from datetime import datetime
|
| 3 |
+
import pytz
|
| 4 |
+
import joblib
|
| 5 |
+
|
| 6 |
+
app = Flask(__name__) # Inilitize the flask app
|
| 7 |
+
|
| 8 |
+
# Load the saved model
|
| 9 |
+
loaded_model = joblib.load('irismodel.joblib')
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
@app.route('/')
|
| 13 |
+
def index():
|
| 14 |
+
dt = datetime.now(pytz.timezone('Asia/Kolkata')
|
| 15 |
+
).strftime('%Y-%m-%d %H:%M:%S')
|
| 16 |
+
return render_template('index.html', dt=dt)
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
@app.route('/predict')
|
| 20 |
+
def predictpage():
|
| 21 |
+
return render_template('predictpage.html')
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
@app.route('/predictiris', methods=['POST'])
|
| 25 |
+
def predict():
|
| 26 |
+
sepal_length = float(request.form['sepal_length'])
|
| 27 |
+
sepal_width = float(request.form['sepal_width'])
|
| 28 |
+
petal_length = float(request.form['petal_length'])
|
| 29 |
+
petal_width = float(request.form['petal_width'])
|
| 30 |
+
new_data = [[sepal_length, sepal_width, petal_length, petal_width]]
|
| 31 |
+
prediction = loaded_model.predict(new_data)
|
| 32 |
+
prediction = prediction[0]
|
| 33 |
+
return render_template('predictpage.html', prediction=prediction)
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
if __name__ == '__main__':
|
| 37 |
+
app.run(debug=True, host='0.0.0.0', port=5000)
|
irismodel.joblib
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0f76b3d9f823faed9b1cb0d1c0e732ae57a71a2ac598957a4736020b9ae17a75
|
| 3 |
+
size 1407
|
templates/index.html
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<html>
|
| 2 |
+
<head>
|
| 3 |
+
<title>Flask Iris</title>
|
| 4 |
+
</head>
|
| 5 |
+
<body>
|
| 6 |
+
<h1>Welcome to Flask Iris!</h1>
|
| 7 |
+
|
| 8 |
+
<h3><a href="/predict">Go To Prediction Page</a></h3>
|
| 9 |
+
<h3>{{ dt }}</h3><br>
|
| 10 |
+
<br><br><br>
|
| 11 |
+
<img src="https://camo.githubusercontent.com/ca4ff60b76c0803d41de1ebf12d6617465e3924fe6845192dd98e9f8503596c2/68747470733a2f2f7777772e656d6265646465642d726f626f746963732e636f6d2f77702d636f6e74656e742f75706c6f6164732f323032322f30312f497269732d446174617365742d436c617373696669636174696f6e2d31303234783336372e706e67">
|
| 12 |
+
|
| 13 |
+
<br><br><br>
|
| 14 |
+
|
| 15 |
+
</body>
|
| 16 |
+
</html>
|
templates/predictpage.html
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<html>
|
| 2 |
+
<head>
|
| 3 |
+
<title>Flask Iris</title>
|
| 4 |
+
</head>
|
| 5 |
+
<body>
|
| 6 |
+
<h1>Welcome to Predict Page</h1>
|
| 7 |
+
<form action="/predictiris" method="POST">
|
| 8 |
+
<input type="text" name="sepal_length" placeholder="Sepal Length" required><br><br>
|
| 9 |
+
<input type="text" name="sepal_width" placeholder="Sepal Width" required><br><br>
|
| 10 |
+
<input type="text" name="petal_length" placeholder="Petal Length" required><br><br>
|
| 11 |
+
<input type="text" name="petal_width" placeholder="Petal Width" required><br><br>
|
| 12 |
+
<input type="submit" value="Predict">
|
| 13 |
+
</form>
|
| 14 |
+
{% if prediction %}
|
| 15 |
+
<h3>Prediction: {{ prediction }}</h3>
|
| 16 |
+
{% endif %}
|
| 17 |
+
|
| 18 |
+
<h3><a href="/">Back to Home</a></h3> <br>
|
| 19 |
+
|
| 20 |
+
</body>
|
| 21 |
+
</html>
|