KoulVivek's picture
Upload folder using huggingface_hub
5521f0c verified
import streamlit as st
import pandas as pd
import requests
# Streamlit UI for Customer Churn Prediction
st.title("Super Kart Sales Prediction Application")
st.write("This tool predicts sales Enter the required information below.")
# Collect user input based on dataset columns
Product_Weight = st.number_input("Product Weight", min_value=0.0, value=10.0)
Product_Sugar_Content = st.selectbox("Product Sugar Content", ["Low Sugar", "Regular", "No Sugar", "reg"])
Product_Allocated_Area = st.number_input("Product Allocated Area", min_value=0.0, value=0.1)
Product_MRP = st.number_input("Product MRP", min_value=0.0, value=100.0)
Store_Size = st.selectbox("Store Size", ["Medium", "High", "Small"])
Store_Location_City_Type = st.selectbox("Store Location City Type", ["Tier 2", "Tier 1", "Tier 3"])
Store_Type = st.selectbox("Store Type", ["Supermarket Type2", "Departmental Store", "Supermarket Type1", "Food Mart"])
Pcategory = st.selectbox("Product Category", ["FD", "NC", "DR"])
Product_Type_category = st.selectbox("Product Type Category", ["Perishable", "Non-Perishable"])
# {'Product_Type_category', 'category', 'Product_Type', 'Store_Id', 'Store_Establishment_Year', 'Product_Id'}
product_info = {
"Product_Weight": Product_Weight,
"Product_Sugar_Content": str(Product_Sugar_Content),
"Product_Allocated_Area": Product_Allocated_Area,
"Product_MRP": Product_MRP,
"Store_Size": str(Store_Size),
"Store_Location_City_Type": str(Store_Location_City_Type),
"Store_Type": str(Store_Type),
'category': str(Pcategory),
'Product_Type_category': str(Product_Type_category)
# {'Store_Establishment_Year', 'Product_Id', 'Store_Id', 'Product_Type'}
}
if st.button("Predict", type='primary'):
response = requests.post("https://KoulVivek-GL-Retail-Sales-Prediction.hf.space/v1/sales", json=product_info) # enter user name and space name before running the cell
if response.status_code == 200:
result = response.json()
prediction = result["Sales"] # Extract only the value
st.write(f"Based on the information provided, the Product sales is {prediction}.")
else:
st.error("Error in API request")