Upload 11 files
Browse files- app.py +94 -0
- models/Rossmann_Model.pkl +3 -0
- models/model1.pkl +3 -0
- models/model2.pkl +3 -0
- pages/Data Overview.py +16 -0
app.py
ADDED
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
import streamlit as st
|
3 |
+
import pandas as pd
|
4 |
+
import joblib
|
5 |
+
|
6 |
+
# Load your trained model
|
7 |
+
model = joblib.load('models\model2.pkl')
|
8 |
+
|
9 |
+
# Function to predict sales
|
10 |
+
def predict_sales(input_data):
|
11 |
+
# Make predictions using the loaded model
|
12 |
+
sales_prediction = model.predict(input_data)
|
13 |
+
return sales_prediction
|
14 |
+
|
15 |
+
# Streamlit app
|
16 |
+
def main():
|
17 |
+
st.title('Sales Prediction App')
|
18 |
+
|
19 |
+
# Input widgets
|
20 |
+
PromoInterval = st.selectbox("Promo Interval", ['No Promotion', 'Jan,Apr,Jul,Oct', 'Feb,May,Aug,Nov', 'Mar,Jun,Sept,Dec'])
|
21 |
+
|
22 |
+
# -----------------------------------------------------------------------------------------------
|
23 |
+
StoreType = st.radio("StoreType", ["Small Shop", "Medium Store", "Large Store", "Hypermarket"])
|
24 |
+
Assortment = st.radio("Assortment", ["basic", "extra", "extended"])
|
25 |
+
|
26 |
+
|
27 |
+
# Encode StateHoliday as 1 for 'Yes' and 0 for 'No' --------------------------------------
|
28 |
+
StateHoliday = st.radio("State Holiday", ["Yes", "No"])
|
29 |
+
StateHoliday = 1 if StateHoliday == "Yes" else 0
|
30 |
+
|
31 |
+
SchoolHoliday = st.radio("School Holiday", ["Yes", "No"])
|
32 |
+
SchoolHoliday = 1 if SchoolHoliday == "Yes" else 0
|
33 |
+
|
34 |
+
Promo = st.radio("Promotion", ["store is participating", "store is not participating"])
|
35 |
+
Promo = 1 if Promo == "store is participating" else 0
|
36 |
+
# ----------------------------------------------------------------------------------------
|
37 |
+
|
38 |
+
|
39 |
+
Store = st.slider("Store", 1, 1115)
|
40 |
+
Customers = st.slider("Customers", 0, 7388)
|
41 |
+
CompetitionDistance = st.slider("Competition Distance", 20, 75860)
|
42 |
+
CompetitionOpenSinceMonth = st.slider("Competition Open Since Month", 1, 12)
|
43 |
+
CompetitionOpenSinceYear = st.slider("Competition Open Since Year", 1998, 2015)
|
44 |
+
# ----------------------------------------------------------------------------------------
|
45 |
+
|
46 |
+
# Store user inputs
|
47 |
+
input_data = pd.DataFrame({
|
48 |
+
'PromoInterval': [PromoInterval],
|
49 |
+
'StoreType': [StoreType],
|
50 |
+
'Assortment': [Assortment],
|
51 |
+
'StateHoliday': [StateHoliday],
|
52 |
+
'Store': [Store],
|
53 |
+
'Customers': [Customers],
|
54 |
+
'Promo': [Promo],
|
55 |
+
'SchoolHoliday': [SchoolHoliday],
|
56 |
+
'CompetitionDistance': [CompetitionDistance],
|
57 |
+
'CompetitionOpenSinceMonth': [CompetitionOpenSinceMonth],
|
58 |
+
'CompetitionOpenSinceYear': [CompetitionOpenSinceYear]
|
59 |
+
})
|
60 |
+
|
61 |
+
# Display input data
|
62 |
+
st.subheader('Input Data:')
|
63 |
+
st.write(input_data)
|
64 |
+
|
65 |
+
# Predict sales
|
66 |
+
# if st.button('Predict Sales'):
|
67 |
+
# prediction = predict_sales(input_data)
|
68 |
+
# st.write('Predicted Sales:', prediction)
|
69 |
+
|
70 |
+
if st.button('Predict Sales'):
|
71 |
+
prediction = predict_sales(input_data)[0]
|
72 |
+
formatted_prediction = "{:.2f}".format(prediction) # Format prediction to display two decimal points
|
73 |
+
st.write('Predicted Sales:', formatted_prediction)
|
74 |
+
|
75 |
+
|
76 |
+
if __name__ == '__main__':
|
77 |
+
main()
|
78 |
+
|
79 |
+
|
80 |
+
|
81 |
+
# Record at index 795018:
|
82 |
+
# PromoInterval Jan,Apr,Jul,Oct
|
83 |
+
# StoreType Small Shop
|
84 |
+
# Assortment basic
|
85 |
+
# StateHoliday 0
|
86 |
+
# Store 650
|
87 |
+
# Customers 636
|
88 |
+
# Promo 1
|
89 |
+
# SchoolHoliday 0
|
90 |
+
# CompetitionDistance 1420
|
91 |
+
# CompetitionOpenSinceMonth 10
|
92 |
+
# CompetitionOpenSinceYear 2012
|
93 |
+
# Sales 6322
|
94 |
+
# Name: 795018, dtype: object
|
models/Rossmann_Model.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:2a4264097df040b74694426b0b55cd70008790bec56cdeefa4eb7de0144096d1
|
3 |
+
size 22628002
|
models/model1.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:f44f412a489f3fe693806f91c0b379f6fa5ba685d29f905dacaf223449ac6279
|
3 |
+
size 22632250
|
models/model2.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:60fb4f99c82338b7cb8917fe1b0734c96c98df89ae01f9fb9617cd94ab967005
|
3 |
+
size 24157012
|
pages/Data Overview.py
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import pandas as pd
|
3 |
+
|
4 |
+
# st.title("hi")
|
5 |
+
|
6 |
+
# Function for data overview
|
7 |
+
def show_data_overview():
|
8 |
+
# Load data from CSV file
|
9 |
+
data = pd.read_csv("Dataset\Rossmann_Cleaned_data.csv")
|
10 |
+
|
11 |
+
# Display data overview
|
12 |
+
st.subheader("Data Overview")
|
13 |
+
st.write(data)
|
14 |
+
|
15 |
+
|
16 |
+
show_data_overview() # Call the function to show data overview
|