-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapplication.py
37 lines (30 loc) · 1.23 KB
/
application.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
from flask import Flask, request, render_template
import pickle
import numpy as np
from sklearn.preprocessing import StandardScaler
app = Flask(__name__)
# Load the ridge regressor model and scaler
ridge_model = pickle.load(open('./models/rid.pkl', 'rb'))
Standard_Scaler = pickle.load(open('./models/scale.pkl', 'rb'))
@app.route("/")
def index():
return render_template('home.html')
@app.route('/predictdata', methods=['GET','POST'])
def predict_datapoint():
if request.method=="POST":
Temperature = float(request.form.get('Temperature'))
RH = float(request.form.get('RH'))
Ws = float(request.form.get('Ws'))
Rain = float(request.form.get('Rain'))
FFMC = float(request.form.get('FFMC'))
DMC = float(request.form.get('DMC'))
ISI = float(request.form.get('ISI'))
CLASSES = float(request.form.get('CLASSES'))
Region = float(request.form.get('Region'))
new_data = Standard_Scaler.transform([[Temperature, RH, Ws, Rain, FFMC, DMC, ISI, CLASSES, Region]])
result = ridge_model.predict(new_data)
return render_template('home.html', results=result[0])
else:
render_template('home.html')
if __name__ == "__main__":
app.run(host="0.0.0.0")