ASDEIM commited on
Commit
02fb9de
·
verified ·
1 Parent(s): bf5db59

Upload app_py.py

Browse files
Files changed (1) hide show
  1. app_py.py +55 -0
app_py.py ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ """app.py
3
+
4
+ Automatically generated by Colab.
5
+
6
+ Original file is located at
7
+ https://colab.research.google.com/drive/1EUSf7Q4En-DqvH6-G5zg4q7I7oGOYPO_
8
+ """
9
+
10
+ import gradio as gr
11
+ import joblib
12
+ import numpy as np
13
+
14
+ # Load model and scaler
15
+ model = joblib.load("wine_quality_model.pkl")
16
+ scaler = joblib.load("wine_scaler.pkl")
17
+
18
+ def predict_quality(fixed_acidity, volatile_acidity, citric_acid, residual_sugar,
19
+ chlorides, free_sulfur_dioxide, total_sulfur_dioxide,
20
+ density, pH, sulphates, alcohol):
21
+
22
+ sample = np.array([[fixed_acidity, volatile_acidity, citric_acid, residual_sugar,
23
+ chlorides, free_sulfur_dioxide, total_sulfur_dioxide,
24
+ density, pH, sulphates, alcohol]])
25
+
26
+ scaled = scaler.transform(sample)
27
+ pred = model.predict(scaled)[0]
28
+
29
+ return "GOOD 🍷" if pred == 1 else "BAD ❌"
30
+
31
+ inputs = [
32
+ gr.Number(label="Fixed Acidity"),
33
+ gr.Number(label="Volatile Acidity"),
34
+ gr.Number(label="Citric Acid"),
35
+ gr.Number(label="Residual Sugar"),
36
+ gr.Number(label="Chlorides"),
37
+ gr.Number(label="Free Sulfur Dioxide"),
38
+ gr.Number(label="Total Sulfur Dioxide"),
39
+ gr.Number(label="Density"),
40
+ gr.Number(label="pH"),
41
+ gr.Number(label="Sulphates"),
42
+ gr.Number(label="Alcohol"),
43
+ ]
44
+
45
+ output = gr.Textbox(label="Prediction")
46
+
47
+ app = gr.Interface(
48
+ fn=predict_quality,
49
+ inputs=inputs,
50
+ outputs=output,
51
+ title="Wine Quality Prediction App",
52
+ description="Enter wine chemistry values to predict if wine is GOOD or BAD"
53
+ )
54
+
55
+ app.launch()