Spaces:
Sleeping
Sleeping
Delete streamlit_app.py
Browse files- streamlit_app.py +0 -41
streamlit_app.py
DELETED
|
@@ -1,41 +0,0 @@
|
|
| 1 |
-
import streamlit as st
|
| 2 |
-
import joblib
|
| 3 |
-
import pandas as pd
|
| 4 |
-
from huggingface_hub import hf_hub_download
|
| 5 |
-
|
| 6 |
-
# Load model from your HF repo
|
| 7 |
-
model_file = hf_hub_download(repo_id="danialsiddiqui/task6-model", filename="model.joblib")
|
| 8 |
-
model_data = joblib.load(model_file)
|
| 9 |
-
model = model_data["model"]
|
| 10 |
-
columns = model_data["columns"]
|
| 11 |
-
|
| 12 |
-
st.title("Supermarket Revenue Prediction")
|
| 13 |
-
|
| 14 |
-
# Input fields
|
| 15 |
-
gender = st.selectbox("Gender", ["Male", "Female"])
|
| 16 |
-
customer_type = st.selectbox("Customer Type", ["Member", "Normal"])
|
| 17 |
-
product_line = st.selectbox("Product Line", ["Beverages", "Food", "Health and beauty", "Fashion", "Electronics", "Home and lifestyle", "Sports and travel"])
|
| 18 |
-
unit_price = st.number_input("Unit Price", min_value=0.0, value=10.0)
|
| 19 |
-
quantity = st.number_input("Quantity", min_value=1, value=1)
|
| 20 |
-
tax_5 = st.number_input("Tax 5%", min_value=0.0, value=0.0)
|
| 21 |
-
|
| 22 |
-
if st.button("Predict"):
|
| 23 |
-
# Create dataframe
|
| 24 |
-
df = pd.DataFrame([{
|
| 25 |
-
"gender": gender,
|
| 26 |
-
"customer_type": customer_type,
|
| 27 |
-
"product_line": product_line,
|
| 28 |
-
"unit_price": unit_price,
|
| 29 |
-
"quantity": quantity,
|
| 30 |
-
"tax_5": tax_5
|
| 31 |
-
}])
|
| 32 |
-
|
| 33 |
-
# One-hot encode same as training
|
| 34 |
-
df = pd.get_dummies(df)
|
| 35 |
-
for col in columns:
|
| 36 |
-
if col not in df.columns:
|
| 37 |
-
df[col] = 0
|
| 38 |
-
df = df[columns]
|
| 39 |
-
|
| 40 |
-
prediction = model.predict(df)[0]
|
| 41 |
-
st.success(f"Predicted Revenue: {prediction:.2f}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|