-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
43 lines (29 loc) · 1.21 KB
/
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
38
39
40
41
42
43
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 index():
return render_template("index.html")
@app.route('/forest_fire.html')
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),
bhai="kuch karna hain iska ab?")
else:
return render_template('forest_fire.html',
pred='Your Forest is safe.\n Probability of fire occuring is {}'.format(output),
bhai="Your Forest is Safe for now")
if __name__ == '__main__':
app.run(debug=True)