Skip to content

Commit c239fc3

Browse files
authored
Rename forecasting API argument to a better name. (dotnet#3945)
1 parent cea7f7b commit c239fc3

File tree

9 files changed

+61
-61
lines changed

9 files changed

+61
-61
lines changed

docs/samples/Microsoft.ML.Samples/Dynamic/Transforms/TimeSeries/ForecastingWithConfidenceInterval.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ public static void Example()
4848
// Instantiate the forecasting model.
4949
var model = ml.Forecasting.ForecastBySsa(outputColumnName, inputColumnName, 5, 11, data.Count, 5,
5050
confidenceLevel: 0.95f,
51-
lowerBoundConfidenceColumn: "ConfidenceLowerBound",
52-
upperBoundConfidenceColumn: "ConfidenceUpperBound");
51+
confidenceLowerBoundColumn: "ConfidenceLowerBound",
52+
confidenceUpperBoundColumn: "ConfidenceUpperBound");
5353

5454
// Train.
5555
var transformer = model.Fit(dataView);

src/Microsoft.ML.TimeSeries/ExtensionsCatalog.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,8 @@ public static SrCnnAnomalyEstimator DetectAnomalyBySrCnn(this TransformsCatalog
167167
/// <param name="shouldStabilize">The flag determining whether the model should be stabilized.</param>
168168
/// <param name="shouldMaintainInfo">The flag determining whether the meta information for the model needs to be maintained.</param>
169169
/// <param name="maxGrowth">The maximum growth on the exponential trend.</param>
170-
/// <param name="lowerBoundConfidenceColumn">The name of the confidence interval lower bound column. If not specified then confidence intervals will not be calculated.</param>
171-
/// <param name="upperBoundConfidenceColumn">The name of the confidence interval upper bound column. If not specified then confidence intervals will not be calculated.</param>
170+
/// <param name="confidenceLowerBoundColumn">The name of the confidence interval lower bound column. If not specified then confidence intervals will not be calculated.</param>
171+
/// <param name="confidenceUpperBoundColumn">The name of the confidence interval upper bound column. If not specified then confidence intervals will not be calculated.</param>
172172
/// <param name="confidenceLevel">The confidence level for forecasting.</param>
173173
/// <param name="variableHorizon">Set this to true if horizon will change after training(at prediction time).</param>
174174
/// <example>
@@ -182,10 +182,10 @@ public static SrCnnAnomalyEstimator DetectAnomalyBySrCnn(this TransformsCatalog
182182
public static SsaForecastingEstimator ForecastBySsa(
183183
this ForecastingCatalog catalog, string outputColumnName, string inputColumnName, int windowSize, int seriesLength, int trainSize, int horizon,
184184
bool isAdaptive = false, float discountFactor = 1, RankSelectionMethod rankSelectionMethod = RankSelectionMethod.Exact, int? rank = null,
185-
int? maxRank = null, bool shouldStabilize = true, bool shouldMaintainInfo = false, GrowthRatio? maxGrowth = null, string lowerBoundConfidenceColumn = null,
186-
string upperBoundConfidenceColumn = null, float confidenceLevel = 0.95f, bool variableHorizon = false) =>
185+
int? maxRank = null, bool shouldStabilize = true, bool shouldMaintainInfo = false, GrowthRatio? maxGrowth = null, string confidenceLowerBoundColumn = null,
186+
string confidenceUpperBoundColumn = null, float confidenceLevel = 0.95f, bool variableHorizon = false) =>
187187
new SsaForecastingEstimator(CatalogUtils.GetEnvironment(catalog), outputColumnName, inputColumnName, windowSize, seriesLength, trainSize,
188-
horizon, isAdaptive, discountFactor, rankSelectionMethod, rank, maxRank, shouldStabilize, shouldMaintainInfo, maxGrowth, lowerBoundConfidenceColumn,
189-
upperBoundConfidenceColumn, confidenceLevel, variableHorizon);
188+
horizon, isAdaptive, discountFactor, rankSelectionMethod, rank, maxRank, shouldStabilize, shouldMaintainInfo, maxGrowth, confidenceLowerBoundColumn,
189+
confidenceUpperBoundColumn, confidenceLevel, variableHorizon);
190190
}
191191
}

src/Microsoft.ML.TimeSeries/SSaForecasting.cs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ internal sealed class Options : TransformInputBase
4242
public string Name;
4343

4444
[Argument(ArgumentType.AtMostOnce, HelpText = "The name of the confidence interval lower bound column.", ShortName = "cnfminname", SortOrder = 3)]
45-
public string LowerBoundConfidenceColumn;
45+
public string ConfidenceLowerBoundColumn;
4646

4747
[Argument(ArgumentType.AtMostOnce, HelpText = "The name of the confidence interval upper bound column.", ShortName = "cnfmaxnname", SortOrder = 3)]
48-
public string UpperBoundConfidenceColumn;
48+
public string ConfidenceUpperBoundColumn;
4949

5050
[Argument(ArgumentType.AtMostOnce, HelpText = "The discount factor in [0,1] used for online updates.", ShortName = "disc", SortOrder = 5)]
5151
public float DiscountFactor = 1;
@@ -97,8 +97,8 @@ public BaseArguments(Options options)
9797
{
9898
Source = options.Source;
9999
Name = options.Name;
100-
LowerBoundConfidenceColumn = options.LowerBoundConfidenceColumn;
101-
UpperBoundConfidenceColumn = options.UpperBoundConfidenceColumn;
100+
ConfidenceLowerBoundColumn = options.ConfidenceLowerBoundColumn;
101+
ConfidenceUpperBoundColumn = options.ConfidenceUpperBoundColumn;
102102
WindowSize = options.WindowSize;
103103
DiscountFactor = options.DiscountFactor;
104104
IsAdaptive = options.IsAdaptive;
@@ -258,8 +258,8 @@ public sealed class SsaForecastingEstimator : IEstimator<SsaForecastingTransform
258258
/// <param name="shouldStabilize">The flag determining whether the model should be stabilized.</param>
259259
/// <param name="shouldMaintainInfo">The flag determining whether the meta information for the model needs to be maintained.</param>
260260
/// <param name="maxGrowth">The maximum growth on the exponential trend.</param>
261-
/// <param name="lowerBoundConfidenceColumn">The name of the confidence interval lower bound column. If not specified then confidence intervals will not be calculated.</param>
262-
/// <param name="upperBoundConfidenceColumn">The name of the confidence interval upper bound column. If not specified then confidence intervals will not be calculated.</param>
261+
/// <param name="confidenceLowerBoundColumn">The name of the confidence interval lower bound column. If not specified then confidence intervals will not be calculated.</param>
262+
/// <param name="confidenceUpperBoundColumn">The name of the confidence interval upper bound column. If not specified then confidence intervals will not be calculated.</param>
263263
/// <param name="confidenceLevel">The confidence level for forecasting.</param>
264264
/// <param name="variableHorizon">Set this to true if horizon will change after training.</param>
265265
internal SsaForecastingEstimator(IHostEnvironment env,
@@ -277,8 +277,8 @@ internal SsaForecastingEstimator(IHostEnvironment env,
277277
bool shouldStabilize = true,
278278
bool shouldMaintainInfo = false,
279279
GrowthRatio? maxGrowth = null,
280-
string lowerBoundConfidenceColumn = null,
281-
string upperBoundConfidenceColumn = null,
280+
string confidenceLowerBoundColumn = null,
281+
string confidenceUpperBoundColumn = null,
282282
float confidenceLevel = 0.95f,
283283
bool variableHorizon = false)
284284
: this(env, new SsaForecastingTransformer.Options
@@ -295,8 +295,8 @@ internal SsaForecastingEstimator(IHostEnvironment env,
295295
ShouldMaintainInfo = shouldMaintainInfo,
296296
MaxGrowth = maxGrowth,
297297
ConfidenceLevel = confidenceLevel,
298-
LowerBoundConfidenceColumn = lowerBoundConfidenceColumn,
299-
UpperBoundConfidenceColumn = upperBoundConfidenceColumn,
298+
ConfidenceLowerBoundColumn = confidenceLowerBoundColumn,
299+
ConfidenceUpperBoundColumn = confidenceUpperBoundColumn,
300300
SeriesLength = seriesLength,
301301
TrainSize = trainSize,
302302
VariableHorizon = variableHorizon,
@@ -344,14 +344,14 @@ public SchemaShape GetOutputSchema(SchemaShape inputSchema)
344344
resultDic[_options.Name] = new SchemaShape.Column(
345345
_options.Name, SchemaShape.Column.VectorKind.Vector, NumberDataViewType.Single, false);
346346

347-
if (!string.IsNullOrEmpty(_options.UpperBoundConfidenceColumn))
347+
if (!string.IsNullOrEmpty(_options.ConfidenceUpperBoundColumn))
348348
{
349-
resultDic[_options.LowerBoundConfidenceColumn] = new SchemaShape.Column(
350-
_options.LowerBoundConfidenceColumn, SchemaShape.Column.VectorKind.Vector,
349+
resultDic[_options.ConfidenceLowerBoundColumn] = new SchemaShape.Column(
350+
_options.ConfidenceLowerBoundColumn, SchemaShape.Column.VectorKind.Vector,
351351
NumberDataViewType.Single, false);
352352

353-
resultDic[_options.UpperBoundConfidenceColumn] = new SchemaShape.Column(
354-
_options.UpperBoundConfidenceColumn, SchemaShape.Column.VectorKind.Vector,
353+
resultDic[_options.ConfidenceUpperBoundColumn] = new SchemaShape.Column(
354+
_options.ConfidenceUpperBoundColumn, SchemaShape.Column.VectorKind.Vector,
355355
NumberDataViewType.Single, false);
356356
}
357357

src/Microsoft.ML.TimeSeries/SequentialForecastingTransformBase.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ internal abstract class ForecastingArgumentsBase
2828

2929
[Argument(ArgumentType.Required, HelpText = "The name of the confidence interval lower bound column.", ShortName = "cnfminname",
3030
SortOrder = 2)]
31-
public string LowerBoundConfidenceColumn;
31+
public string ConfidenceLowerBoundColumn;
3232

3333
[Argument(ArgumentType.Required, HelpText = "The name of the confidence interval upper bound column.", ShortName = "cnfmaxnname",
3434
SortOrder = 2)]
35-
public string UpperBoundConfidenceColumn;
35+
public string ConfidenceUpperBoundColumn;
3636

3737
[Argument(ArgumentType.AtMostOnce, HelpText = "The length of series from the begining used for training.", ShortName = "wnd",
3838
SortOrder = 3)]
@@ -57,18 +57,18 @@ internal abstract class SequentialForecastingTransformBase<TInput, TState> : Seq
5757
private readonly int _outputLength;
5858

5959
private protected SequentialForecastingTransformBase(int windowSize, int initialWindowSize,
60-
string inputColumnName, string outputColumnName, string forecastingConfidenceIntervalMinOutputColumnName,
61-
string forecastingConfidenceIntervalMaxOutputColumnName, string name, int outputLength, IHostEnvironment env)
60+
string inputColumnName, string outputColumnName, string confidenceLowerBoundColumn,
61+
string confidenceUpperBoundColumn, string name, int outputLength, IHostEnvironment env)
6262
: base(Contracts.CheckRef(env, nameof(env)).Register(name), windowSize, initialWindowSize,
63-
outputColumnName, forecastingConfidenceIntervalMinOutputColumnName,
64-
forecastingConfidenceIntervalMaxOutputColumnName, inputColumnName, new VectorDataViewType(NumberDataViewType.Single, outputLength))
63+
outputColumnName, confidenceLowerBoundColumn,
64+
confidenceUpperBoundColumn, inputColumnName, new VectorDataViewType(NumberDataViewType.Single, outputLength))
6565
{
6666
_outputLength = outputLength;
6767
}
6868

6969
private protected SequentialForecastingTransformBase(ForecastingArgumentsBase args, string name, int outputLength, IHostEnvironment env)
70-
: this(args.TrainSize, args.SeriesLength, args.Source, args.LowerBoundConfidenceColumn,
71-
args.UpperBoundConfidenceColumn, args.Name, name, outputLength, env)
70+
: this(args.TrainSize, args.SeriesLength, args.Source, args.ConfidenceLowerBoundColumn,
71+
args.ConfidenceUpperBoundColumn, args.Name, name, outputLength, env)
7272
{
7373
}
7474

@@ -127,12 +127,12 @@ public DataViewSchema.DetachedColumn[] GetOutputColumns()
127127
{
128128
DetachedColumn[] info;
129129

130-
if (!string.IsNullOrEmpty(_parent.ForecastingConfidenceIntervalMaxOutputColumnName))
130+
if (!string.IsNullOrEmpty(_parent.ConfidenceUpperBoundColumn))
131131
{
132132
info = new DetachedColumn[3];
133133
info[0] = new DetachedColumn(_parent.OutputColumnName, new VectorDataViewType(NumberDataViewType.Single, _parent._outputLength));
134-
info[1] = new DetachedColumn(_parent.ForecastingConfidenceIntervalMinOutputColumnName, new VectorDataViewType(NumberDataViewType.Single, _parent._outputLength));
135-
info[2] = new DetachedColumn(_parent.ForecastingConfidenceIntervalMaxOutputColumnName, new VectorDataViewType(NumberDataViewType.Single, _parent._outputLength));
134+
info[1] = new DetachedColumn(_parent.ConfidenceLowerBoundColumn, new VectorDataViewType(NumberDataViewType.Single, _parent._outputLength));
135+
info[2] = new DetachedColumn(_parent.ConfidenceUpperBoundColumn, new VectorDataViewType(NumberDataViewType.Single, _parent._outputLength));
136136
}
137137
else
138138
{
@@ -156,7 +156,7 @@ public Func<int, bool> GetDependencies(Func<int, bool> activeOutput)
156156
public Delegate[] CreateGetters(DataViewRow input, Func<int, bool> activeOutput, out Action disposer)
157157
{
158158
disposer = null;
159-
var getters = string.IsNullOrEmpty(_parent.ForecastingConfidenceIntervalMaxOutputColumnName) ? new Delegate[1] : new Delegate[3];
159+
var getters = string.IsNullOrEmpty(_parent.ConfidenceUpperBoundColumn) ? new Delegate[1] : new Delegate[3];
160160

161161
if (activeOutput(0))
162162
{
@@ -168,7 +168,7 @@ public Delegate[] CreateGetters(DataViewRow input, Func<int, bool> activeOutput,
168168
getters[0] = valueGetter;
169169
}
170170

171-
if (!string.IsNullOrEmpty(_parent.ForecastingConfidenceIntervalMaxOutputColumnName))
171+
if (!string.IsNullOrEmpty(_parent.ConfidenceUpperBoundColumn))
172172
{
173173
if (activeOutput(1))
174174
{

src/Microsoft.ML.TimeSeries/SequentialTransformerBase.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -335,8 +335,8 @@ private protected virtual void CloneCore(TState state)
335335

336336
internal readonly string InputColumnName;
337337
internal readonly string OutputColumnName;
338-
internal readonly string ForecastingConfidenceIntervalMinOutputColumnName;
339-
internal readonly string ForecastingConfidenceIntervalMaxOutputColumnName;
338+
internal readonly string ConfidenceLowerBoundColumn;
339+
internal readonly string ConfidenceUpperBoundColumn;
340340
private protected DataViewType OutputColumnType;
341341

342342
bool ITransformer.IsRowToRowMapper => false;
@@ -372,12 +372,12 @@ private protected SequentialTransformerBase(IHost host, int windowSize, int init
372372
}
373373

374374
private protected SequentialTransformerBase(IHost host, int windowSize, int initialWindowSize,
375-
string outputColumnName, string forecastingConfidenceIntervalMinOutputColumnName,
376-
string forecastingConfidenceIntervalMaxOutputColumnName, string inputColumnName, DataViewType outputColType) :
375+
string outputColumnName, string confidenceLowerBoundColumn,
376+
string confidenceUpperBoundColumn, string inputColumnName, DataViewType outputColType) :
377377
this(host, windowSize, initialWindowSize, outputColumnName, inputColumnName, outputColType)
378378
{
379-
ForecastingConfidenceIntervalMinOutputColumnName = forecastingConfidenceIntervalMinOutputColumnName;
380-
ForecastingConfidenceIntervalMaxOutputColumnName = forecastingConfidenceIntervalMaxOutputColumnName;
379+
ConfidenceLowerBoundColumn = confidenceLowerBoundColumn;
380+
ConfidenceUpperBoundColumn = confidenceUpperBoundColumn;
381381
}
382382

383383
private protected SequentialTransformerBase(IHost host, ModelLoadContext ctx)
@@ -403,8 +403,8 @@ private protected SequentialTransformerBase(IHost host, ModelLoadContext ctx)
403403

404404
InputColumnName = inputColumnName;
405405
OutputColumnName = outputColumnName;
406-
ForecastingConfidenceIntervalMinOutputColumnName = ctx.Reader.ReadString();
407-
ForecastingConfidenceIntervalMaxOutputColumnName = ctx.Reader.ReadString();
406+
ConfidenceLowerBoundColumn = ctx.Reader.ReadString();
407+
ConfidenceUpperBoundColumn = ctx.Reader.ReadString();
408408
InitialWindowSize = initialWindowSize;
409409
WindowSize = windowSize;
410410

@@ -431,8 +431,8 @@ private protected virtual void SaveModel(ModelSaveContext ctx)
431431
ctx.Writer.Write(InitialWindowSize);
432432
ctx.SaveNonEmptyString(InputColumnName);
433433
ctx.SaveNonEmptyString(OutputColumnName);
434-
ctx.Writer.Write(ForecastingConfidenceIntervalMinOutputColumnName ?? string.Empty);
435-
ctx.Writer.Write(ForecastingConfidenceIntervalMaxOutputColumnName ?? string.Empty);
434+
ctx.Writer.Write(ConfidenceLowerBoundColumn ?? string.Empty);
435+
ctx.Writer.Write(ConfidenceUpperBoundColumn ?? string.Empty);
436436
var bs = new BinarySaver(Host, new BinarySaver.Arguments());
437437
bs.TryWriteTypeDescription(ctx.Writer.BaseStream, OutputColumnType, out int byteWritten);
438438
}
@@ -480,8 +480,8 @@ public SequentialDataTransform(IHost host, SequentialTransformerBase<TInput, TOu
480480
Metadata = new MetadataDispatcher(3);
481481
_parent = parent;
482482
_transform = CreateLambdaTransform(_parent.Host, input, _parent.InputColumnName,
483-
_parent.OutputColumnName, _parent.ForecastingConfidenceIntervalMinOutputColumnName,
484-
_parent.ForecastingConfidenceIntervalMaxOutputColumnName, InitFunction, _parent.WindowSize > 0, _parent.OutputColumnType);
483+
_parent.OutputColumnName, _parent.ConfidenceLowerBoundColumn,
484+
_parent.ConfidenceUpperBoundColumn, InitFunction, _parent.WindowSize > 0, _parent.OutputColumnType);
485485

486486
_mapper = mapper;
487487
_bindings = new ColumnBindings(input.Schema, _mapper.GetOutputColumns());

src/Microsoft.ML.TimeSeries/SsaForecastingBase.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,16 +127,16 @@ internal sealed class SsaForecastingBase : SequentialForecastingTransformBase<fl
127127
internal SequenceModelerBase<Single, Single> Model;
128128

129129
public SsaForecastingBase(SsaForecastingOptions options, string name, IHostEnvironment env, SsaForecastingBaseWrapper parent)
130-
: base(options.TrainSize, 0, options.Source, options.Name, options.LowerBoundConfidenceColumn,
131-
options.UpperBoundConfidenceColumn, name, options.VariableHorizon ? 0: options.Horizon, env)
130+
: base(options.TrainSize, 0, options.Source, options.Name, options.ConfidenceLowerBoundColumn,
131+
options.ConfidenceUpperBoundColumn, name, options.VariableHorizon ? 0: options.Horizon, env)
132132
{
133133
Host.CheckUserArg(0 <= options.DiscountFactor && options.DiscountFactor <= 1, nameof(options.DiscountFactor), "Must be in the range [0, 1].");
134134
IsAdaptive = options.IsAdaptive;
135135
Horizon = options.Horizon;
136136
ConfidenceLevel = options.ConfidenceLevel;
137137
// Creating the master SSA model
138138
Model = new AdaptiveSingularSpectrumSequenceModelerInternal(Host, options.TrainSize, options.SeriesLength, options.WindowSize,
139-
options.DiscountFactor, options.RankSelectionMethod, options.Rank, options.MaxRank, !string.IsNullOrEmpty(options.LowerBoundConfidenceColumn),
139+
options.DiscountFactor, options.RankSelectionMethod, options.Rank, options.MaxRank, !string.IsNullOrEmpty(options.ConfidenceLowerBoundColumn),
140140
options.ShouldStablize, options.ShouldMaintainInfo, options.MaxGrowth);
141141

142142
StateRef = new State();

0 commit comments

Comments
 (0)