-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.py
More file actions
30 lines (23 loc) · 880 Bytes
/
app.py
File metadata and controls
30 lines (23 loc) · 880 Bytes
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
#importing packages
from flask import Flask, render_template, request
import pickle
app = Flask(__name__)
# Load the trained model
with open('random_forest_model.pkl', 'rb') as file:
model = pickle.load(file)
@app.route('/')
def index():
return render_template('index.html')
@app.route('/predict', methods=['POST'])
def predict():
# Get input values from the form
precipitation = float(request.form['precipitation'])
temp_max = float(request.form['temp_max'])
temp_min = float(request.form['temp_min'])
wind = float(request.form['wind'])
# Make a prediction using the loaded model
prediction = model.predict([[precipitation, temp_max, temp_min, wind]])
# Pass the prediction result to the result.html page
return render_template('result.html', prediction=prediction[0])
if __name__ == '__main__':
app.run(debug=True)