Refactor wine function to accept input in a
Browse files
app.py
CHANGED
|
@@ -12,10 +12,16 @@ model_dir = model.download()
|
|
| 12 |
model = joblib.load(model_dir + "/wine_model.pkl")
|
| 13 |
print("Model downloaded")
|
| 14 |
|
| 15 |
-
def wine(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
print("Calling function")
|
| 17 |
-
df = pd.DataFrame([[
|
| 18 |
-
|
| 19 |
print("Predicting")
|
| 20 |
print(df)
|
| 21 |
# 'res' is a list of predictions returned as the label.
|
|
@@ -32,16 +38,16 @@ iface = gr.Interface(
|
|
| 32 |
description="Predict the quality of a wine based on its features.",
|
| 33 |
allow_flagging="never",
|
| 34 |
inputs=[
|
| 35 |
-
gr.Number(label="
|
|
|
|
|
|
|
|
|
|
| 36 |
gr.Number(label="chlorides"),
|
| 37 |
-
gr.Number(label="
|
| 38 |
-
gr.Number(label="fixed acidity"),
|
| 39 |
gr.Number(label="ph"),
|
| 40 |
-
gr.Number(label="residual sugar"),
|
| 41 |
gr.Number(label="sulphates"),
|
| 42 |
-
gr.Number(label="
|
| 43 |
-
gr.
|
| 44 |
-
gr.Number(label="volatile acidity"),
|
| 45 |
],
|
| 46 |
outputs=gr.Number(label="quality"))
|
| 47 |
|
|
|
|
| 12 |
model = joblib.load(model_dir + "/wine_model.pkl")
|
| 13 |
print("Model downloaded")
|
| 14 |
|
| 15 |
+
def wine(fixed_acidity, volatile_acidity, citric_acid, residual_sugar, chlorides, total_sulfur_dioxide, ph, sulphates, alcohol, type):
|
| 16 |
+
|
| 17 |
+
if type == "red":
|
| 18 |
+
type = 0
|
| 19 |
+
else:
|
| 20 |
+
type = 1
|
| 21 |
+
|
| 22 |
print("Calling function")
|
| 23 |
+
df = pd.DataFrame([[fixed_acidity, volatile_acidity, citric_acid, residual_sugar, chlorides, total_sulfur_dioxide, ph, sulphates, alcohol, type]], columns=['fixed acidity', 'volatile acidity', 'citric acid', 'residual sugar', 'chlorides', 'total sulfur dioxide', 'ph', 'sulphates', 'alcohol', 'type'])
|
| 24 |
+
|
| 25 |
print("Predicting")
|
| 26 |
print(df)
|
| 27 |
# 'res' is a list of predictions returned as the label.
|
|
|
|
| 38 |
description="Predict the quality of a wine based on its features.",
|
| 39 |
allow_flagging="never",
|
| 40 |
inputs=[
|
| 41 |
+
gr.Number(label="fixed_acidity"),
|
| 42 |
+
gr.Number(label="volatile_acidity"),
|
| 43 |
+
gr.Number(label="citric_acid"),
|
| 44 |
+
gr.Number(label="residual_sugar"),
|
| 45 |
gr.Number(label="chlorides"),
|
| 46 |
+
gr.Number(label="total_sulfur_dioxide"),
|
|
|
|
| 47 |
gr.Number(label="ph"),
|
|
|
|
| 48 |
gr.Number(label="sulphates"),
|
| 49 |
+
gr.Number(label="alcohol"),
|
| 50 |
+
gr.Radio(["red", "white"], label="type")
|
|
|
|
| 51 |
],
|
| 52 |
outputs=gr.Number(label="quality"))
|
| 53 |
|