Nahiyan14 commited on
Commit
417573f
·
verified ·
1 Parent(s): 65fae25

Upload 3 files

Browse files
Files changed (3) hide show
  1. app.py +56 -0
  2. pipeline.pkl +3 -0
  3. requirements.txt +6 -0
app.py ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import pandas as pd
3
+ import joblib
4
+
5
+ # Load the pre-trained pipeline
6
+ pipeline = joblib.load("pipeline.pkl")
7
+
8
+ def predict(fixed_acidity, volatile_acidity, citric_acid, residual_sugar,
9
+ chlorides, free_sulfur_dioxide, total_sulfur_dioxide, density,
10
+ pH, sulphates, alcohol, Id=None):
11
+ # Create a DataFrame with the input data
12
+ input_data = {
13
+ 'fixed_acidity': [float(fixed_acidity)],
14
+ 'volatile_acidity': [float(volatile_acidity)],
15
+ 'citric_acid': [float(citric_acid)],
16
+ 'residual_sugar': [float(residual_sugar)],
17
+ 'chlorides': [float(chlorides)],
18
+ 'free_sulfur_dioxide': [float(free_sulfur_dioxide)],
19
+ 'total_sulfur_dioxide': [float(total_sulfur_dioxide)],
20
+ 'density': [float(density)],
21
+ 'pH': [float(pH)],
22
+ 'sulphates': [float(sulphates)],
23
+ 'alcohol': [float(alcohol)],
24
+ 'Id': [Id] if Id is not None else [0] # Optional ID column
25
+ }
26
+ df = pd.DataFrame(input_data)
27
+
28
+ # Make predictions
29
+ predictions = pipeline.predict(df)
30
+ return {"Quality Prediction": predictions[0]}
31
+
32
+ # Define Gradio interface
33
+ inputs = [
34
+ gr.inputs.Textbox(label='Fixed Acidity'),
35
+ gr.inputs.Textbox(label='Volatile Acidity'),
36
+ gr.inputs.Textbox(label='Citric Acid'),
37
+ gr.inputs.Textbox(label='Residual Sugar'),
38
+ gr.inputs.Textbox(label='Chlorides'),
39
+ gr.inputs.Textbox(label='Free Sulfur Dioxide'),
40
+ gr.inputs.Textbox(label='Total Sulfur Dioxide'),
41
+ gr.inputs.Textbox(label='Density'),
42
+ gr.inputs.Textbox(label='pH'),
43
+ gr.inputs.Textbox(label='Sulphates'),
44
+ gr.inputs.Textbox(label='Alcohol'),
45
+ gr.inputs.Textbox(label='Id', optional=True),
46
+ ]
47
+
48
+ interface = gr.Interface(
49
+ fn=predict,
50
+ inputs=inputs,
51
+ outputs="json",
52
+ title="Wine Quality Prediction",
53
+ description="Enter wine parameters to predict its quality."
54
+ )
55
+
56
+ interface.launch()
pipeline.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:388f78b8e6955799a702f071db804beb51329f505b2fe51a13310d375c7714e3
3
+ size 309075
requirements.txt ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ pandas
2
+ numpy
3
+ scikit-learn
4
+ catboost
5
+ gradio
6
+ joblib