-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* first pickle fix attempt * better attempt by using initializer creating an initializer class to tackle problem of #340 fixed #40 * ETS Initializer add ets initializer and change some wording from stan to generic * change wording from stan to generic [minor] minor wording
- Loading branch information
Edwin Ng
authored
Jan 28, 2021
1 parent
307b5b4
commit 2b4aba9
Showing
14 changed files
with
153 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import numpy as np | ||
from ..constants import dlt as constants | ||
|
||
|
||
class DLTInitializer(object): | ||
def __init__(self, s, n_pr, n_nr, n_rr): | ||
self.s = s | ||
self.n_pr = n_pr | ||
self.n_nr = n_nr | ||
self.n_rr = n_rr | ||
|
||
def __call__(self): | ||
init_values = dict() | ||
if self.s > 1: | ||
init_sea = np.random.normal(loc=0, scale=0.05, size=self.s - 1) | ||
# catch cases with extreme values | ||
init_sea[init_sea > 1.0] = 1.0 | ||
init_sea[init_sea < -1.0] = -1.0 | ||
init_values[constants.LatentSamplingParameters.INITIAL_SEASONALITY.value] = init_sea | ||
if self.n_pr > 0: | ||
x = np.random.normal(loc=0, scale=0.1, size=self.n_pr) | ||
x[x < 0] = -1 * x[x < 0] | ||
init_values[constants.LatentSamplingParameters.REGRESSION_POSITIVE_COEFFICIENTS.value] = \ | ||
x | ||
if self.n_nr > 0: | ||
x = np.random.normal(loc=-0, scale=0.1, size=self.n_nr) | ||
x[x > 0] = -1 * x[x > 0] | ||
init_values[constants.LatentSamplingParameters.REGRESSION_NEGATIVE_COEFFICIENTS.value] = \ | ||
x | ||
if self.n_rr > 0: | ||
init_values[constants.LatentSamplingParameters.REGRESSION_REGULAR_COEFFICIENTS.value] = \ | ||
np.random.normal(loc=-0, scale=0.1, size=self.n_rr) | ||
return init_values |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import numpy as np | ||
from ..constants import ets as constants | ||
|
||
|
||
class ETSInitializer(object): | ||
def __init__(self, s): | ||
self.s = s | ||
|
||
def __call__(self): | ||
init_values = dict() | ||
init_sea = np.random.normal(loc=0, scale=0.05, size=self.s - 1) | ||
# catch cases with extreme values | ||
init_sea[init_sea > 1.0] = 1.0 | ||
init_sea[init_sea < -1.0] = -1.0 | ||
init_values[constants.LatentSamplingParameters.INITIAL_SEASONALITY.value] = init_sea | ||
return init_values |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import numpy as np | ||
from ..constants import lgt as constants | ||
|
||
|
||
class LGTInitializer(object): | ||
def __init__(self, s, n_pr, n_nr, n_rr): | ||
self.s = s | ||
self.n_pr = n_pr | ||
self.n_nr = n_nr | ||
self.n_rr = n_rr | ||
|
||
def __call__(self): | ||
init_values = dict() | ||
if self.s > 1: | ||
init_sea = np.random.normal(loc=0, scale=0.05, size=self.s - 1) | ||
# catch cases with extreme values | ||
init_sea[init_sea > 1.0] = 1.0 | ||
init_sea[init_sea < -1.0] = -1.0 | ||
init_values[constants.LatentSamplingParameters.INITIAL_SEASONALITY.value] = init_sea | ||
if self.n_pr > 0: | ||
x = np.random.normal(loc=0, scale=0.1, size=self.n_pr) | ||
x[x < 0] = -1 * x[x < 0] | ||
init_values[constants.LatentSamplingParameters.REGRESSION_POSITIVE_COEFFICIENTS.value] = \ | ||
x | ||
if self.n_nr > 0: | ||
x = np.random.normal(loc=-0, scale=0.1, size=self.n_nr) | ||
x[x > 0] = -1 * x[x > 0] | ||
init_values[constants.LatentSamplingParameters.REGRESSION_NEGATIVE_COEFFICIENTS.value] = \ | ||
x | ||
if self.n_rr > 0: | ||
init_values[constants.LatentSamplingParameters.REGRESSION_REGULAR_COEFFICIENTS.value] = \ | ||
np.random.normal(loc=-0, scale=0.1, size=self.n_rr) | ||
return init_values |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.