khushi155 commited on
Commit
e6a40cf
·
verified ·
1 Parent(s): 448a101

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +40 -0
app.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import joblib
3
+ import pandas as pd
4
+
5
+ # Load trained model
6
+ model = joblib.load("wine_rf_model.pkl")
7
+
8
+ # Define prediction function
9
+ def predict(fixed_acidity, volatile_acidity, citric_acid, residual_sugar, chlorides,
10
+ free_sulfur_dioxide, total_sulfur_dioxide, density, pH, sulphates, alcohol):
11
+ data = pd.DataFrame([[fixed_acidity, volatile_acidity, citric_acid, residual_sugar, chlorides,
12
+ free_sulfur_dioxide, total_sulfur_dioxide, density, pH, sulphates, alcohol]],
13
+ columns=["fixed acidity", "volatile acidity", "citric acid", "residual sugar",
14
+ "chlorides", "free sulfur dioxide", "total sulfur dioxide", "density",
15
+ "pH", "sulphates", "alcohol"])
16
+ prediction = model.predict(data)[0]
17
+ return f"Predicted Wine Quality: {prediction}"
18
+
19
+ # Create Gradio interface
20
+ iface = gr.Interface(
21
+ fn=predict,
22
+ inputs=[
23
+ gr.Number(label="Fixed Acidity"),
24
+ gr.Number(label="Volatile Acidity"),
25
+ gr.Number(label="Citric Acid"),
26
+ gr.Number(label="Residual Sugar"),
27
+ gr.Number(label="Chlorides"),
28
+ gr.Number(label="Free Sulfur Dioxide"),
29
+ gr.Number(label="Total Sulfur Dioxide"),
30
+ gr.Number(label="Density"),
31
+ gr.Number(label="pH"),
32
+ gr.Number(label="Sulphates"),
33
+ gr.Number(label="Alcohol")
34
+ ],
35
+ outputs=gr.Textbox(label="Prediction"),
36
+ title="Wine Quality Prediction using Random Forest",
37
+ description="Enter chemical properties of wine to predict its quality."
38
+ )
39
+
40
+ iface.launch()