Spaces:
Build error
Build error
Updated file location
Browse files- sales.png +0 -0
- src/app.py +11 -11
- utils.py +29 -0
sales.png
ADDED
|
src/app.py
CHANGED
|
@@ -4,10 +4,10 @@ import pandas as pd
|
|
| 4 |
import numpy as np
|
| 5 |
import pickle
|
| 6 |
import datetime
|
| 7 |
-
import os
|
| 8 |
-
import sys
|
| 9 |
# from utils import payday, date_extracts
|
| 10 |
-
sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
|
| 11 |
|
| 12 |
from utils import payday, date_extracts
|
| 13 |
|
|
@@ -23,11 +23,11 @@ st.set_page_config(
|
|
| 23 |
}
|
| 24 |
)
|
| 25 |
|
| 26 |
-
# Define directory paths
|
| 27 |
-
DIRPATH = os.path.dirname(os.path.realpath(__file__))
|
| 28 |
-
ml_components_1 = os.path.join(DIRPATH, "..", "src", "assets", "ml_components", "ml_components_1.pkl")
|
| 29 |
-
ml_components_2 = os.path.join(DIRPATH, "..", "src", "assets", "ml_components", "ml_components_2.pkl")
|
| 30 |
-
image_path = os.path.join(DIRPATH, "..", "src", "assets", "images", "sales.png")
|
| 31 |
|
| 32 |
|
| 33 |
# create a functions to load pickle file.
|
|
@@ -38,8 +38,8 @@ def load_pickle(filename):
|
|
| 38 |
|
| 39 |
|
| 40 |
#load all pickle files
|
| 41 |
-
ml_compos_1 = load_pickle(ml_components_1)
|
| 42 |
-
ml_compos_2 = load_pickle(ml_components_2)
|
| 43 |
|
| 44 |
# components in ml_compos_2
|
| 45 |
categorical_pipeline = ml_compos_2['categorical_pipeline']
|
|
@@ -54,7 +54,7 @@ cat_cols = ml_compos_1['cat_cols']
|
|
| 54 |
st.title('✨SALES FORECASTING APP✨')
|
| 55 |
|
| 56 |
# adding image
|
| 57 |
-
image=Image.open(
|
| 58 |
st.image(image, width=600)
|
| 59 |
|
| 60 |
|
|
|
|
| 4 |
import numpy as np
|
| 5 |
import pickle
|
| 6 |
import datetime
|
| 7 |
+
# import os
|
| 8 |
+
# import sys
|
| 9 |
# from utils import payday, date_extracts
|
| 10 |
+
# sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
|
| 11 |
|
| 12 |
from utils import payday, date_extracts
|
| 13 |
|
|
|
|
| 23 |
}
|
| 24 |
)
|
| 25 |
|
| 26 |
+
# # Define directory paths
|
| 27 |
+
# DIRPATH = os.path.dirname(os.path.realpath(__file__))
|
| 28 |
+
# ml_components_1 = os.path.join(DIRPATH, "..", "src", "assets", "ml_components", "ml_components_1.pkl")
|
| 29 |
+
# ml_components_2 = os.path.join(DIRPATH, "..", "src", "assets", "ml_components", "ml_components_2.pkl")
|
| 30 |
+
# image_path = os.path.join(DIRPATH, "..", "src", "assets", "images", "sales.png")
|
| 31 |
|
| 32 |
|
| 33 |
# create a functions to load pickle file.
|
|
|
|
| 38 |
|
| 39 |
|
| 40 |
#load all pickle files
|
| 41 |
+
ml_compos_1 = load_pickle('ml_components_1.pkl')
|
| 42 |
+
ml_compos_2 = load_pickle('ml_components_2.pkl')
|
| 43 |
|
| 44 |
# components in ml_compos_2
|
| 45 |
categorical_pipeline = ml_compos_2['categorical_pipeline']
|
|
|
|
| 54 |
st.title('✨SALES FORECASTING APP✨')
|
| 55 |
|
| 56 |
# adding image
|
| 57 |
+
image=Image.open('sales.png')
|
| 58 |
st.image(image, width=600)
|
| 59 |
|
| 60 |
|
utils.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import numpy as np
|
| 2 |
+
import pickle
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
def payday(row):
|
| 8 |
+
if row.DayOfMonth == 15 or row.Is_month_end == 1:
|
| 9 |
+
return 1
|
| 10 |
+
else:
|
| 11 |
+
return 0
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
def date_extracts(data):
|
| 15 |
+
data['Year'] = data.index.year
|
| 16 |
+
data['Month'] = data.index.month
|
| 17 |
+
data['DayOfMonth'] = data.index.day
|
| 18 |
+
data['DaysInMonth'] = data.index.days_in_month
|
| 19 |
+
data['DayOfYear'] = data.index.day_of_year
|
| 20 |
+
data['DayOfWeek'] = data.index.dayofweek
|
| 21 |
+
data['Week'] = data.index.isocalendar().week
|
| 22 |
+
data['Is_weekend'] = np.where(data['DayOfWeek'] > 4, 1, 0)
|
| 23 |
+
data['Is_month_start'] = data.index.is_month_start.astype(int)
|
| 24 |
+
data['Is_month_end'] = data.index.is_month_end.astype(int)
|
| 25 |
+
data['Quarter'] = data.index.quarter
|
| 26 |
+
data['Is_quarter_start'] = data.index.is_quarter_start.astype(int)
|
| 27 |
+
data['Is_quarter_end'] = data.index.is_quarter_end.astype(int)
|
| 28 |
+
data['Is_year_start'] = data.index.is_year_start.astype(int)
|
| 29 |
+
data['Is_year_end'] = data.index.is_year_end.astype(int)
|