Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub (#1)
Browse files- Upload folder using huggingface_hub (05fb1eb862e18658310220a565b80a242dfd7e4b)
Co-authored-by: Rajdeep Jain <raj2261992@users.noreply.huggingface.co>
app.py
CHANGED
|
@@ -1,44 +1,32 @@
|
|
| 1 |
-
import requests
|
| 2 |
import streamlit as st
|
| 3 |
import pandas as pd
|
| 4 |
-
import
|
| 5 |
|
| 6 |
-
|
|
|
|
|
|
|
| 7 |
|
| 8 |
-
#
|
| 9 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
-
#
|
| 12 |
-
|
| 13 |
-
Product_Sugar_Content = st.selectbox("Product Sugar Content", ["Low Fat", "Regular"])
|
| 14 |
-
Product_Allocated_Area = st.number_input("Product Allocated Area (area allocated to the product)", min_value=0.001, max_value=1.0, value=0.045, step=0.001)
|
| 15 |
-
Product_Type = st.selectbox("Product Type", ["Baking Goods", "Breads", "Breakfast", "Canned", "Dairy", "Frozen Foods", "Fruits and Vegetables", "Hard Drinks", "Health and Hygiene", "Household", "Meat", "Others", "Seafood", "Snack Foods", "Soft Drinks"])
|
| 16 |
-
Product_MRP = st.number_input("Product MRP (maximum retail price in ₹)", min_value=10.0, max_value=500.0, value=150.75)
|
| 17 |
-
Store_Id = st.selectbox("Store ID", ["OUT010", "OUT013", "OUT017", "OUT018", "OUT019", "OUT027", "OUT035", "OUT045", "OUT046", "OUT049"])
|
| 18 |
-
Store_Establishment_Year = st.number_input("Store Establishment Year", min_value=1985, max_value=2025, value=2005)
|
| 19 |
-
Store_Size = st.selectbox("Store Size", ["Small", "Medium", "High"])
|
| 20 |
-
Store_Location_City_Type = st.selectbox("Store Location City Type", ["Tier 1", "Tier 2", "Tier 3"])
|
| 21 |
-
Store_Type = st.selectbox("Store Type", ["Grocery Store", "Supermarket Type1", "Supermarket Type2", "Supermarket Type3"])
|
| 22 |
|
| 23 |
-
product_data = {
|
| 24 |
-
'Product_Weight': Product_Weight,
|
| 25 |
-
'Product_Sugar_Content': Product_Sugar_Content,
|
| 26 |
-
'Product_Allocated_Area': Product_Allocated_Area,
|
| 27 |
-
'Product_Type': Product_Type,
|
| 28 |
-
'Product_MRP': Product_MRP,
|
| 29 |
-
'Store_Id': Store_Id,
|
| 30 |
-
'Store_Establishment_Year': Store_Establishment_Year,
|
| 31 |
-
'Store_Size': Store_Size,
|
| 32 |
-
'Store_Location_City_Type': Store_Location_City_Type,
|
| 33 |
-
'Store_Type': Store_Type
|
| 34 |
-
}
|
| 35 |
|
| 36 |
if st.button("Predict", type='primary'):
|
| 37 |
-
response = requests.post("https://
|
| 38 |
if response.status_code == 200:
|
| 39 |
result = response.json()
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
st.metric(f"Predicted Sales Revenue", f"₹{sales_prediction:.2f}")
|
| 43 |
else:
|
| 44 |
-
st.error(
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import pandas as pd
|
| 3 |
+
import requests
|
| 4 |
|
| 5 |
+
# Streamlit UI for Sales price Prediction
|
| 6 |
+
st.title("SuperKart Sales Prediction App")
|
| 7 |
+
st.write("This tool predicts sales price based on product details. Enter the required information below.")
|
| 8 |
|
| 9 |
+
# Collect user input based on dataset columns
|
| 10 |
+
ProductWeight = st.number_input("Product Weight", min_value=0.1, max_value=500.0)
|
| 11 |
+
ProductSugarContent = st.selectbox("Product Sugar Content", ["Low Sugar", "Regular", "No Sugar"])
|
| 12 |
+
ProductAllocatedArea = st.number_input("Product Allocated Area", min_value=0.01, max_value=500.0)
|
| 13 |
+
ProductType = st.selectbox("Product Type", ["Fruits and Vegetables","Snack Foods","Frozen Foods","Dairy","Household","Baking Goods","Canned","Health and Hygiene","Meat","Soft Drinks","Breads","Hard Drinks","Others","Starchy Foods","Breakfast","Seafood"])
|
| 14 |
+
ProductMRP = st.number_input("Product MRP", min_value=0.1, max_value=5000000.0)
|
| 15 |
+
StoreId = st.selectbox("Store Id", ["OUT001", "OUT002", "OUT003","OUT004"])
|
| 16 |
+
StoreEstablishmentYear = st.selectbox("Store Establishment Year", ["1987", "1998", "1999","2009"])
|
| 17 |
+
StoreSize = st.selectbox("Store Size", ["Small", "Medium", "High"])
|
| 18 |
+
StoreLocationCityType = st.selectbox("Store Location City Type", ["Tier 1", "Tier 2", "Tier 3"])
|
| 19 |
+
StoreType = st.selectbox("Store Type", ["Supermarket Type1", "Supermarket Type2", "Departmental Store", "Food Mart"])
|
| 20 |
|
| 21 |
+
# Convert categorical inputs to match model training
|
| 22 |
+
product_data = {'Product_Weight': ProductWeight,'Product_Sugar_Content': ProductSugarContent,'Product_Allocated_Area': ProductAllocatedArea,'Product_Type': ProductType,'Product_MRP':ProductMRP,'Store_Id': StoreId,'Store_Establishment_Year': StoreEstablishmentYear,'Store_Size': StoreSize,'Store_Location_City_Type': StoreLocationCityType,'Store_Type': StoreType}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
if st.button("Predict", type='primary'):
|
| 26 |
+
response = requests.post("https://rahulg1987-app-backend.hf.space/v1/totalsales", json=product_data)
|
| 27 |
if response.status_code == 200:
|
| 28 |
result = response.json()
|
| 29 |
+
prediction = result["predicted_sales"] # Extract only the value
|
| 30 |
+
st.write(f"Based on the product information provided, The sales price will be {prediction}.")
|
|
|
|
| 31 |
else:
|
| 32 |
+
st.error(response.status_code)
|