superkart-api / fe_app.py
siaese's picture
Upload folder using huggingface_hub
9c10ab9 verified
# import streamlit as st
# import pandas as pd
# import requests
# # Streamlit UI for Customer Churn Prediction
# st.title("SuperKart Sales Prediction App")
# st.subheader("Online Sales Prediction")
# # Collect user input based on dataset columns
# Product_Id = st.number_input("Product ID", min_value=1, max_value=1000000, value=1)
# Product_Weight = st.number_input("Product Weight (kg)", min_value=0.1, max_value=100.0, value=1.0, format="%.2f")
# Product_Sugar_Content = st.selectbox("Product Sugar Content", ["Low", "Medium", "High"]) # Adjust options as per your dataset
# Product_Allocated_Area = st.number_input("Product Allocated Area (sq. units)", min_value=0.0, max_value=10000.0, value=100.0, format="%.2f")
# Product_Type = st.selectbox("Product Type", ["Type A", "Type B", "Type C"]) # Replace with actual product types
# Product_MRP = st.number_input("Product MRP", min_value=0.0, max_value=10000.0, value=100.0, format="%.2f")
# Store_Id = st.number_input("Store ID", min_value=1, max_value=1000000, value=1)
# Store_Establishment_Year = st.number_input("Store Establishment Year", min_value=1900, max_value=2025, value=2000)
# Store_Size = st.selectbox("Store Size", ["Small", "Medium", "Large"]) # Adjust options according to your data
# Store_Location_City_Type = st.selectbox("Store Location City Type", ["Tier 1", "Tier 2", "Tier 3"])
# Store_Type = st.selectbox("Store Type", ["Type 1", "Type 2", "Type 3"]) # Replace with actual store types
# # Product_Store_Sales_Total = st.number_input("Total Product Store Sales", min_value=0.0, value=0.0, format="%.2f")
# # Convert user input to dataframe
# input_data = {
# 'Product_Id': Product_Id,
# 'Product_Weight': Product_Weight,
# 'Product_Sugar_Content': Product_Sugar_Content,
# 'Product_Allocated_Area': Product_Allocated_Area,
# 'Product_Type': Product_Type,
# 'Product_MRP': Product_MRP,
# 'Store_Id': Store_Id,
# 'Store_Establishment_Year': Store_Establishment_Year,
# 'Store_Size': Store_Size,
# 'Store_Location_City_Type': Store_Location_City_Type,
# 'Store_Type': Store_Type
# }
# # Change as per requirement
# if st.button("Predict"):
# # response = requests.post("https://siaese/superkart-api/v1/sales", json=input_data.to_dict(orient='records')[0]) # enter user name and space name before running the cell
# response = requests.post("https://siaese/superkart-api/v1/sales", json=input_data) # enter user name and space name before running the cell
# if response.status_code == 200:
# prediction = response.json()['Predicted Sales for SuperKart']
# st.success(f'Predicted Sales: {prediction}')
# else:
# st.error("Error making sales prediction")
# # Sales Prediction
# st.subheader("Sales Prediction")
import streamlit as st
import pandas as pd
import requests
# Streamlit UI for Customer Churn Prediction
st.title("SuperKart Sales Prediction App")
st.subheader("Online Sales Prediction")
# Collect user input based on dataset columns
Product_Id = st.number_input("Product ID", min_value=1, max_value=1000000, value=1)
Product_Weight = st.number_input("Product Weight (kg)", min_value=0.1, max_value=100.0, value=1.0, format="%.2f")
Product_Sugar_Content = st.selectbox("Product Sugar Content", ["Low", "Medium", "High"]) # Adjust options as per your dataset
Product_Allocated_Area = st.number_input("Product Allocated Area (sq. units)", min_value=0.0, max_value=10000.0, value=100.0, format="%.2f")
Product_Type = st.selectbox("Product Type", ["Type A", "Type B", "Type C"]) # Replace with actual product types
Product_MRP = st.number_input("Product MRP", min_value=0.0, max_value=10000.0, value=100.0, format="%.2f")
Product_Category = st.selectbox("Product_Category", ["FD" "NC" "DR"])
Store_Id = st.number_input("Store ID", min_value=1, max_value=1000000, value=1)
Store_Establishment_Year = st.number_input("Store Establishment Year", min_value=1900, max_value=2025, value=2000)
Store_Tenure = st.number_input("Store_Tenure", min_value=16, max_value=50, value=32)
Store_Size = st.selectbox("Store Size", ["Small", "Medium", "Large"]) # Adjust options according to your data
Store_Location_City_Type = st.selectbox("Store Location City Type", ["Tier 1", "Tier 2", "Tier 3"])
Store_Type = st.selectbox("Store Type", ["Type 1", "Type 2", "Type 3"]) # Replace with actual store types
Perishability = st.selectbox("Perishability", ["Perishable", "Non-Perishable", "Unknown"]) # Replace with actual store types
# Product_Store_Sales_Total = st.number_input("Total Product Store Sales", min_value=0.0, value=0.0, format="%.2f")
# Convert user input to dataframe
input_data = {
"Product_Id": Product_Id,
"Product_Weight": Product_Weight,
"Product_Sugar_Content": Product_Sugar_Content,
"Product_Allocated_Area": Product_Allocated_Area,
"Product_Type": Product_Type,
"Product_MRP": Product_MRP,
"Product_Category": Product_Category,
"Store_Id": Store_Id,
"Store_Tenure": Store_Tenure,
"Store_Establishment_Year": Store_Establishment_Year,
"Store_Size": Store_Size,
"Store_Location_City_Type": Store_Location_City_Type,
"Store_Type": Store_Type,
"Perishability": Perishability
}
# Change as per requirement
if st.button("Predict"):
# response = requests.post("https://siaese/superkart-api/v1/sales", json=input_data.to_dict(orient="records")[0]) # enter user name and space name before running the cell
response = requests.post("https://siaese/superkart-api/v1/sales", json=input_data) # enter user name and space name before running the cell
if response.status_code == 200:
prediction = response.json()["predicted_sales_price"]
st.success(f"Predicted Sales: {prediction}")
else:
st.error("Error making sales prediction")
# Sales Prediction
st.subheader("Sales Prediction")