Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,16 +1,7 @@
|
|
1 |
-
import subprocess
|
2 |
-
import sys
|
3 |
import gradio as gr
|
4 |
import pandas as pd
|
5 |
import pickle
|
6 |
|
7 |
-
# Check if scikit-learn is installed, and if not, install it
|
8 |
-
try:
|
9 |
-
import sklearn
|
10 |
-
except ModuleNotFoundError:
|
11 |
-
subprocess.check_call([sys.executable, "-m", "pip", "install", "scikit-learn"])
|
12 |
-
import sklearn
|
13 |
-
|
14 |
# Load the pre-trained model
|
15 |
with open('best_model.pkl', 'rb') as model_file:
|
16 |
model = pickle.load(model_file)
|
@@ -52,22 +43,22 @@ def predict_coffee_type(time_of_day, coffee_strength, sweetness_level, milk_type
|
|
52 |
|
53 |
return coffee_type
|
54 |
|
55 |
-
# Gradio Interface
|
56 |
interface = gr.Interface(
|
57 |
fn=predict_coffee_type,
|
58 |
inputs=[
|
59 |
-
gr.
|
60 |
-
gr.
|
61 |
-
gr.
|
62 |
-
gr.
|
63 |
-
gr.
|
64 |
-
gr.
|
65 |
-
gr.
|
66 |
-
gr.
|
67 |
-
gr.
|
68 |
-
gr.
|
69 |
],
|
70 |
-
outputs=gr.
|
71 |
title="Coffee Type Recommendation"
|
72 |
)
|
73 |
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
import pandas as pd
|
3 |
import pickle
|
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
# Load the pre-trained model
|
6 |
with open('best_model.pkl', 'rb') as model_file:
|
7 |
model = pickle.load(model_file)
|
|
|
43 |
|
44 |
return coffee_type
|
45 |
|
46 |
+
# Gradio Interface using components
|
47 |
interface = gr.Interface(
|
48 |
fn=predict_coffee_type,
|
49 |
inputs=[
|
50 |
+
gr.Dropdown(['morning', 'afternoon', 'evening'], label="Time of Day"),
|
51 |
+
gr.Dropdown(['mild', 'regular', 'strong'], label="Coffee Strength"),
|
52 |
+
gr.Dropdown(['unsweetened', 'lightly sweetened', 'sweet'], label="Sweetness Level"),
|
53 |
+
gr.Dropdown(['none', 'regular', 'skim', 'almond'], label="Milk Type"),
|
54 |
+
gr.Dropdown(['hot', 'iced', 'cold brew'], label="Coffee Temperature"),
|
55 |
+
gr.Dropdown(['yes', 'no'], label="Flavored Coffee"),
|
56 |
+
gr.Dropdown(['low', 'medium', 'high'], label="Caffeine Tolerance"),
|
57 |
+
gr.Dropdown(['Arabica', 'Robusta', 'blend'], label="Coffee Bean"),
|
58 |
+
gr.Dropdown(['small', 'medium', 'large'], label="Coffee Size"),
|
59 |
+
gr.Dropdown(['none', 'vegan', 'lactose-intolerant'], label="Dietary Preferences")
|
60 |
],
|
61 |
+
outputs=gr.Textbox(label="Recommended Coffee Type"),
|
62 |
title="Coffee Type Recommendation"
|
63 |
)
|
64 |
|