pratikshadhumal12's picture
Upload folder using huggingface_hub
2adcce8 verified
Raw
History Blame Contribute Delete
2.12 kB
import streamlit as st
import pandas as pd
import requests
# Streamlit UI for Price Prediction
st.title("SuperKart Sales Prediction App")
st.write("This tool predicts the sales of an Superkart based on the product & store details.")
st.subheader("Enter the product & store details:")
# Collect user input
Product_Weight = st.number_input("Product Weight (Weight of product)", min_value=0.0, value=10.05)
Product_Sugar_Content = st.selectbox("Product Sugar Content", ["Low", "Medium", "High"])
Product_Allocated_Area = st.number_input("Product_Allocated_Area", min_value=0.0, value=11.02)
Product_MRP = st.number_input("Product MRP", min_value=0.0, value=100.0)
Store_Size = st.selectbox("Store Size", ["Small", "Medium", "Large"])
Store_Location_City_Type = st.selectbox("Store Location City Type", ["Tier 1", "Tier 2", "Tier 3"])
Store_Type = st.selectbox("Store_Type",["Supermarket Type1", "Supermarket Type2", "Departmental Store", "Food Mart"])
Store_Age = st.number_input("Store Age", min_value=0, value=10)
Product_Category = st.selectbox("Product Category", ["FD", "NC", "DR"])
Product_Category_Type = st.selectbox("Product Category Type", ["Perishables", "Non-Perishables"])
# Convert user input into a DataFrame
input_data = pd.DataFrame([{
'Product_Weight': Product_Weight,
'Product_Sugar_Content': Product_Sugar_Content,
'Product_Allocated_Area': Product_Allocated_Area,
'Product_MRP': Product_MRP,
'Store_Size': Store_Size,
'Store_Location_City_Type': Store_Location_City_Type,
'Store_Type': Store_Type,
'Store_Age': Store_Age,
'Product_Category': Product_Category,
'Product_Category_Type': Product_Category_Type
}])
# Make prediction when the "Predict" button is clicked
if st.button("Predict"):
response = requests.post("https://pratikshadhumal12-SuperkartSalePredictionBackendhf.space/v1/superkart", json=input_data.to_dict(orient='records')[0]) # Send data to Flask API
if response.status_code == 200:
prediction = response.json()['Sales']
st.success(f"Sales: {prediction}")
else:
st.error("Error making prediction.")