import requests import streamlit as st import pandas as pd st.title("Product Sales per store Prediction") # Batch Prediction st.subheader("Online Prediction") # Input fields for Store data ProductId = st.text_input("Product ID") CreditScore = st.number_input("Credit Score (customer's credit score)", min_value=300, max_value=900, value=650) ProductSugarContent = st.selectbox("Product Sugar Content (Sugar Content of product)", ['Low Sugar', 'Regular', 'No Sugar']) ProductType = 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', 'Others', 'Breakfast', 'Starchy Foods', 'Seafood']) StoreId = st.selectbox("Store Id", ['OUT004', 'OUT003', 'OUT001', 'OUT002']) StoreSize = st.selectbox("Store Size", ['Medium', 'High', 'Small']) StoreLocationCityType = st.selectbox("Store Location City Type", ['Tier 2', 'Tier 1', 'Tier 3']) StoreType = st.selectbox("Store Type", ['Supermarket Type2', 'Departmental Store', 'Supermarket Type1', 'Food Mart']) ProductWeight = st.number_input("Product Weight", min_value=1, max_value=30) ProductAllocatedArea = st.number_input("Product Allocated Area", min_value=0, max_value=0.5) ProductMRP = st.number_input("Product MRP",min_value=30, max_value=300) StoreEstablishmentYear = st.number_input("Store Establishment Year", min_value=1980, max_value=2010) customer_data = { 'ProductId': ProductId, 'CreditScore': CreditScore, 'ProductSugarContent': ProductSugarContent, 'ProductType': ProductType, 'StoreId': StoreId, 'StoreSize': StoreSize, 'StoreLocationCityType': StoreLocationCityType, 'StoreType': StoreType, 'ProductWeight': ProductWeight, 'ProductAllocatedArea': ProductAllocatedArea, 'ProductMRP': ProductMRP, 'StoreEstablishmentYear': StoreEstablishmentYear, } if st.button("Predict", type='primary'): response = requests.post("https://RahulSingh211-SuperkarPredictionBackend.hf.space/v1/invester", json=customer_data) if response.status_code == 200: result = response.json() prediction = result["Prediction"] st.write(f"Based on the information provided, sale forcast for product{ProductId} is likely to {prediction} dollars.") else: st.error("Error in API request") # Batch Prediction st.subheader("Batch Prediction") file = st.file_uploader("Upload CSV file", type=["csv"]) if file is not None: if st.button("Predict for Batch", type='primary'): response = requests.post("https://RahulSingh211-SuperkarPredictionBackend.hf.space/v1/investerbatch", files={"file": file}) if response.status_code == 200: result = response.json() st.header("Batch Prediction Results") st.write(result) else: st.error("Error in API request")