-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathprediction.py
More file actions
91 lines (82 loc) · 2.6 KB
/
prediction.py
File metadata and controls
91 lines (82 loc) · 2.6 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import numpy as np
import smtplib
from flask import Flask,request,render_template
import pickle
app=Flask(__name__)
@app.route('/')
def home():
return render_template('homepage.html')
@app.route('/earth')
def earth():
return render_template('earthquake.html')
@app.route('/cyclone')
def cyclone():
return render_template('cyclone.html')
@app.route('/flood')
def flood():
return render_template('flood.html')
@app.route('/contact')
def contact():
return render_template('contactus.html')
@app.route('/esm')
def esm():
return render_template('esm.html')
@app.route('/fs')
def fs():
return render_template('FS.html')
@app.route('/cs')
def cs():
return render_template('CS.html')
@app.route('/tech')
def tech():
return render_template('tech.html')
@app.route('/pre',methods=['POST'])
def pre():
model=pickle.load(open('model.pkl','rb'))
val=[float(x) for x in request.form.values()]
fival=[np.array(val)]
prediction=model.predict(fival)
pred=float(prediction)
if(pred>0 and pred<1 ):
a="MODERATE chances of earthquake"
elif(pred >=1 ):
a="HIGH chances of earthquake"
elif(pred<0):
a="NO chances of earthquake"
else:
a="NO chances of earthquake"
return render_template('earthquake.html',prediction_text="Predicted value is: {0} and {1}".format(pred,a))
@app.route('/flo',methods=['POST'])
def flo():
fmodel=pickle.load(open('fmodel.pkl','rb'))
val=[float(x) for x in request.form.values()]
fival=[np.array(val)]
prediction=fmodel.predict(fival)
pred=float(prediction)
if(pred>0 and pred<0.9):
a="LOW chances of flood occurence"
elif(pred>=1):
a="HIGH chances of flood occurence"
else:
a="no chances of flood"
return render_template('flood.html',prediction_text="Predicted value is: {0} and {1}".format(pred,a))
@app.route('/cyl',methods=['POST'])
def cyl():
cymodel=pickle.load(open('cmodel.pkl','rb'))
val=[float(x) for x in request.form.values()]
fival=[np.array(val)]
prediction=cymodel.predict(fival)
pred=float(prediction)
if(pred>0 and pred<4.0):
a="LOW chances of hurricane occurence"
elif(pred>=4 and pred<5.5):
a="MODERATE hurricane and it is in tropical depression"
elif(pred>=5.5 and pred<6):
a="HIGH chances of hurricane and it is in tropical storm"
elif(pred>6):
a="MODERATE chances of extratropical hurricane"
else:
a="NO chances of hurricane"
return render_template('cyclone.html',prediction_text="Predicted value is: {0} and {1}".format(pred,a))
if __name__ == "__main__":
app.run(debug=True)