-
Notifications
You must be signed in to change notification settings - Fork 2
/
app.py
38 lines (30 loc) · 1.38 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
from flask import Flask, render_template, request
import pickle
import numpy as np
# Load the Model
filename = 'rf_classifier_model.pkl'
classifier = pickle.load(open(filename, 'rb'))
app = Flask(__name__)
@app.route('/')
def home():
return render_template('index.html')
@app.route('/predict', methods=['POST'])
def predict():
if request.method == 'POST':
wine_type = int(request.form['type'])
fixed_acidity = float(request.form['fixed acidity'])
volatile_acidity = float(request.form['volatile acidity'])
citric_acid = float(request.form['citric acid'])
residual_sugar = float(request.form['residual sugar'])
chlorides = float(request.form['chlorides'])
free_sd = float(request.form['free sulfur dioxide'])
total_sd = float(request.form['total sulfur dioxide'])
density = float(request.form['density'])
ph = float(request.form['pH'])
sulphates = float(request.form['sulphates'])
alcohol = float(request.form['alcohol'])
input_data = np.array([[wine_type, fixed_acidity, volatile_acidity, citric_acid, residual_sugar, chlorides, free_sd, total_sd, density, ph, sulphates, alcohol]])
my_prediction = classifier.predict(input_data)
return render_template('result.html', prediction=my_prediction)
if __name__ == '__main__':
app.run(debug=True)