-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path4_decomposition.py
More file actions
34 lines (24 loc) · 898 Bytes
/
4_decomposition.py
File metadata and controls
34 lines (24 loc) · 898 Bytes
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
import orbit
import pandas as pd
import matplotlib.pyplot as plt
from orbit.diagnostics.plot import plot_predicted_data,plot_predicted_components
from model import runTheModel, getModelDict, trainTestestSplit
import pathlib
import os
## Instantiate Variables
dirPath = str(pathlib.Path().resolve())
dataPath = dirPath + "/data/"
rankPath = dataPath + 'ranking.csv'
processedDataPath = dataPath + 'procssed_data.csv'
imgPath = dirPath + "/img/"
date_col = 'date'
response_col = 'sales'
df = pd.read_csv(processedDataPath)
train, test = trainTestestSplit(df)
rankData = pd.read_csv(rankPath)
bestModel = rankData[rankData.Rank==1].Model[0]
modelDict = getModelDict(train)
if not os.path.exists(imgPath):
os.mkdir(imgPath)
fullimgpath = imgPath + 'decomposition.jpg'
runTheModel(train, test, modelDict[bestModel], bestModel, date_col, response_col, decompose=True, imgPath=fullimgpath)