File size: 1,896 Bytes
815ebe7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50

import streamlit as st
import pandas as pd
import joblib
import numpy as np

# Load the trained model
@st.cache_resource
def load_model():
    return joblib.load("superkart_sales_prediction_model_v1_0.joblib")

model = load_model()

# Streamlit UI
st.title("SuperKart Sales Prediction App")
st.write("This tool predicts the sales for a product based on its features and store details.")

st.subheader("Enter the product and store details:")

# Numeric inputs
Product_Weight = st.number_input("Product Weight (in grams)", min_value=0.0, value=500.0)
Product_Allocated_Area = st.number_input("Allocated Area (sq ft)", min_value=0.0, value=100.0)
Product_MRP = st.number_input("Product MRP", min_value=0.0, value=50.0)
Store_Establishment_Year = st.number_input("Store Establishment Year", min_value=1900, max_value=2025, value=2000)

# Categorical inputs
Product_Sugar_Content = st.selectbox("Product Sugar Content", ["Low", "Medium", "High"])
Product_Type = st.selectbox("Product Type", ["Food", "Beverage", "Snack", "Other"])
Store_Size = st.selectbox("Store Size", ["Small", "Medium", "Large"])
Store_Location_City_Type = st.selectbox("City Type", ["Tier 1", "Tier 2", "Tier 3"])
Store_Type = st.selectbox("Store Type", ["Mall", "Standalone", "Supermarket", "Other"])

# Convert user input into a DataFrame
input_data = pd.DataFrame([{
    'Product_Weight': Product_Weight,
    'Product_Allocated_Area': Product_Allocated_Area,
    'Product_MRP': Product_MRP,
    'Store_Establishment_Year': Store_Establishment_Year,
    'Product_Sugar_Content': Product_Sugar_Content,
    'Product_Type': Product_Type,
    'Store_Size': Store_Size,
    'Store_Location_City_Type': Store_Location_City_Type,
    'Store_Type': Store_Type
}])

# Predict button
if st.button("Predict"):
    prediction = model.predict(input_data)
    st.write(f"The predicted sales for the product is {prediction[0]:.2f} units.")