Sukhmanpreet commited on
Commit
eded884
·
verified ·
1 Parent(s): ccd10ef

Upload 3 files

Browse files
Files changed (3) hide show
  1. app.py +44 -0
  2. model.pkl +3 -0
  3. requirements.txt +4 -0
app.py ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import numpy as np
3
+ import pickle
4
+
5
+ # Function to load the trained model # Cache the model so it's loaded only once per session
6
+ def load_model(model_file):
7
+ with open(model_file, 'rb') as f:
8
+ model = pickle.load(f)
9
+ return model
10
+
11
+ # Function to predict wine quality
12
+ def predict_quality(model, features):
13
+ input_features = np.array(features).reshape(1, -1)
14
+ prediction = model.predict(input_features)
15
+ predicted_quality = prediction[0]
16
+ return predicted_quality
17
+
18
+ # Load the model
19
+ model_file = 'model.pkl' # Replace with your model file path
20
+ model = load_model(model_file)
21
+
22
+ # Streamlit UI
23
+ st.title('Wine Quality Prediction')
24
+
25
+ # Input fields for each feature
26
+ st.header('Input Features')
27
+ fixed_acidity = st.slider('Fixed Acidity', min_value=4.0, max_value=16.0, value=8.0, step=0.1)
28
+ volatile_acidity = st.slider('Volatile Acidity', min_value=0.1, max_value=2.0, value=0.5, step=0.01)
29
+ citric_acid = st.slider('Citric Acid', min_value=0.0, max_value=1.0, value=0.5, step=0.01)
30
+ residual_sugar = st.slider('Residual Sugar', min_value=0.0, max_value=20.0, value=10.0, step=0.1)
31
+ chlorides = st.slider('Chlorides', min_value=0.0, max_value=1.0, value=0.08, step=0.01)
32
+ free_sulfur_dioxide = st.slider('Free Sulfur Dioxide', min_value=1, max_value=100, value=30, step=1)
33
+ total_sulfur_dioxide = st.slider('Total Sulfur Dioxide', min_value=1, max_value=300, value=100, step=1)
34
+ density = st.slider('Density', min_value=0.8, max_value=1.0, value=0.996, step=0.001)
35
+ pH = st.slider('pH', min_value=2.0, max_value=4.0, value=3.0, step=0.01)
36
+ sulphates = st.slider('Sulphates', min_value=0.2, max_value=2.0, value=0.5, step=0.01)
37
+ alcohol = st.slider('Alcohol', min_value=8.0, max_value=15.0, value=10.0, step=0.1)
38
+
39
+ # Predict button
40
+ if st.button('Predict'):
41
+ features = [fixed_acidity, volatile_acidity, citric_acid, residual_sugar, chlorides,
42
+ free_sulfur_dioxide, total_sulfur_dioxide, density, pH, sulphates, alcohol]
43
+ predicted_quality = predict_quality(model, features)
44
+ st.success(f'Predicted wine quality: {predicted_quality}')
model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:87939868f417c7f27248f5d1aba3a49ffeec8d1aa2819a352fdb907db2c23c2b
3
+ size 826
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ streamlit
2
+ pandas
3
+ numpy
4
+ scikit-learn