|
|
import streamlit as st |
|
|
import pandas as pd |
|
|
import requests |
|
|
|
|
|
|
|
|
st.title("Store Total Sales Prediction") |
|
|
|
|
|
|
|
|
st.subheader("Online Prediction") |
|
|
|
|
|
|
|
|
product_weight = st.number_input("Product Weight", min_value=4.0, max_value=22.0, step=0.1, value=5.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.004, max_value=0.298000, step=0.1, value=0.01) |
|
|
product_type = st.selectbox("Product Type", ["Frozen Foods", "Dairy", "Canned", "Baking Goods", "Health and Hygiene", |
|
|
"Snack Foods", "Meat", "Household", "Hard Drinks", "Fruits and Vegetables", |
|
|
"Breads", "Soft Drinks", "Breakfast", "Others", "Starchy Foods", "Seafood"]) |
|
|
product_mrp = st.number_input("Product MRP", min_value=31.0, max_value=266.0, step=5.0, value=50.0) |
|
|
store_id = st.selectbox("Store Id ", ["OUT001", "OUT002", "OUT003", "OUT004"]) |
|
|
store_establishment_year = st.selectbox("Store Establishment Year ", ["1987", "1998", "1999", "2009"]) |
|
|
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 ", ["Supermarket Type1", "Supermarket Type2", "Departmental Store", "Food Mart"]) |
|
|
|
|
|
|
|
|
|
|
|
input_data = { |
|
|
'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 |
|
|
} |
|
|
|
|
|
|
|
|
if st.button("Predict"): |
|
|
response = requests.post("https://karora1804-StoreTotalSalesPredictionBackend.hf.space/v1/storeSales", json=input_data) |
|
|
if response.status_code == 200: |
|
|
prediction = response.json()['Predicted_Store_Total_Sales'] |
|
|
st.success(f"Predicted Store Total Sales: {prediction}") |
|
|
else: |
|
|
st.error("Error making prediction.") |
|
|
st.write(response.status_code) |
|
|
st.write(response.text) |
|
|
|
|
|
|
|
|
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"): |
|
|
response = requests.post("https://karora1804-StoreTotalSalesPredictionBackend.hf.space/v1/storeSalesbatch", 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.") |
|
|
|