|
|
| import streamlit as st |
| import pandas as pd |
| import joblib |
| import numpy as np |
| import requests |
|
|
| |
| |
| |
| |
|
|
| |
|
|
| |
| st.title("Product Sales Prediction App") |
| st.write("This tool predicts the price of an products listing based on the given details.") |
|
|
| st.subheader("Enter the listing details:") |
|
|
| |
| Product_Sugar_Content = st.selectbox("Sugar Content", ["Regular", "Low Sugar", "No Sugar"]) |
| Product_Weight = st.number_input("Product Weights (grams)", min_value=0.0, max_value=30.0, format="%.2f", value=15.0, step=0.01) |
| Product_Allocated_Area = st.number_input("Product Allocated Area (Sq.Ft)", min_value=0.0, max_value=0.3, step=0.01, value=0.20, format="%.2f") |
| Product_MRP = st.number_input("Product Price ($) ", min_value=0.0, max_value=300.0, step=1.0, value=100.0, format="%.2f") |
| Store_Size = st.selectbox("Store Size", ["High", "Medium", "Small"]) |
| 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", "Food Mart", "Departmental Store"]) |
| Product_Id_Code = st.selectbox("Product ID Code ", ["FD", "DR", "NC"]) |
| Product_Type_Category = st.selectbox("Product Type Category ", ["Non Perishables", "Perishables"]) |
| Store_Age_Years = st.number_input("Age of the store ? ", min_value=0, max_value=50, value=15, step=1) |
|
|
| |
| input_data = pd.DataFrame([{ |
| 'Product_Sugar_Content': Product_Sugar_Content, |
| 'Product_Weight': Product_Weight, |
| '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, |
| 'Product_Id_Code': Product_Id_Code, |
| 'Product_Type_Category': Product_Type_Category, |
| 'Store_Age_Years': Store_Age_Years |
| }]) |
|
|
| |
| if st.button("Predict"): |
| response = requests.post("https://R-autowired-ProductSalesPredictionBackend.hf.space/v1/salespredict", json=input_data.to_dict(orient='records')[0]) |
| if response.status_code == 200: |
| prediction = response.json()['Sales'] |
| st.success(f"Sales: {prediction}") |
| else: |
| st.error("Error making prediction.") |
|
|