Edward Nagy commited on
Commit
706b0ec
1 Parent(s): ed4cc16

Add application file

Browse files
Files changed (3) hide show
  1. README.md +5 -4
  2. app.py +52 -0
  3. requirements.txt +3 -0
README.md CHANGED
@@ -1,12 +1,13 @@
1
  ---
2
  title: Wine Quality Prediction
3
- emoji: 👁
4
- colorFrom: red
5
- colorTo: gray
6
  sdk: gradio
7
- sdk_version: 4.4.1
8
  app_file: app.py
9
  pinned: false
 
10
  ---
11
 
12
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
  title: Wine Quality Prediction
3
+ emoji: 🍷
4
+ colorFrom: purple
5
+ colorTo: green
6
  sdk: gradio
7
+ sdk_version: 3.14.0
8
  app_file: app.py
9
  pinned: false
10
+ license: apache-2.0
11
  ---
12
 
13
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from PIL import Image
3
+ import requests
4
+ import hopsworks
5
+ import joblib
6
+ import pandas as pd
7
+
8
+ project = hopsworks.login()
9
+ fs = project.get_feature_store()
10
+
11
+
12
+ mr = project.get_model_registry()
13
+ model = mr.get_model("wine_class_model", version=1)
14
+ model_dir = model.download()
15
+ model = joblib.load(model_dir + "/wine_class_model.pkl")
16
+ print("Model downloaded")
17
+
18
+ def wine_quality_class(wine_type, fixed_acidity, volatile_acidity, citric_acid, residual_sugar, chlorides, free_sulfur_dioxide, density, pH, sulphates, alcohol):
19
+ print("Calling function")
20
+ df = pd.DataFrame([[wine_type, fixed_acidity, volatile_acidity, citric_acid, residual_sugar, chlorides, free_sulfur_dioxide, density, pH, sulphates, alcohol]],
21
+ columns=['type','fixed_acidity','volatile_acidity','citric_acid','residual_sugar','chlorides','free_sulfur_dioxide','density','pH','sulphates','alcohol'])
22
+ print("Predicting")
23
+ print(df)
24
+ # 'res' is a list of predictions returned as the label.
25
+ res = model.predict(df)
26
+ return res[0]
27
+
28
+
29
+ demo = gr.Interface(
30
+ fn=wine_quality_class,
31
+ title="Wine Quality Predictive Analytics",
32
+ description="Experiment with wine quality to predict which quality it is.",
33
+ allow_flagging="never",
34
+ # type,fixed acidity,volatile acidity,citric acid,residual sugar,chlorides,free sulfur dioxide,density,pH,sulphates,alcohol,quality
35
+ # e.g. white,7,0.27,0.36,20.7,0.045,45,170,1.001,3,0.45,8.8,6
36
+ inputs=[
37
+ gr.inputs.Dropdown(["white", "red"], label="Wine type"),
38
+ gr.inputs.Number(default=7.0, label="fixed acidity"),
39
+ gr.inputs.Number(default=0.27, label="volatile acidity"),
40
+ gr.inputs.Number(default=0.36, label="citric acid"),
41
+ gr.inputs.Number(default=20.7, label="residual sugar"),
42
+ gr.inputs.Number(default=0.045, label="chlorides"),
43
+ gr.inputs.Number(default=45, label="free sulfur dioxide"),
44
+ gr.inputs.Number(default=1.001, label="density"),
45
+ gr.inputs.Number(default=3.0, label="pH"),
46
+ gr.inputs.Number(default=0.45, label="sulphates"),
47
+ gr.inputs.Number(default=8.8, label="alcohol"),
48
+ ],
49
+ outputs=gr.Textbox(type="str"))
50
+
51
+ demo.launch(debug=True)
52
+
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ hopsworks
2
+ joblib
3
+ scikit-learn==1.1.1