Skip to content

Commit

Permalink
Add Multiplicative Models/Seasonals #178.
Browse files Browse the repository at this point in the history
Compute AR/Keras/Intermittent/Scikit models residues
  • Loading branch information
antoinecarme committed Mar 5, 2022
1 parent 9703650 commit 94cd00b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
5 changes: 2 additions & 3 deletions pyaf/TS/Intermittent_Models.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def fit(self):

lPredicted = self.croston(self.mARFrame);
self.mARFrame[self.mOutName] = lPredicted['forecast']
self.mARFrame[self.mOutName + '_residue'] = self.mARFrame[series] - self.mARFrame[self.mOutName]
self.compute_ar_residue(self.mARFrame)

# print("ESTIMATE_CROSTON_MODEL_END" , self.mOutName);

Expand All @@ -140,7 +140,6 @@ def transformDataset(self, df, horizon_index = 1):
series = self.mCycleResidueName;
pred = self.croston(df, horizon_index)
df[self.mOutName] = pred['forecast'];
target = df[series].values
df[self.mOutName + '_residue'] = target - df[self.mOutName].values
self.compute_ar_residue(df)
return df;

5 changes: 2 additions & 3 deletions pyaf/TS/Keras_Models.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def fit(self):

# print("ESTIMATE_RNN_MODEL_STEP8" , self.mOutName);

self.mARFrame[self.mOutName + '_residue'] = self.mARFrame[series] - self.mARFrame[self.mOutName]
self.compute_ar_residue(self.mARFrame)

# print("ESTIMATE_RNN_MODEL_END" , self.mOutName, self.mModel.__dict__);
# self.testPickle_old();
Expand All @@ -114,8 +114,7 @@ def transformDataset(self, df, horizon_index = 1):
lPredicted = self.mModel.predict(inputs)
lPredicted = np.reshape(lPredicted, (lPredicted.shape[0]))
df[self.mOutName] = lPredicted;
target = df[series].values
df[self.mOutName + '_residue'] = target - df[self.mOutName].values
self.compute_ar_residue(df)
return df;

class cMLP_Model(cAbstract_RNN_Model):
Expand Down
5 changes: 2 additions & 3 deletions pyaf/TS/Scikit_Models.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def fit(self):
# issue_34 failure SVD does not converge
self.mARFrame[self.mOutName] = self.mDefaultValues[series]

self.mARFrame[self.mOutName + '_residue'] = self.mARFrame[series] - self.mARFrame[self.mOutName]
self.compute_ar_residue(self.mARFrame)

# print("ESTIMATE_SCIKIT_MODEL_END" , self.mOutName);

Expand All @@ -132,8 +132,7 @@ def transformDataset(self, df, horizon_index = 1):
else:
df[self.mOutName] = self.mDefaultValues[series];

target = df[series].values
df[self.mOutName + '_residue'] = target - df[self.mOutName].values
self.compute_ar_residue(df)
return df;


Expand Down

0 comments on commit 94cd00b

Please sign in to comment.