| import requests |
| import streamlit as st |
| import pandas as pd |
|
|
| st.title("SuperKart Product Revenue Prediction") |
|
|
| |
| st.subheader("Online Prediction") |
|
|
| |
| Product_Weight = st.number_input("Product's Weight (weight of the product)", value=0.0, format="%.2f", min_value=0.0, max_value=50.0) |
| Product_Allocated_Area = st.number_input("Product's Allocated Area (Ratio of the allocated display area of the product to the total display area of the store in which the product is being sold)", value=0.0, format="%.3f", min_value=0.0, max_value=1.0) |
| Product_MRP = st.number_input("Product's MRP (in rupees)", value=0.0, format="%.2f", min_value=0.0, max_value=300.0) |
|
|
| Product_Id = st.text_input("Product ID (This must have two letters at the beginning, followed by a number)") |
| |
| Product_Id_Code = str(Product_Id)[:2] |
| Product_Sugar_Content = st.selectbox("Product's Sugar Content (Sugar content of the product)", ["Low Sugar", "Regular", "No Sugar"]) |
| Store_Id = st.selectbox("Store ID (Unique identifier of the store)", ["OUT001", "OUT002", "OUT003", "OUT004"]) |
| Store_Establishment_Year = st.selectbox("Year in which the store was established", ["1987", "1998", "1999", "2009"]) |
| Store_Size = st.selectbox("Size of the store", ["Small", "Medium", "High"]) |
| Store_Location_City_Type = st.selectbox("Type of the city in which the store is located", ["Tier 1", "Tier 2", "Tier 3"]) |
| Store_Type = st.selectbox("Type of store the product is being sold", ["Food Mart", "Departmental Store", "Supermarket Type1", "Supermarket Type2"]) |
|
|
| |
| allowed_codes = {"FD", "NC", "DR"} |
|
|
| if Product_Id_Code in allowed_codes: |
| print("Valid Product ID Code") |
| else: |
| print("Invalid Product ID Code : The first two characters of Product ID must be either of three strings - 'FD','NC','DR'") |
|
|
| product_data = { |
| 'Product_Weight': Product_Weight, |
| 'Product_Allocated_Area': Product_Allocated_Area, |
| 'Product_MRP': Product_MRP, |
| 'Product_Sugar_Content': Product_Sugar_Content, |
| '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, |
| 'Product_Id_Code': Product_Id_Code |
| } |
|
|
| if st.button("Predict", type='primary'): |
| response = requests.post("https://mvnmanojhirwani-StoreRevenuePredictionBackend.hf.space/v1/product", json=product_data) |
| if response.status_code == 200: |
| result = response.json() |
| revenue_prediction = result["Predicted revenue (in rupees)"] |
| st.write(f"Based on the information provided, the product with ID {Product_Id} is likely to generate a revenue of {revenue_prediction} rupees in {Store_Id} store.") |
| else: |
| st.error("Error in API request") |
|
|
| |
| 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://mvnmanojhirwani-StoreRevenuePredictionBackend.hf.space/v1/productBatch", 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") |
|
|