Sathwikchowdary commited on
Commit
9642b8b
·
verified ·
1 Parent(s): 3688360

Create home.py

Browse files
Files changed (1) hide show
  1. home.py +88 -0
home.py ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pickle
3
+ import numpy as np
4
+ import os
5
+
6
+ # Load the trained model
7
+ MODEL_PATH = "/home/user/app/wine_quality_model.pkl" # Update with your actual model path
8
+
9
+ # Streamlit UI
10
+ st.set_page_config(page_title="🍷 Wine Quality Predictor", layout="centered")
11
+
12
+ # Custom Styling for Background and Text
13
+ st.markdown(
14
+ """
15
+ <style>
16
+ .stApp {
17
+ background-color: #003366;
18
+ color: white;
19
+ }
20
+ .title {
21
+ font-size: 36px !important;
22
+ font-weight: bold;
23
+ color: white;
24
+ text-align: center;
25
+ }
26
+ .subtitle {
27
+ font-size: 24px !important;
28
+ font-weight: bold;
29
+ color: #ffcc00;
30
+ }
31
+ .stSlider label, .stNumberInput label {
32
+ font-size: 20px !important;
33
+ font-weight: bold;
34
+ color: white;
35
+ }
36
+ .stButton>button {
37
+ background-color: #ffcc00;
38
+ color: #003366;
39
+ font-size: 18px;
40
+ font-weight: bold;
41
+ border-radius: 10px;
42
+ }
43
+ .stButton>button:hover {
44
+ background-color: #ff9900;
45
+ color: white;
46
+ }
47
+ .prediction {
48
+ font-size: 26px;
49
+ font-weight: bold;
50
+ color: #32CD32;
51
+ text-align: center;
52
+ }
53
+ </style>
54
+ """,
55
+ unsafe_allow_html=True,
56
+ )
57
+
58
+ st.markdown('<h1 class="title">🍷 Wine Quality Prediction</h1>', unsafe_allow_html=True)
59
+ st.write("Predict the quality of wine based on its properties.")
60
+
61
+ # Check if model file exists
62
+ if os.path.exists(MODEL_PATH):
63
+ with open(MODEL_PATH, "rb") as f:
64
+ model = pickle.load(f)
65
+ model_loaded = True
66
+ else:
67
+ model_loaded = False
68
+ st.error(f"Model file '{MODEL_PATH}' not found. Please check your uploaded files.")
69
+
70
+ # User Inputs
71
+ alcohol = st.slider("Alcohol Content", 8.0, 15.0, 10.0)
72
+ volatile_acidity = st.slider("Volatile Acidity", 0.1, 1.5, 0.5)
73
+ citric_acid = st.slider("Citric Acid", 0.0, 1.0, 0.3)
74
+ sulphates = st.slider("Sulphates", 0.3, 2.0, 0.8)
75
+ pH = st.slider("pH Level", 2.5, 4.0, 3.2)
76
+
77
+ # Prepare input for model
78
+ input_data = np.array([[alcohol, volatile_acidity, citric_acid, sulphates, pH]])
79
+
80
+ # Prediction
81
+ if st.button("Predict Quality"):
82
+ if model_loaded:
83
+ prediction = model.predict(input_data)
84
+ st.markdown(f'<p class="prediction">Predicted Wine Quality Score: {prediction[0]:.1f}</p>', unsafe_allow_html=True)
85
+ else:
86
+ st.error(f"Model file '{MODEL_PATH}' not found. Please upload the model file and try again.")
87
+
88
+ st.write("*Powered by Machine Learning*")