File size: 9,492 Bytes
b15f80a |
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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 |
# import streamlit as st
# import pandas as pd
# import numpy as np
# from sklearn.preprocessing import LabelEncoder
# import joblib
# # Load your trained model
# model = joblib.load('models\model1.pkl')
# # Function to predict sales
# def predict_sales(input_data):
# sales_prediction = model.predict(input_data)
# return sales_prediction
# # Streamlit app
# def main():
# st.title('Sales Prediction App')
# # Input widgets
# PromoInterval = st.selectbox("Promo Interval", ['No Promotion', 'Jan,Apr,Jul,Oct', 'Feb,May,Aug,Nov', 'Mar,Jun,Sept,Dec'])
# StoreType = st.radio("StoreType", ["a", "b", "c", "d"])
# Assortment = st.radio("Assortment", ["a", "b", "c"])
# StateHoliday = st.radio("State Holiday", ["1", "0"])
# SchoolHoliday = st.radio("School Holiday", ["1", "0"])
# Promo = st.radio("Promo", ["1", "0"])
# Store = st.slider("Store", 1, 1115)
# Customers = st.slider("Customers", 0, 7388)
# CompetitionDistance = st.slider("Competition Distance", 20, 75860)
# CompetitionOpenSinceMonth = st.slider("Competition Open Since Month", 1, 12)
# CompetitionOpenSinceYear = st.slider("Competition Open Since Year", 1998, 2015)
# # PromoInterval StoreType Assortment StateHoliday Store Customers Promo SchoolHoliday CompetitionDistance CompetitionOpenSinceMonth CompetitionOpenSinceYear
# # Store user inputs
# input_data = pd.DataFrame({
# 'PromoInterval': [PromoInterval],
# 'StoreType': [StoreType],
# 'Assortment': [Assortment],
# 'StateHoliday': [StateHoliday],
# 'Store': [Store],
# 'Customers': [Customers],
# 'Promo': [Promo],
# 'SchoolHoliday': [SchoolHoliday],
# 'CompetitionDistance': [CompetitionDistance],
# 'CompetitionOpenSinceMonth': [CompetitionOpenSinceMonth],
# 'CompetitionOpenSinceYear': [CompetitionOpenSinceYear]
# })
# # Display input data
# st.subheader('Input Data:')
# st.write(input_data)
# # Predict sales
# if st.button('Predict Sales'):
# prediction = predict_sales(input_data)
# st.write('Predicted Sales:', prediction)
# if __name__ == '__main__':
# main()
# import streamlit as st
# import pandas as pd
# import numpy as np
# from sklearn.preprocessing import LabelEncoder
# import joblib
# # Load your trained model
# model = joblib.load('models\model1.pkl')
# # Function to predict sales
# def predict_sales(input_data):
# sales_prediction = model.predict(input_data)
# return sales_prediction
# # Function for data analysis
# def perform_analysis(data):
# # Add your analysis code here
# st.subheader("Analysis")
# st.write("Performing analysis...")
# # Function for data overview
# def show_data_overview():
# # Load data from CSV file
# data = pd.read_csv('Dataset/rossmann.csv')
# # Display data overview
# st.subheader("Data Overview")
# st.write(data)
# # Streamlit app
# def main():
# st.title('Sales Prediction App')
# # Sidebar options
# sidebar_option = st.sidebar.radio("Navigation", ["Main", "Analysis", "Data Overview"])
# if sidebar_option == "Main":
# # Input widgets
# PromoInterval = st.selectbox("Promo Interval", ['No Promotion', 'Jan,Apr,Jul,Oct', 'Feb,May,Aug,Nov', 'Mar,Jun,Sept,Dec'])
# StoreType = st.radio("StoreType", ["a", "b", "c", "d"])
# Assortment = st.radio("Assortment", ["a", "b", "c"])
# # StateHoliday = st.radio("State Holiday", ["1", "0"])
# # -------------------------------------------------------------------------------
# # Define the options and their corresponding labels
# options = ["1", "0"]
# labels = ["Yes", "No"]
# # Create the radio button with labels
# StateHoliday = st.radio("State Holiday", labels)
# # Convert the selected label back to its corresponding option value
# # selected_option = options[labels.index(state_holiday)]
# # -------------------------------------------------------------------------------
# SchoolHoliday = st.radio("School Holiday", ["1", "0"])
# Promo = st.radio("promotion", ["1", "0"])
# Store = st.slider("Store", 1, 1115)
# Customers = st.slider("Customers", 0, 7388)
# CompetitionDistance = st.slider("Competition Distance", 20, 75860)
# CompetitionOpenSinceMonth = st.slider("Competition Open Since Month", 1, 12)
# CompetitionOpenSinceYear = st.slider("Competition Open Since Year", 1998, 2015)
# # Store user inputs
# input_data = pd.DataFrame({
# 'PromoInterval': [PromoInterval],
# 'StoreType': [StoreType],
# 'Assortment': [Assortment],
# 'StateHoliday': [StateHoliday],
# 'Store': [Store],
# 'Customers': [Customers],
# 'Promo': [Promo],
# 'SchoolHoliday': [SchoolHoliday],
# 'CompetitionDistance': [CompetitionDistance],
# 'CompetitionOpenSinceMonth': [CompetitionOpenSinceMonth],
# 'CompetitionOpenSinceYear': [CompetitionOpenSinceYear]
# })
# # Display input data
# st.subheader('Input Data:')
# st.write(input_data)
# # Predict sales
# if st.button('Predict Sales'):
# prediction = predict_sales(input_data)
# st.write('Predicted Sales:', prediction)
# elif sidebar_option == "Analysis":
# perform_analysis(None) # Pass data for analysis if needed
# elif sidebar_option == "Data Overview":
# show_data_overview() # Pass data for overview if needed
# if __name__ == '__main__':
# main()
import streamlit as st
import pandas as pd
import joblib
# Load your trained model
model = joblib.load('models\model2.pkl')
# Function to predict sales
def predict_sales(input_data):
# Make predictions using the loaded model
sales_prediction = model.predict(input_data)
return sales_prediction
# Streamlit app
def main():
st.title('Sales Prediction App')
# Input widgets
PromoInterval = st.selectbox("Promo Interval", ['No Promotion', 'Jan,Apr,Jul,Oct', 'Feb,May,Aug,Nov', 'Mar,Jun,Sept,Dec'])
# -----------------------------------------------------------------------------------------------
StoreType = st.radio("StoreType", ["Small Shop", "Medium Store", "Large Store", "Hypermarket"])
Assortment = st.radio("Assortment", ["basic", "extra", "extended"])
# Encode StateHoliday as 1 for 'Yes' and 0 for 'No' --------------------------------------
StateHoliday = st.radio("State Holiday", ["Yes", "No"])
StateHoliday = 1 if StateHoliday == "Yes" else 0
SchoolHoliday = st.radio("School Holiday", ["Yes", "No"])
SchoolHoliday = 1 if SchoolHoliday == "Yes" else 0
Promo = st.radio("Promotion", ["store is participating", "store is not participating"])
Promo = 1 if Promo == "store is participating" else 0
# ----------------------------------------------------------------------------------------
Store = st.slider("Store", 1, 1115)
Customers = st.slider("Customers", 0, 7388)
CompetitionDistance = st.slider("Competition Distance", 20, 75860)
CompetitionOpenSinceMonth = st.slider("Competition Open Since Month", 1, 12)
CompetitionOpenSinceYear = st.slider("Competition Open Since Year", 1998, 2015)
# ----------------------------------------------------------------------------------------
# Store user inputs
input_data = pd.DataFrame({
'PromoInterval': [PromoInterval],
'StoreType': [StoreType],
'Assortment': [Assortment],
'StateHoliday': [StateHoliday],
'Store': [Store],
'Customers': [Customers],
'Promo': [Promo],
'SchoolHoliday': [SchoolHoliday],
'CompetitionDistance': [CompetitionDistance],
'CompetitionOpenSinceMonth': [CompetitionOpenSinceMonth],
'CompetitionOpenSinceYear': [CompetitionOpenSinceYear]
})
# Display input data
st.subheader('Input Data:')
st.write(input_data)
# Predict sales
# if st.button('Predict Sales'):
# prediction = predict_sales(input_data)
# st.write('Predicted Sales:', prediction)
if st.button('Predict Sales'):
prediction = predict_sales(input_data)[0]
formatted_prediction = "{:.2f}".format(prediction) # Format prediction to display two decimal points
st.write('Predicted Sales:', formatted_prediction)
if __name__ == '__main__':
main()
# Record at index 795018:
# PromoInterval Jan,Apr,Jul,Oct
# StoreType Small Shop
# Assortment basic
# StateHoliday 0
# Store 650
# Customers 636
# Promo 1
# SchoolHoliday 0
# CompetitionDistance 1420
# CompetitionOpenSinceMonth 10
# CompetitionOpenSinceYear 2012
# Sales 6322
# Name: 795018, dtype: object |