Skip to content
This repository was archived by the owner on Nov 16, 2023. It is now read-only.

Commit 2ad0a4f

Browse files
Update to the latest entry point version of SsaForecaster. Fix a few
naming issues and remove the confidence lower and upper bounds from the examples.
1 parent 6a8fa2f commit 2ad0a4f

File tree

8 files changed

+82
-92
lines changed

8 files changed

+82
-92
lines changed

src/python/nimbusml/examples/SsaForecaster.py

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,10 @@
1919

2020
# define the training pipeline
2121
pipeline = Pipeline([
22-
SsaForecaster(forcasting_confident_lower_bound_column_name="cmin",
23-
forcasting_confident_upper_bound_column_name="cmax",
24-
series_length=6,
22+
SsaForecaster(series_length=6,
2523
train_size=8,
2624
window_size=3,
2725
horizon=2,
28-
# max_growth={'TimeSpan': 1, 'Growth': 1}
2926
columns={'t2_fc': 't2'})
3027
])
3128

@@ -35,15 +32,16 @@
3532
print(result)
3633

3734
# Output
38-
# t1 t2 t3 t2_fc.0 t2_fc.1 cmin.0 cmin.1 cmax.0 cmax.1
39-
# 0 0.01 0.01 0.01 0.10 0.12 0.09 0.11 0.11 0.13
40-
# 1 0.02 0.02 0.02 0.06 0.08 0.06 0.07 0.07 0.09
41-
# 2 0.03 0.03 0.02 0.04 0.05 0.03 0.04 0.05 0.07
42-
# 3 0.03 0.03 0.03 0.05 0.06 0.04 0.05 0.05 0.07
43-
# 4 0.03 0.03 0.00 0.05 0.07 0.04 0.05 0.06 0.08
44-
# 5 0.03 0.05 0.01 0.06 0.08 0.05 0.07 0.07 0.10
45-
# 6 0.05 0.07 0.05 0.09 0.12 0.08 0.10 0.10 0.13
46-
# 7 0.07 0.09 0.09 0.12 0.16 0.11 0.15 0.13 0.17
47-
# 8 0.09 99.00 99.00 57.92 82.88 57.91 82.87 57.93 82.89
48-
# 9 1.10 0.10 0.10 60.50 77.18 60.49 77.17 60.50 77.19
35+
#
36+
# t1 t2 t3 t2_fc.0 t2_fc.1
37+
# 0 0.01 0.01 0.01 0.10 0.12
38+
# 1 0.02 0.02 0.02 0.06 0.08
39+
# 2 0.03 0.03 0.02 0.04 0.05
40+
# 3 0.03 0.03 0.03 0.05 0.06
41+
# 4 0.03 0.03 0.00 0.05 0.07
42+
# 5 0.03 0.05 0.01 0.06 0.08
43+
# 6 0.05 0.07 0.05 0.09 0.12
44+
# 7 0.07 0.09 0.09 0.12 0.16
45+
# 8 0.09 99.00 99.00 57.92 82.88
46+
# 9 1.10 0.10 0.10 60.50 77.18
4947

src/python/nimbusml/examples/examples_from_dataframe/SsaForecaster_df.py

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -54,35 +54,33 @@
5454
training_seasons = 3
5555
training_size = seasonality_size * training_seasons
5656

57-
forecaster = SsaForecaster(forcasting_confident_lower_bound_column_name="cmin",
58-
forcasting_confident_upper_bound_column_name="cmax",
59-
series_length=8,
57+
forecaster = SsaForecaster(series_length=8,
6058
train_size=training_size,
6159
window_size=seasonality_size + 1,
62-
horizon=4,
63-
# max_growth={'TimeSpan': 1, 'Growth': 1}
64-
) << {'fc': 'ts'}
60+
horizon=4) << {'fc': 'ts'}
6561

6662
forecaster.fit(X_train, verbose=1)
6763
data = forecaster.transform(x_test)
6864

6965
pd.set_option('display.float_format', lambda x: '%.2f' % x)
7066
print(data)
7167

72-
# Output
73-
# ts fc.0 fc.1 fc.2 fc.3 cmin.0 cmin.1 cmin.2 cmin.3 cmax.0 cmax.1 cmax.2 cmax.3
74-
# 0 0 1.00 2.00 3.00 4.00 1.00 2.00 3.00 4.00 1.00 2.00 3.00 4.00
75-
# 1 1 2.00 3.00 4.00 -0.00 2.00 3.00 4.00 -0.00 2.00 3.00 4.00 0.00
76-
# 2 2 3.00 4.00 -0.00 1.00 3.00 4.00 -0.00 1.00 3.00 4.00 0.00 1.00
77-
# 3 3 4.00 -0.00 1.00 2.00 4.00 -0.00 1.00 2.00 4.00 0.00 1.00 2.00
78-
# 4 4 -0.00 1.00 2.00 3.00 -0.00 1.00 2.00 3.00 0.00 1.00 2.00 3.00
79-
# 5 0 1.00 2.00 3.00 4.00 1.00 2.00 3.00 4.00 1.00 2.00 3.00 4.00
80-
# 6 1 2.00 3.00 4.00 -0.00 2.00 3.00 4.00 -0.00 2.00 3.00 4.00 0.00
81-
# 7 2 3.00 4.00 -0.00 1.00 3.00 4.00 -0.00 1.00 3.00 4.00 0.00 1.00
82-
# 8 3 4.00 -0.00 1.00 2.00 4.00 -0.00 1.00 2.00 4.00 0.00 1.00 2.00
83-
# 9 4 -0.00 1.00 2.00 3.00 -0.00 1.00 2.00 3.00 0.00 1.00 2.00 3.00
84-
# 10 0 1.00 2.00 3.00 4.00 1.00 2.00 3.00 4.00 1.00 2.00 3.00 4.00
85-
# 11 1 2.00 3.00 4.00 -0.00 2.00 3.00 4.00 -0.00 2.00 3.00 4.00 0.00
86-
# 12 100 3.00 4.00 0.00 1.00 3.00 4.00 -0.00 1.00 3.00 4.00 0.00 1.00
87-
# 13 110 4.00 -0.00 1.00 75.50 4.00 -0.00 1.00 75.50 4.00 -0.00 1.00 75.50
88-
# 14 120 -0.00 1.00 83.67 83.25 -0.00 1.00 83.67 83.25 -0.00 1.00 83.67 83.25
68+
# The fc.x columns are the forecasts
69+
# given the input in the ts column.
70+
#
71+
# ts fc.0 fc.1 fc.2 fc.3
72+
# 0 0 1.00 2.00 3.00 4.00
73+
# 1 1 2.00 3.00 4.00 -0.00
74+
# 2 2 3.00 4.00 -0.00 1.00
75+
# 3 3 4.00 -0.00 1.00 2.00
76+
# 4 4 -0.00 1.00 2.00 3.00
77+
# 5 0 1.00 2.00 3.00 4.00
78+
# 6 1 2.00 3.00 4.00 -0.00
79+
# 7 2 3.00 4.00 -0.00 1.00
80+
# 8 3 4.00 -0.00 1.00 2.00
81+
# 9 4 -0.00 1.00 2.00 3.00
82+
# 10 0 1.00 2.00 3.00 4.00
83+
# 11 1 2.00 3.00 4.00 -0.00
84+
# 12 100 3.00 4.00 0.00 1.00
85+
# 13 110 4.00 -0.00 1.00 75.50
86+
# 14 120 -0.00 1.00 83.67 83.25

src/python/nimbusml/internal/core/timeseries/ssaforecaster.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ class SsaForecaster(BasePipelineItem, DefaultSignature):
3737
:param variable_horizon: Set this to true horizon will change at prediction
3838
time.
3939
40-
:param forcasting_confident_lower_bound_column_name: The name of the
41-
confidence interval lower bound column.
40+
:param lower_bound_confidence_column: The name of the confidence interval
41+
lower bound column.
4242
43-
:param forcasting_confident_upper_bound_column_name: The name of the
44-
confidence interval upper bound column.
43+
:param upper_bound_confidence_column: The name of the confidence interval
44+
upper bound column.
4545
4646
:param rank_selection_method: The rank selection method.
4747
@@ -54,7 +54,7 @@ class SsaForecaster(BasePipelineItem, DefaultSignature):
5454
process. If not provided (i.e. set to null), it is set to windowSize -
5555
1.
5656
57-
:param should_stablize: The flag determining whether the model should be
57+
:param should_stabilize: The flag determining whether the model should be
5858
stabilized.
5959
6060
:param should_maintain_info: The flag determining whether the meta
@@ -80,12 +80,12 @@ def __init__(
8080
horizon=0,
8181
confidence_level=0.95,
8282
variable_horizon=False,
83-
forcasting_confident_lower_bound_column_name=None,
84-
forcasting_confident_upper_bound_column_name=None,
83+
lower_bound_confidence_column=None,
84+
upper_bound_confidence_column=None,
8585
rank_selection_method='Exact',
8686
rank=None,
8787
max_rank=None,
88-
should_stablize=True,
88+
should_stabilize=True,
8989
should_maintain_info=False,
9090
max_growth=None,
9191
discount_factor=1.0,
@@ -100,12 +100,12 @@ def __init__(
100100
self.horizon = horizon
101101
self.confidence_level = confidence_level
102102
self.variable_horizon = variable_horizon
103-
self.forcasting_confident_lower_bound_column_name = forcasting_confident_lower_bound_column_name
104-
self.forcasting_confident_upper_bound_column_name = forcasting_confident_upper_bound_column_name
103+
self.lower_bound_confidence_column = lower_bound_confidence_column
104+
self.upper_bound_confidence_column = upper_bound_confidence_column
105105
self.rank_selection_method = rank_selection_method
106106
self.rank = rank
107107
self.max_rank = max_rank
108-
self.should_stablize = should_stablize
108+
self.should_stabilize = should_stabilize
109109
self.should_maintain_info = should_maintain_info
110110
self.max_growth = max_growth
111111
self.discount_factor = discount_factor
@@ -126,12 +126,12 @@ def _get_node(self, **all_args):
126126
horizon=self.horizon,
127127
confidence_level=self.confidence_level,
128128
variable_horizon=self.variable_horizon,
129-
forcasting_confident_lower_bound_column_name=self.forcasting_confident_lower_bound_column_name,
130-
forcasting_confident_upper_bound_column_name=self.forcasting_confident_upper_bound_column_name,
129+
lower_bound_confidence_column=self.lower_bound_confidence_column,
130+
upper_bound_confidence_column=self.upper_bound_confidence_column,
131131
rank_selection_method=self.rank_selection_method,
132132
rank=self.rank,
133133
max_rank=self.max_rank,
134-
should_stablize=self.should_stablize,
134+
should_stabilize=self.should_stabilize,
135135
should_maintain_info=self.should_maintain_info,
136136
max_growth=self.max_growth,
137137
discount_factor=self.discount_factor,

src/python/nimbusml/internal/entrypoints/timeseriesprocessingentrypoints_ssaforecasting.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ def timeseriesprocessingentrypoints_ssaforecasting(
2121
horizon=0,
2222
confidence_level=0.95,
2323
variable_horizon=False,
24-
forcasting_confident_lower_bound_column_name=None,
25-
forcasting_confident_upper_bound_column_name=None,
24+
lower_bound_confidence_column=None,
25+
upper_bound_confidence_column=None,
2626
rank_selection_method='Exact',
2727
rank=None,
2828
max_rank=None,
29-
should_stablize=True,
29+
should_stabilize=True,
3030
should_maintain_info=False,
3131
max_growth=None,
3232
discount_factor=1.0,
@@ -50,10 +50,10 @@ def timeseriesprocessingentrypoints_ssaforecasting(
5050
forecasting. (inputs).
5151
:param variable_horizon: Set this to true horizon will change at
5252
prediction time. (inputs).
53-
:param forcasting_confident_lower_bound_column_name: The name of
54-
the confidence interval lower bound column. (inputs).
55-
:param forcasting_confident_upper_bound_column_name: The name of
56-
the confidence interval upper bound column. (inputs).
53+
:param lower_bound_confidence_column: The name of the confidence
54+
interval lower bound column. (inputs).
55+
:param upper_bound_confidence_column: The name of the confidence
56+
interval upper bound column. (inputs).
5757
:param rank_selection_method: The rank selection method.
5858
(inputs).
5959
:param rank: The desired rank of the subspace used for SSA
@@ -64,7 +64,7 @@ def timeseriesprocessingentrypoints_ssaforecasting(
6464
:param max_rank: The maximum rank considered during the rank
6565
selection process. If not provided (i.e. set to null), it is
6666
set to windowSize - 1. (inputs).
67-
:param should_stablize: The flag determining whether the model
67+
:param should_stabilize: The flag determining whether the model
6868
should be stabilized. (inputs).
6969
:param should_maintain_info: The flag determining whether the
7070
meta information for the model needs to be maintained.
@@ -130,15 +130,15 @@ def timeseriesprocessingentrypoints_ssaforecasting(
130130
obj=variable_horizon,
131131
none_acceptable=True,
132132
is_of_type=bool)
133-
if forcasting_confident_lower_bound_column_name is not None:
134-
inputs['ForcastingConfidentLowerBoundColumnName'] = try_set(
135-
obj=forcasting_confident_lower_bound_column_name,
133+
if lower_bound_confidence_column is not None:
134+
inputs['LowerBoundConfidenceColumn'] = try_set(
135+
obj=lower_bound_confidence_column,
136136
none_acceptable=True,
137137
is_of_type=str,
138138
is_column=True)
139-
if forcasting_confident_upper_bound_column_name is not None:
140-
inputs['ForcastingConfidentUpperBoundColumnName'] = try_set(
141-
obj=forcasting_confident_upper_bound_column_name,
139+
if upper_bound_confidence_column is not None:
140+
inputs['UpperBoundConfidenceColumn'] = try_set(
141+
obj=upper_bound_confidence_column,
142142
none_acceptable=True,
143143
is_of_type=str,
144144
is_column=True)
@@ -161,9 +161,9 @@ def timeseriesprocessingentrypoints_ssaforecasting(
161161
obj=max_rank,
162162
none_acceptable=True,
163163
is_of_type=numbers.Real)
164-
if should_stablize is not None:
165-
inputs['ShouldStablize'] = try_set(
166-
obj=should_stablize,
164+
if should_stabilize is not None:
165+
inputs['ShouldStabilize'] = try_set(
166+
obj=should_stabilize,
167167
none_acceptable=True,
168168
is_of_type=bool)
169169
if should_maintain_info is not None:

src/python/nimbusml/tests/timeseries/test_ssaforecaster.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ def test_simple_forecast(self):
2626
training_seasons = 3
2727
training_size = seasonality_size * training_seasons
2828

29-
forecaster = SsaForecaster(forcasting_confident_lower_bound_column_name="cmin",
30-
forcasting_confident_upper_bound_column_name="cmax",
31-
series_length=8,
29+
forecaster = SsaForecaster(series_length=8,
3230
train_size=training_size,
3331
window_size=seasonality_size + 1,
3432
horizon=2) << {'fc': 'ts'}
@@ -48,9 +46,7 @@ def test_multiple_user_specified_columns_is_not_allowed(self):
4846

4947
try:
5048
pipeline = Pipeline([
51-
SsaForecaster(forcasting_confident_lower_bound_column_name="cmin",
52-
forcasting_confident_upper_bound_column_name="cmax",
53-
series_length=8,
49+
SsaForecaster(series_length=8,
5450
train_size=15,
5551
window_size=5,
5652
horizon=2,

src/python/nimbusml/timeseries/ssaforecaster.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ class SsaForecaster(core, BaseTransform, TransformerMixin):
4040
:param variable_horizon: Set this to true horizon will change at prediction
4141
time.
4242
43-
:param forcasting_confident_lower_bound_column_name: The name of the
44-
confidence interval lower bound column.
43+
:param lower_bound_confidence_column: The name of the confidence interval
44+
lower bound column.
4545
46-
:param forcasting_confident_upper_bound_column_name: The name of the
47-
confidence interval upper bound column.
46+
:param upper_bound_confidence_column: The name of the confidence interval
47+
upper bound column.
4848
4949
:param rank_selection_method: The rank selection method.
5050
@@ -57,7 +57,7 @@ class SsaForecaster(core, BaseTransform, TransformerMixin):
5757
process. If not provided (i.e. set to null), it is set to windowSize -
5858
1.
5959
60-
:param should_stablize: The flag determining whether the model should be
60+
:param should_stabilize: The flag determining whether the model should be
6161
stabilized.
6262
6363
:param should_maintain_info: The flag determining whether the meta
@@ -83,12 +83,12 @@ def __init__(
8383
horizon=0,
8484
confidence_level=0.95,
8585
variable_horizon=False,
86-
forcasting_confident_lower_bound_column_name=None,
87-
forcasting_confident_upper_bound_column_name=None,
86+
lower_bound_confidence_column=None,
87+
upper_bound_confidence_column=None,
8888
rank_selection_method='Exact',
8989
rank=None,
9090
max_rank=None,
91-
should_stablize=True,
91+
should_stabilize=True,
9292
should_maintain_info=False,
9393
max_growth=None,
9494
discount_factor=1.0,
@@ -107,12 +107,12 @@ def __init__(
107107
horizon=horizon,
108108
confidence_level=confidence_level,
109109
variable_horizon=variable_horizon,
110-
forcasting_confident_lower_bound_column_name=forcasting_confident_lower_bound_column_name,
111-
forcasting_confident_upper_bound_column_name=forcasting_confident_upper_bound_column_name,
110+
lower_bound_confidence_column=lower_bound_confidence_column,
111+
upper_bound_confidence_column=upper_bound_confidence_column,
112112
rank_selection_method=rank_selection_method,
113113
rank=rank,
114114
max_rank=max_rank,
115-
should_stablize=should_stablize,
115+
should_stabilize=should_stabilize,
116116
should_maintain_info=should_maintain_info,
117117
max_growth=max_growth,
118118
discount_factor=discount_factor,

src/python/tests/test_estimator_checks.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,7 @@
200200
window_size=2,
201201
series_length=5,
202202
train_size=5,
203-
horizon=1,
204-
forcasting_confident_lower_bound_column_name="cmin",
205-
forcasting_confident_upper_bound_column_name="cmax"),
203+
horizon=1),
206204
'TensorFlowScorer': TensorFlowScorer(
207205
model_location=os.path.join(
208206
this,

src/python/tools/manifest.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4095,7 +4095,7 @@
40954095
"Default": false
40964096
},
40974097
{
4098-
"Name": "ForcastingConfidentLowerBoundColumnName",
4098+
"Name": "LowerBoundConfidenceColumn",
40994099
"Type": "String",
41004100
"Desc": "The name of the confidence interval lower bound column.",
41014101
"Aliases": [
@@ -4107,7 +4107,7 @@
41074107
"Default": null
41084108
},
41094109
{
4110-
"Name": "ForcastingConfidentUpperBoundColumnName",
4110+
"Name": "UpperBoundConfidenceColumn",
41114111
"Type": "String",
41124112
"Desc": "The name of the confidence interval upper bound column.",
41134113
"Aliases": [
@@ -4153,7 +4153,7 @@
41534153
"Default": null
41544154
},
41554155
{
4156-
"Name": "ShouldStablize",
4156+
"Name": "ShouldStabilize",
41574157
"Type": "Bool",
41584158
"Desc": "The flag determining whether the model should be stabilized.",
41594159
"Required": false,

0 commit comments

Comments
 (0)