| import streamlit as st |
| import pandas as pd |
| import requests |
|
|
| |
| st.title("SuperKart Product sales Prediction") |
|
|
| |
| st.subheader("Online Prediction") |
|
|
| |
| product_type = st.selectbox("Product Type",["Frozen Foods","Dairy","Canned","Baking Goods","Snack Foods","Meat","Fruits and Vegetables","Breads","Breakfast","Starchy Foods","Seafood"]) |
| product_sugar_content = st.selectbox("Product Sugar Content", ["Low Sugar","Regular","No Sugar"]) |
|
|
| |
| |
| |
| |
| product_mrp = st.number_input("MRP (in $)", min_value=31.0, max_value=267.0, step=1.0, value=147.0) |
| product_weight = st.number_input("Product Weight (in Ounce)", min_value=4.0, max_value=22.0, step=0.2, value=12.0) |
| product_allocated_area=st.number_input("Product Allocated area in %", min_value=0.4, max_value=30.0, step=0.1, value=0.7) |
|
|
| store_size = st.selectbox("Store Size", ["Small","Medium","High"]) |
| store_location_city_type = st.selectbox("Store Location City Type", ["Tier 1","Tier 2","Tier 3"]) |
| store_type=st.selectbox("Store Type", ["Food Mart","Supermarket Type1","Supermarket Type2","Departmental Store"]) |
|
|
| |
| input_data = pd.DataFrame([{ |
| 'Product_MRP': product_mrp, |
| 'Product_Type': product_type, |
| 'Product_Sugar_Content': product_sugar_content, |
| 'Product_Weight': product_weight, |
| 'Product_Allocated_Area': product_allocated_area/100, |
| 'Store_Size': store_size, |
| 'Store_Location_City_Type': store_location_city_type, |
| 'Store_Type': store_type |
| }]) |
|
|
| |
| if st.button("Predict"): |
| response = requests.post("https://deepacsr-ProductPricePredictionBackend.hf.space/v1/ProductSale", json=input_data.to_dict(orient='records')[0]) |
| if response.status_code == 200: |
| prediction = response.json() |
| st.success("Product sales predictions completed!") |
| st.success(f"Predicted Sales Price (in dollars): {prediction}") |
| else: |
| st.error("Error making prediction.") |
| st.error(f"Error code: {response.status_code}") |
|
|
| |
| st.subheader("Batch Prediction") |
|
|
| |
| uploaded_file = st.file_uploader("Upload CSV file for batch prediction", type=["csv"]) |
|
|
| |
| if uploaded_file is not None: |
| if st.button("Predict Batch"): |
| st.write(uploaded_file.name) |
| st.write(uploaded_file.getvalue()) |
| response = requests.post("https://deepacsr-ProductPricePredictionBackend.hf.space//v1/batchsales",files={"file": uploaded_file}) |
| if response.status_code == 200: |
| predictions = response.json() |
| st.success("Batch predictions completed!") |
| st.write(predictions) |
| else: |
| st.error("Error making batch prediction.") |
| st.error(f"Error code: {response.status_code}") |
| st.error(response.text) |
|
|