-
Notifications
You must be signed in to change notification settings - Fork 0
/
Wine_Quality_Prediction_WebApp.py
81 lines (58 loc) · 2.2 KB
/
Wine_Quality_Prediction_WebApp.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
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
# -*- coding: utf-8 -*-
"""
Created on Wed May 22 12:17:04 2024
@author: prachet
"""
import numpy as np
import pickle
import streamlit as st
#loading. the saved model
loaded_model = pickle.load(open('winequality_trained_model.sav','rb'))
#creating a function for prediction
def wine_quality_prediction(input_data):
#changing the input data to numpy
input_data_as_numpy_array = np.asarray(input_data)
#reshape the array as we are predicting on 1 instance
input_data_reshaped = input_data_as_numpy_array.reshape(1,-1)
prediction = loaded_model.predict(input_data_reshaped)
#print(prediction)
if(prediction[0]==1):
return 'Good Quality Wine'
else:
return 'Bad Quality Wine'
def main():
#giving a title
st.title('Wine Quality Prediction Web App')
#getting input data from user
col1 , col2 = st.columns(2)
#getting input data from user
with col1:
fixed_acidity = st.text_input("Fixed Acidity of Wine")
with col2:
volatile_acidity = st.text_input("Volatile Acidity of Wine")
with col1:
citric_acid = st.text_input("Citric Acid in Wine")
with col2:
residual_sugar = st.text_input("Residual Sugar in Wine")
with col1:
chlorides = st.text_input("Chlorides in Wine")
with col2:
free_sulfur_dioxide = st.text_input("Free Sulfur-dioxide in Wine")
with col1:
total_sulfur_dioxide = st.text_input("Total Sulfur-dioxide in Wine")
with col2:
density = st.text_input("Density of Wine")
with col1:
pH = st.text_input("pH of Wine")
with col2:
sulphates = st.text_input("Sulphates in Wine")
with col1:
alcohol = st.text_input("Alcohol in Wine")
# code for prediction
wine_quality = ''
#creating a button for Prediction
if st.button('Predict Wine Quality'):
wine_quality =wine_quality_prediction((fixed_acidity,volatile_acidity,citric_acid,residual_sugar,chlorides,free_sulfur_dioxide,total_sulfur_dioxide,density,pH,sulphates,alcohol))
st.success(wine_quality)
if __name__ == '__main__':
main()