Spaces:
Sleeping
Sleeping
Upload 4 files
Browse files- app.py +45 -0
- decision_tree_model.pkl +3 -0
- linear_regression_model.pkl +3 -0
- random_forest_model.pkl +3 -0
app.py
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import joblib
|
| 4 |
+
from sklearn.linear_model import LinearRegression
|
| 5 |
+
from sklearn.tree import DecisionTreeRegressor
|
| 6 |
+
from sklearn.ensemble import RandomForestRegressor
|
| 7 |
+
|
| 8 |
+
# Load the trained models (make sure these pickle files are uploaded in the same directory as your app.py in Hugging Face Space)
|
| 9 |
+
lr = joblib.load('linear_regression_model.pkl')
|
| 10 |
+
dt = joblib.load('decision_tree_model.pkl')
|
| 11 |
+
rf = joblib.load('random_forest_model.pkl')
|
| 12 |
+
|
| 13 |
+
# Streamlit UI
|
| 14 |
+
st.title("Indian Food Cook Time Prediction")
|
| 15 |
+
st.write("Enter the features to predict the cook time of Indian food.")
|
| 16 |
+
|
| 17 |
+
# Input fields
|
| 18 |
+
diet = st.selectbox("Diet Type", options=["vegetarian", "non vegetarian"])
|
| 19 |
+
prep_time = st.number_input("Preparation Time (minutes)", min_value=0, step=1)
|
| 20 |
+
ingredients = st.number_input("Number of Ingredients", min_value=1, step=1)
|
| 21 |
+
|
| 22 |
+
# Convert diet to numeric (0 for vegetarian, 1 for non-vegetarian)
|
| 23 |
+
diet = 0 if diet == "vegetarian" else 1
|
| 24 |
+
|
| 25 |
+
# Combine inputs into a DataFrame for prediction
|
| 26 |
+
input_data = pd.DataFrame({
|
| 27 |
+
'diet': [diet],
|
| 28 |
+
'prep_time': [prep_time],
|
| 29 |
+
'num_ingredients': [ingredients]
|
| 30 |
+
})
|
| 31 |
+
|
| 32 |
+
# Model selection
|
| 33 |
+
model_choice = st.selectbox("Select a Model", ["Linear Regression", "Decision Tree", "Random Forest"])
|
| 34 |
+
|
| 35 |
+
if st.button("Predict Cook Time"):
|
| 36 |
+
# Make prediction based on model choice
|
| 37 |
+
if model_choice == "Linear Regression":
|
| 38 |
+
prediction = lr.predict(input_data)[0]
|
| 39 |
+
elif model_choice == "Decision Tree":
|
| 40 |
+
prediction = dt.predict(input_data)[0]
|
| 41 |
+
elif model_choice == "Random Forest":
|
| 42 |
+
prediction = rf.predict(input_data)[0]
|
| 43 |
+
|
| 44 |
+
# Display the predicted cook time
|
| 45 |
+
st.write(f"Predicted Cook Time: {round(prediction, 2)} minutes")
|
decision_tree_model.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:dad5e8aa2bd01508be87dcbfa08a67e3c86a0a7589b51b22d6709b04f9133f09
|
| 3 |
+
size 8929
|
linear_regression_model.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9badbd8144112a7358f14a306a88df1bbe24efa6743a57c75b4687ff807ff259
|
| 3 |
+
size 928
|
random_forest_model.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:cb8f1b31d3a1032369038017849b85de8839188af50eb2d6369333b6104a0d43
|
| 3 |
+
size 611169
|