Spaces:
Sleeping
Sleeping
Upload 4 files
Browse files- app.py +40 -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,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import numpy as np
|
| 4 |
+
import joblib
|
| 5 |
+
|
| 6 |
+
# Load the trained models
|
| 7 |
+
lr = joblib.load('linear_regression_model.pkl')
|
| 8 |
+
dt = joblib.load('decision_tree_model.pkl')
|
| 9 |
+
rf = joblib.load('random_forest_model.pkl')
|
| 10 |
+
|
| 11 |
+
# Streamlit UI
|
| 12 |
+
st.title("Indian Food Cook Time Prediction")
|
| 13 |
+
st.write("Enter the features to predict the cook time of Indian food.")
|
| 14 |
+
|
| 15 |
+
# Input fields
|
| 16 |
+
diet = st.selectbox("Diet Type", options=["vegetarian", "non vegetarian"])
|
| 17 |
+
prep_time = st.number_input("Preparation Time (minutes)", min_value=0, step=1)
|
| 18 |
+
ingredients = st.number_input("Number of Ingredients", min_value=1, step=1)
|
| 19 |
+
|
| 20 |
+
# Convert diet to numerical
|
| 21 |
+
diet = 0 if diet == "vegetarian" else 1
|
| 22 |
+
|
| 23 |
+
# Combine inputs into a DataFrame
|
| 24 |
+
input_data = pd.DataFrame({
|
| 25 |
+
'diet': [diet],
|
| 26 |
+
'prep_time': [prep_time],
|
| 27 |
+
'num_ingredients': [ingredients]
|
| 28 |
+
})
|
| 29 |
+
|
| 30 |
+
# Model selection
|
| 31 |
+
model_choice = st.selectbox("Select a Model", ["Linear Regression", "Decision Tree", "Random Forest"])
|
| 32 |
+
if st.button("Predict Cook Time"):
|
| 33 |
+
if model_choice == "Linear Regression":
|
| 34 |
+
prediction = lr.predict(input_data)[0]
|
| 35 |
+
elif model_choice == "Decision Tree":
|
| 36 |
+
prediction = dt.predict(input_data)[0]
|
| 37 |
+
elif model_choice == "Random Forest":
|
| 38 |
+
prediction = rf.predict(input_data)[0]
|
| 39 |
+
|
| 40 |
+
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:2608faee475773179048fd887066ec1760538900f37d8b783b10ed8f26de20f9
|
| 3 |
+
size 5601
|
linear_regression_model.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:86dba6eee1ed5bb10b65d69244111c0a4df032b9cbd01832a2b84ae260edb363
|
| 3 |
+
size 904
|
random_forest_model.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a56d767058dfcdac7aee5b436497a15962518d77d90bdaf81c61ae1720bff5b9
|
| 3 |
+
size 367505
|