File size: 2,430 Bytes
0377433
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5e1615b
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
51
52
53

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("store_total_sales_prediction_model_v1_0.joblib")

model = load_model()

# Streamlit UI for Price Prediction
st.title("Store Total Sales Prediction App")
st.write("This tool predicts the total sales of a store based on the given store and its product details.")

st.subheader("Enter the listing details:")

# Collect user input for property features
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"])

# Convert user input into a DataFrame
input_data = pd.DataFrame([{
    '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
}])


# Predict button
if st.button("Predict"):
    prediction = model.predict(input_data)
    st.write(f"The predicted total sales of the store is: {prediction}")