-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
37 lines (26 loc) · 971 Bytes
/
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
33
34
35
36
37
# -*- coding: utf-8 -*-
"""
Created on Fri Feb 28 15:06:32 2020
@author: Ayantika
"""
# importing necessary libraries and functions
import numpy as np
from flask import Flask, request, jsonify, render_template
import pickle
app = Flask(__name__) #Initialize the flask App
model = pickle.load(open('model.pkl', 'rb')) # loading the trained model
@app.route('/') # Homepage
def home():
return render_template('index4.html')
@app.route('/predict',methods=['POST'])
def predict():
'''
For rendering results on HTML GUI
'''
# retrieving values from form
init_features = [float(x) for x in request.form.values()]
final_features = [np.array(init_features)]
prediction = model.predict(final_features) # making prediction
return render_template('index4.html', prediction_text='Predicted Class: {}'.format(prediction)) # rendering the predicted result
if __name__ == "__main__":
app.run()