Spaces:
Build error
Build error
Commit
·
63c9787
1
Parent(s):
159cb19
Add wine predictor app
Browse files
app.py
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from sklearn.hub import HubLoader
|
| 3 |
+
|
| 4 |
+
hub = HubLoader("risingodegua/wine-quality-model", "sklearn_model.joblib")
|
| 5 |
+
model = hub.load()
|
| 6 |
+
|
| 7 |
+
def wine_quality_predictor(X):
|
| 8 |
+
'''Predicts the quality of wine
|
| 9 |
+
|
| 10 |
+
Parameters
|
| 11 |
+
----------
|
| 12 |
+
|
| 13 |
+
X : numpy, list
|
| 14 |
+
A list containing values used for prediction.
|
| 15 |
+
|
| 16 |
+
Returns
|
| 17 |
+
-------
|
| 18 |
+
List
|
| 19 |
+
The list of predicted values.
|
| 20 |
+
|
| 21 |
+
'''
|
| 22 |
+
return model.predict(X.to_numpy())
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
headers = [
|
| 26 |
+
"fixed acidity",
|
| 27 |
+
"volatile acidity",
|
| 28 |
+
"citric acid",
|
| 29 |
+
"residual sugar",
|
| 30 |
+
"chlorides",
|
| 31 |
+
"free sulfur dioxide",
|
| 32 |
+
"total sulfur dioxide",
|
| 33 |
+
"density",
|
| 34 |
+
"pH",
|
| 35 |
+
"sulphates",
|
| 36 |
+
"alcohol",
|
| 37 |
+
]
|
| 38 |
+
default = [
|
| 39 |
+
[7.4, 0.7, 0, 1.9, 0.076, 11, 34, 0.9978, 3.51, 0.56, 9.4],
|
| 40 |
+
[7.8, 0.88, 0, 2.6, 0.098, 25, 67, 0.9968, 3.2, 0.68, 9.8],
|
| 41 |
+
[7.8, 0.76, 0.04, 2.3, 0.092, 15, 54, 0.997, 3.26, 0.65, 9.8],
|
| 42 |
+
]
|
| 43 |
+
|
| 44 |
+
iface = gr.Interface(
|
| 45 |
+
wine_quality_predictor,
|
| 46 |
+
gr.inputs.Dataframe(
|
| 47 |
+
headers=headers,
|
| 48 |
+
default=default,
|
| 49 |
+
),
|
| 50 |
+
["numpy"],
|
| 51 |
+
description="Enter wine properties for prediction"
|
| 52 |
+
)
|
| 53 |
+
iface.launch()
|