-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
32 lines (22 loc) Β· 980 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
from flask import Flask,request, url_for, redirect, render_template
import pickle
import numpy as np
app = Flask(__name__)
model=pickle.load(open('model.pkl','rb'))
@app.route('/')
def hello_world():
return render_template("forest_fire.html")
@app.route('/predict',methods=['POST','GET'])
def predict():
int_features=[int(x) for x in request.form.values()]
final=[np.array(int_features)]
print(int_features)
print(final)
prediction=model.predict_proba(final)
output='{0:.{1}f}'.format(prediction[0][1], 2)
if output>str(0.5):
return render_template('forest_fire.html',pred='Your Forest is in Danger.\nProbability of fire occuring is {}'.format(output),b="Forest Department")
else:
return render_template('forest_fire.html',pred='Your Forest is safe.\n Probability of fire occuring is {}'.format(output),b="Your Forest is Safe for now")
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000, debug=True)