Skip to content

Lockdown Microsoft.ML.TimeSeries public surface #2344

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Feb 11, 2019

Conversation

codemzs
Copy link
Member

@codemzs codemzs commented Jan 31, 2019

fixes #2281

This change reduces TimeSeries public API count from 371 to 124 58 57.

image

image

@TomFinley
Copy link
Contributor

TomFinley commented Jan 31, 2019

public abstract class SequenceModelerBase<TInput, TOutput> : ICanSaveModel

This should not be part of our public API. #Resolved


Refers to: src/Microsoft.ML.TimeSeries/SequenceModelerBase.cs:25 in b81ef6c. [](commit_id = b81ef6c, deletion_comment = False)

@codemzs codemzs changed the title Lockdown Microsoft.ML.TimeSeries public surface WIP Lockdown Microsoft.ML.TimeSeries public surface Jan 31, 2019
@@ -15,7 +15,7 @@ namespace Microsoft.ML.TimeSeriesProcessing
internal static class TimeSeriesProcessingEntryPoints
{
[TlcModule.EntryPoint(Desc = ExponentialAverageTransform.Summary, UserName = ExponentialAverageTransform.UserName, ShortName = ExponentialAverageTransform.ShortName)]
public static CommonOutputs.TransformOutput ExponentialAverage(IHostEnvironment env, ExponentialAverageTransform.Arguments input)
internal static CommonOutputs.TransformOutput ExponentialAverage(IHostEnvironment env, ExponentialAverageTransform.Arguments input)
Copy link
Contributor

@TomFinley TomFinley Jan 31, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

internal [](start = 8, length = 8)

This appears to already be part of an internal class, so the changes in this particular file were not helpful. Probably revert. #Pending

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure but these functions were showing up in API list but I could be wrong as well ... will do in the next iteration.


In reply to: 252812773 [](ancestors = 252812773)

@TomFinley
Copy link
Contributor

TomFinley commented Jan 31, 2019

At least in the current version, I do not see that we have made an effort to internalize and hide SequentialAnomalyDetectionTransformBase, which is arguably the most offensive and problematic part of this API? #Resolved

@codemzs
Copy link
Member Author

codemzs commented Jan 31, 2019

@TomFinley SequentialAnomalyDetectionTransformBase is the base class for IID and SSA spike and anomaly detectors. Can you please clarify on what needs to be internalized there? I believe the only thing we need to internalize is State object but if there is anything else please let me know. #Resolved

@TomFinley
Copy link
Contributor

Well, the only plausible way to internalize the state is to wrap the transformer implementation, since you will doubtless need these generic parameters still. This suggests internalizing the generic base class.


In reply to: 459483255 [](ancestors = 459483255)

@codecov
Copy link

codecov bot commented Jan 31, 2019

Codecov Report

Merging #2344 into master will increase coverage by <.01%.
The diff coverage is 82.36%.

@@            Coverage Diff             @@
##           master    #2344      +/-   ##
==========================================
+ Coverage   71.24%   71.24%   +<.01%     
==========================================
  Files         788      789       +1     
  Lines      141131   141200      +69     
  Branches    16115    16116       +1     
==========================================
+ Hits       100545   100598      +53     
- Misses      36121    36136      +15     
- Partials     4465     4466       +1
Flag Coverage Δ
#Debug 71.24% <82.36%> (ø) ⬆️
#production 67.57% <82.25%> (ø) ⬆️
#test 85.35% <100%> (ø) ⬆️

@TomFinley
Copy link
Contributor

TomFinley commented Jan 31, 2019

Since the goal of this is to refine the public surface, it would be helpful to understand what the public surface now is. Could you post a listing of the public surface? Thanks. #Resolved

@codemzs codemzs changed the title WIP Lockdown Microsoft.ML.TimeSeries public surface Lockdown Microsoft.ML.TimeSeries public surface Feb 4, 2019
@codemzs
Copy link
Member Author

codemzs commented Feb 5, 2019

@TomFinley Below is the new API list:

N:Microsoft.ML.TimeSeries

T:Microsoft.ML.TimeSeries.PredictionFunctionExtensions
M:Microsoft.ML.TimeSeries.PredictionFunctionExtensions.CreateTimeSeriesPredictionFunction``2(Microsoft.ML.Core.Data.ITransformer,Microsoft.ML.IHostEnvironment,System.Boolean,Microsoft.ML.Data.SchemaDefinition,Microsoft.ML.Data.SchemaDefinition)
T:Microsoft.ML.TimeSeries.TimeSeriesPredictionFunction2 M:Microsoft.ML.TimeSeries.TimeSeriesPredictionFunction2.#ctor(Microsoft.ML.IHostEnvironment,Microsoft.ML.Core.Data.ITransformer,System.Boolean,Microsoft.ML.Data.SchemaDefinition,Microsoft.ML.Data.SchemaDefinition)
M:Microsoft.ML.TimeSeries.TimeSeriesPredictionFunction`2.CheckPoint(Microsoft.ML.IHostEnvironment,System.String)
M:Microsoft.ML.TimeSeries.TimeSeriesPredictionFunction`2.Predict(`0,`1@)
N:Microsoft.ML.TimeSeriesProcessing
T:Microsoft.ML.TimeSeriesProcessing.AlertingScore
F:Microsoft.ML.TimeSeriesProcessing.AlertingScore.MartingaleScore
F:Microsoft.ML.TimeSeriesProcessing.AlertingScore.PValueScore
F:Microsoft.ML.TimeSeriesProcessing.AlertingScore.RawScore
F:Microsoft.ML.TimeSeriesProcessing.AlertingScore.value__
T:Microsoft.ML.TimeSeriesProcessing.AnomalySide
F:Microsoft.ML.TimeSeriesProcessing.AnomalySide.Negative
F:Microsoft.ML.TimeSeriesProcessing.AnomalySide.Positive
F:Microsoft.ML.TimeSeriesProcessing.AnomalySide.TwoSided
F:Microsoft.ML.TimeSeriesProcessing.AnomalySide.value__
T:Microsoft.ML.TimeSeriesProcessing.ArgumentsBase
F:Microsoft.ML.TimeSeriesProcessing.ArgumentsBase.AlertOn
F:Microsoft.ML.TimeSeriesProcessing.ArgumentsBase.Side
F:Microsoft.ML.TimeSeriesProcessing.ArgumentsBase.Martingale
F:Microsoft.ML.TimeSeriesProcessing.ArgumentsBase.AlertThreshold
F:Microsoft.ML.TimeSeriesProcessing.ArgumentsBase.PowerMartingaleEpsilon
F:Microsoft.ML.TimeSeriesProcessing.ArgumentsBase.InitialWindowSize
F:Microsoft.ML.TimeSeriesProcessing.ArgumentsBase.WindowSize
F:Microsoft.ML.TimeSeriesProcessing.ArgumentsBase.Name
F:Microsoft.ML.TimeSeriesProcessing.ArgumentsBase.Source
M:Microsoft.ML.TimeSeriesProcessing.ArgumentsBase.#ctor
T:Microsoft.ML.TimeSeriesProcessing.ErrorFunction
F:Microsoft.ML.TimeSeriesProcessing.ErrorFunction.AbsoluteDifference
F:Microsoft.ML.TimeSeriesProcessing.ErrorFunction.AbsoluteProportion
F:Microsoft.ML.TimeSeriesProcessing.ErrorFunction.SignedDifference
F:Microsoft.ML.TimeSeriesProcessing.ErrorFunction.SignedProportion
F:Microsoft.ML.TimeSeriesProcessing.ErrorFunction.SquaredDifference
F:Microsoft.ML.TimeSeriesProcessing.ErrorFunction.value__
T:Microsoft.ML.TimeSeriesProcessing.IidAnomalyDetectionBaseWrapper
M:Microsoft.ML.TimeSeriesProcessing.IidAnomalyDetectionBaseWrapper.#ctor(Microsoft.ML.IHostEnvironment,Microsoft.ML.Model.ModelLoadContext,System.String)
M:Microsoft.ML.TimeSeriesProcessing.IidAnomalyDetectionBaseWrapper.#ctor(Microsoft.ML.TimeSeriesProcessing.ArgumentsBase,System.String,Microsoft.ML.IHostEnvironment)
P:Microsoft.ML.TimeSeriesProcessing.IidAnomalyDetectionBaseWrapper.IsRowToRowMapper
M:Microsoft.ML.TimeSeriesProcessing.IidAnomalyDetectionBaseWrapper.GetOutputSchema(Microsoft.Data.DataView.Schema)
M:Microsoft.ML.TimeSeriesProcessing.IidAnomalyDetectionBaseWrapper.GetRowToRowMapper(Microsoft.Data.DataView.Schema)
M:Microsoft.ML.TimeSeriesProcessing.IidAnomalyDetectionBaseWrapper.GetStatefulRowToRowMapper(Microsoft.Data.DataView.Schema)
M:Microsoft.ML.TimeSeriesProcessing.IidAnomalyDetectionBaseWrapper.get_IsRowToRowMapper
M:Microsoft.ML.TimeSeriesProcessing.IidAnomalyDetectionBaseWrapper.Save(Microsoft.ML.Model.ModelSaveContext)
M:Microsoft.ML.TimeSeriesProcessing.IidAnomalyDetectionBaseWrapper.Transform(Microsoft.Data.DataView.IDataView)
T:Microsoft.ML.TimeSeriesProcessing.IidChangePointDetector
M:Microsoft.ML.TimeSeriesProcessing.IidChangePointDetector.Save(Microsoft.ML.Model.ModelSaveContext)
T:Microsoft.ML.TimeSeriesProcessing.IidChangePointDetector.Arguments
F:Microsoft.ML.TimeSeriesProcessing.IidChangePointDetector.Arguments.Martingale
F:Microsoft.ML.TimeSeriesProcessing.IidChangePointDetector.Arguments.Confidence
F:Microsoft.ML.TimeSeriesProcessing.IidChangePointDetector.Arguments.PowerMartingaleEpsilon
F:Microsoft.ML.TimeSeriesProcessing.IidChangePointDetector.Arguments.ChangeHistoryLength
F:Microsoft.ML.TimeSeriesProcessing.IidChangePointDetector.Arguments.Name
F:Microsoft.ML.TimeSeriesProcessing.IidChangePointDetector.Arguments.Source
M:Microsoft.ML.TimeSeriesProcessing.IidChangePointDetector.Arguments.#ctor
T:Microsoft.ML.TimeSeriesProcessing.IidChangePointEstimator
M:Microsoft.ML.TimeSeriesProcessing.IidChangePointEstimator.#ctor(Microsoft.ML.IHostEnvironment,Microsoft.ML.TimeSeriesProcessing.IidChangePointDetector.Arguments)
M:Microsoft.ML.TimeSeriesProcessing.IidChangePointEstimator.#ctor(Microsoft.ML.IHostEnvironment,System.String,System.Int32,System.Int32,System.String,Microsoft.ML.TimeSeriesProcessing.MartingaleType,System.Double)
M:Microsoft.ML.TimeSeriesProcessing.IidChangePointEstimator.GetOutputSchema(Microsoft.ML.Core.Data.SchemaShape)
T:Microsoft.ML.TimeSeriesProcessing.IidSpikeDetector
M:Microsoft.ML.TimeSeriesProcessing.IidSpikeDetector.#ctor(Microsoft.ML.IHostEnvironment,Microsoft.ML.Model.ModelLoadContext)
M:Microsoft.ML.TimeSeriesProcessing.IidSpikeDetector.Save(Microsoft.ML.Model.ModelSaveContext)
T:Microsoft.ML.TimeSeriesProcessing.IidSpikeDetector.Arguments
F:Microsoft.ML.TimeSeriesProcessing.IidSpikeDetector.Arguments.Side
F:Microsoft.ML.TimeSeriesProcessing.IidSpikeDetector.Arguments.Confidence
F:Microsoft.ML.TimeSeriesProcessing.IidSpikeDetector.Arguments.PvalueHistoryLength
F:Microsoft.ML.TimeSeriesProcessing.IidSpikeDetector.Arguments.Name
F:Microsoft.ML.TimeSeriesProcessing.IidSpikeDetector.Arguments.Source
M:Microsoft.ML.TimeSeriesProcessing.IidSpikeDetector.Arguments.#ctor
T:Microsoft.ML.TimeSeriesProcessing.IidSpikeEstimator
M:Microsoft.ML.TimeSeriesProcessing.IidSpikeEstimator.#ctor(Microsoft.ML.IHostEnvironment,Microsoft.ML.TimeSeriesProcessing.IidSpikeDetector.Arguments)
M:Microsoft.ML.TimeSeriesProcessing.IidSpikeEstimator.#ctor(Microsoft.ML.IHostEnvironment,System.String,System.Int32,System.Int32,System.String,Microsoft.ML.TimeSeriesProcessing.AnomalySide)
M:Microsoft.ML.TimeSeriesProcessing.IidSpikeEstimator.GetOutputSchema(Microsoft.ML.Core.Data.SchemaShape)
T:Microsoft.ML.TimeSeriesProcessing.MartingaleType
F:Microsoft.ML.TimeSeriesProcessing.MartingaleType.Mixture
F:Microsoft.ML.TimeSeriesProcessing.MartingaleType.None
F:Microsoft.ML.TimeSeriesProcessing.MartingaleType.Power
F:Microsoft.ML.TimeSeriesProcessing.MartingaleType.value__
T:Microsoft.ML.TimeSeriesProcessing.SequenceModelerBase`2
M:Microsoft.ML.TimeSeriesProcessing.SequenceModelerBase`2.Save(Microsoft.ML.Model.ModelSaveContext)
T:Microsoft.ML.TimeSeriesProcessing.SsaAnomalyDetectionBaseWrapper
M:Microsoft.ML.TimeSeriesProcessing.SsaAnomalyDetectionBaseWrapper.#ctor(Microsoft.ML.IHostEnvironment,Microsoft.ML.Model.ModelLoadContext,System.String)
M:Microsoft.ML.TimeSeriesProcessing.SsaAnomalyDetectionBaseWrapper.#ctor(Microsoft.ML.TimeSeriesProcessing.SsaAnomalyDetectionBaseWrapper.SsaArguments,System.String,Microsoft.ML.IHostEnvironment)
P:Microsoft.ML.TimeSeriesProcessing.SsaAnomalyDetectionBaseWrapper.IsRowToRowMapper
M:Microsoft.ML.TimeSeriesProcessing.SsaAnomalyDetectionBaseWrapper.GetOutputSchema(Microsoft.Data.DataView.Schema)
M:Microsoft.ML.TimeSeriesProcessing.SsaAnomalyDetectionBaseWrapper.GetRowToRowMapper(Microsoft.Data.DataView.Schema)
M:Microsoft.ML.TimeSeriesProcessing.SsaAnomalyDetectionBaseWrapper.GetStatefulRowToRowMapper(Microsoft.Data.DataView.Schema)
M:Microsoft.ML.TimeSeriesProcessing.SsaAnomalyDetectionBaseWrapper.get_IsRowToRowMapper
M:Microsoft.ML.TimeSeriesProcessing.SsaAnomalyDetectionBaseWrapper.Save(Microsoft.ML.Model.ModelSaveContext)
M:Microsoft.ML.TimeSeriesProcessing.SsaAnomalyDetectionBaseWrapper.Transform(Microsoft.Data.DataView.IDataView)
T:Microsoft.ML.TimeSeriesProcessing.SsaAnomalyDetectionBaseWrapper.SsaArguments
F:Microsoft.ML.TimeSeriesProcessing.SsaAnomalyDetectionBaseWrapper.SsaArguments.ErrorFunction
F:Microsoft.ML.TimeSeriesProcessing.SsaAnomalyDetectionBaseWrapper.SsaArguments.IsAdaptive
F:Microsoft.ML.TimeSeriesProcessing.SsaAnomalyDetectionBaseWrapper.SsaArguments.SeasonalWindowSize
F:Microsoft.ML.TimeSeriesProcessing.SsaAnomalyDetectionBaseWrapper.SsaArguments.DiscountFactor
M:Microsoft.ML.TimeSeriesProcessing.SsaAnomalyDetectionBaseWrapper.SsaArguments.#ctor
T:Microsoft.ML.TimeSeriesProcessing.SsaChangePointDetector
M:Microsoft.ML.TimeSeriesProcessing.SsaChangePointDetector.Save(Microsoft.ML.Model.ModelSaveContext)
T:Microsoft.ML.TimeSeriesProcessing.SsaChangePointDetector.Arguments
F:Microsoft.ML.TimeSeriesProcessing.SsaChangePointDetector.Arguments.ErrorFunction
F:Microsoft.ML.TimeSeriesProcessing.SsaChangePointDetector.Arguments.Martingale
F:Microsoft.ML.TimeSeriesProcessing.SsaChangePointDetector.Arguments.Confidence
F:Microsoft.ML.TimeSeriesProcessing.SsaChangePointDetector.Arguments.PowerMartingaleEpsilon
F:Microsoft.ML.TimeSeriesProcessing.SsaChangePointDetector.Arguments.ChangeHistoryLength
F:Microsoft.ML.TimeSeriesProcessing.SsaChangePointDetector.Arguments.SeasonalWindowSize
F:Microsoft.ML.TimeSeriesProcessing.SsaChangePointDetector.Arguments.TrainingWindowSize
F:Microsoft.ML.TimeSeriesProcessing.SsaChangePointDetector.Arguments.Name
F:Microsoft.ML.TimeSeriesProcessing.SsaChangePointDetector.Arguments.Source
M:Microsoft.ML.TimeSeriesProcessing.SsaChangePointDetector.Arguments.#ctor
T:Microsoft.ML.TimeSeriesProcessing.SsaChangePointEstimator
M:Microsoft.ML.TimeSeriesProcessing.SsaChangePointEstimator.#ctor(Microsoft.ML.IHostEnvironment,Microsoft.ML.TimeSeriesProcessing.SsaChangePointDetector.Arguments)
M:Microsoft.ML.TimeSeriesProcessing.SsaChangePointEstimator.#ctor(Microsoft.ML.IHostEnvironment,System.String,System.Int32,System.Int32,System.Int32,System.Int32,System.String,Microsoft.ML.TimeSeriesProcessing.ErrorFunction,Microsoft.ML.TimeSeriesProcessing.MartingaleType,System.Double)
M:Microsoft.ML.TimeSeriesProcessing.SsaChangePointEstimator.Fit(Microsoft.Data.DataView.IDataView)
M:Microsoft.ML.TimeSeriesProcessing.SsaChangePointEstimator.GetOutputSchema(Microsoft.ML.Core.Data.SchemaShape)
T:Microsoft.ML.TimeSeriesProcessing.SsaSpikeDetector
M:Microsoft.ML.TimeSeriesProcessing.SsaSpikeDetector.Save(Microsoft.ML.Model.ModelSaveContext)
T:Microsoft.ML.TimeSeriesProcessing.SsaSpikeDetector.Arguments
F:Microsoft.ML.TimeSeriesProcessing.SsaSpikeDetector.Arguments.Side
F:Microsoft.ML.TimeSeriesProcessing.SsaSpikeDetector.Arguments.ErrorFunction
F:Microsoft.ML.TimeSeriesProcessing.SsaSpikeDetector.Arguments.Confidence
F:Microsoft.ML.TimeSeriesProcessing.SsaSpikeDetector.Arguments.PvalueHistoryLength
F:Microsoft.ML.TimeSeriesProcessing.SsaSpikeDetector.Arguments.SeasonalWindowSize
F:Microsoft.ML.TimeSeriesProcessing.SsaSpikeDetector.Arguments.TrainingWindowSize
F:Microsoft.ML.TimeSeriesProcessing.SsaSpikeDetector.Arguments.Name
F:Microsoft.ML.TimeSeriesProcessing.SsaSpikeDetector.Arguments.Source
M:Microsoft.ML.TimeSeriesProcessing.SsaSpikeDetector.Arguments.#ctor
T:Microsoft.ML.TimeSeriesProcessing.SsaSpikeEstimator
M:Microsoft.ML.TimeSeriesProcessing.SsaSpikeEstimator.#ctor(Microsoft.ML.IHostEnvironment,Microsoft.ML.TimeSeriesProcessing.SsaSpikeDetector.Arguments)
M:Microsoft.ML.TimeSeriesProcessing.SsaSpikeEstimator.#ctor(Microsoft.ML.IHostEnvironment,System.String,System.Int32,System.Int32,System.Int32,System.Int32,System.String,Microsoft.ML.TimeSeriesProcessing.AnomalySide,Microsoft.ML.TimeSeriesProcessing.ErrorFunction)
M:Microsoft.ML.TimeSeriesProcessing.SsaSpikeEstimator.Fit(Microsoft.Data.DataView.IDataView)
M:Microsoft.ML.TimeSeriesProcessing.SsaSpikeEstimator.GetOutputSchema(Microsoft.ML.Core.Data.SchemaShape)

#Resolved

@artidoro
Copy link
Contributor

artidoro commented Feb 5, 2019

    public override SchemaShape GetOutputSchema(SchemaShape inputSchema)

Can you add:

    /// <summary>
    /// Returns the <see cref="SchemaShape"/> of the schema which will be produced by the transformer.
    /// Used for schema propagation and verification in a pipeline.
    /// </summary> #Resolved

Refers to: src/Microsoft.ML.TimeSeries/IidChangePointDetector.cs:242 in b81ef6c. [](commit_id = b81ef6c, deletion_comment = False)

@artidoro
Copy link
Contributor

artidoro commented Feb 5, 2019

    public IidChangePointEstimator(IHostEnvironment env, string outputColumnName, int confidence,

Can you make these constructors internal, and allow to create this estimator only through MLContext? #Resolved


Refers to: src/Microsoft.ML.TimeSeries/IidChangePointDetector.cs:221 in b81ef6c. [](commit_id = b81ef6c, deletion_comment = False)

@artidoro
Copy link
Contributor

artidoro commented Feb 5, 2019

    public IidSpikeEstimator(IHostEnvironment env, string outputColumnName, int confidence, int pvalueHistoryLength, string inputColumnName, AnomalySide side = AnomalySide.TwoSided)

Same comment here. You can actually make the constructors internal and only allow them to be created from MLContext. #Resolved


Refers to: src/Microsoft.ML.TimeSeries/IidSpikeDetector.cs:199 in b81ef6c. [](commit_id = b81ef6c, deletion_comment = False)

@artidoro
Copy link
Contributor

artidoro commented Feb 5, 2019

    public TimeSeriesPredictionFunction(IHostEnvironment env, ITransformer transformer, bool ignoreMissingColumns,

Could you a summary comment for what is public? #Resolved


Refers to: src/Microsoft.ML.TimeSeries/PredictionFunction.cs:93 in b81ef6c. [](commit_id = b81ef6c, deletion_comment = False)

@artidoro
Copy link
Contributor

artidoro commented Feb 5, 2019

    public SsaChangePointEstimator(IHostEnvironment env, string outputColumnName,

These constructors here too should be made internal. #Resolved


Refers to: src/Microsoft.ML.TimeSeries/SsaChangePointDetector.cs:237 in b81ef6c. [](commit_id = b81ef6c, deletion_comment = False)

@artidoro
Copy link
Contributor

artidoro commented Feb 5, 2019

    public SsaSpikeEstimator(IHostEnvironment env,

Same here #Resolved


Refers to: src/Microsoft.ML.TimeSeries/SsaSpikeDetector.cs:217 in b81ef6c. [](commit_id = b81ef6c, deletion_comment = False)

@codemzs codemzs requested a review from wschin February 6, 2019 22:11
@@ -146,7 +146,7 @@ public abstract class PredictionEngineBase<TSrc, TDst> : IDisposable
disposer = inputRow.Dispose;
}

protected virtual Func<Schema, IRowToRowMapper> TransformerChecker(IExceptionContext ectx, ITransformer transformer)
internal virtual Func<Schema, IRowToRowMapper> TransformerChecker(IExceptionContext ectx, ITransformer transformer)
Copy link
Member

@wschin wschin Feb 6, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

private protected? #Resolved

Copy link
Member Author

@codemzs codemzs Feb 6, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, what is the added benefit for pp? #Resolved

@@ -60,11 +58,11 @@ private sealed class Reconciler : EstimatorReconciler
{
Contracts.Assert(toOutput.Length == 1);
var outCol = (OutColumn)toOutput[0];
return new IidChangePointEstimator(env,
return new MLContext().Transforms.IidChangePointEstimator(
Copy link
Member

@wschin wschin Feb 6, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if we should reuse the env passed in. This new MLContext() is also a kind of environment. #WontFix

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't use env. MLContext implements env.


In reply to: 254475845 [](ancestors = 254475845)


public Schema GetOutputSchema(Schema inputSchema) => Base.GetOutputSchema(inputSchema);

public IRowToRowMapper GetRowToRowMapper(Schema inputSchema) => Base.GetRowToRowMapper(inputSchema);
Copy link
Member

@wschin wschin Feb 6, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to expose this function to users? If not, maybe consider explicit interface implementation?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, I agree that it is a bit confusing, I might consider doing what I am doing with ICanSaveModel, and explicit implement the interface for these methods, but it should be done in another PR, and further discussed.


In reply to: 254477452 [](ancestors = 254477452)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, this needs to be its own change since it require creating and implementing a new interface.


In reply to: 254485970 [](ancestors = 254485970,254477452)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please open an issue?


In reply to: 255151564 [](ancestors = 255151564,254485970,254477452)

{
public const string Summary = "Applies a Exponential average on a time series.";
public const string LoaderSignature = "ExpAverageTransform";
public const string UserName = "Exponential Average Transform";
public const string ShortName = "ExpAvg";

#pragma warning disable 0649
public sealed class Arguments : TransformInputBase
Copy link
Contributor

@artidoro artidoro Feb 6, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need this? #Resolved

Copy link
Member Author

@codemzs codemzs Feb 6, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will warn for variable not initialized error. This pattern is used across the codebase #Resolved

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did we not need it before?


In reply to: 254478686 [](ancestors = 254478686)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it has to do with making the class internal.


In reply to: 254483842 [](ancestors = 254483842,254478686)

StateRef = new State();
StateRef.InitState(WindowSize, InitialWindowSize, this, Host);
}
public bool IsRowToRowMapper => Base.IsRowToRowMapper;
Copy link
Member

@wschin wschin Feb 6, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to expose this function to users? Maybe internal-best-friend it? #ByDesign

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it comes from the IStatefulTransformer, so it has to be public.


In reply to: 254477753 [](ancestors = 254477753)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It comes from ITransformer which is public.


In reply to: 254485421 [](ancestors = 254485421,254477753)


public IRowToRowMapper GetRowToRowMapper(Schema inputSchema) => Base.GetRowToRowMapper(inputSchema);

public IRowToRowMapper GetStatefulRowToRowMapper(Schema inputSchema) => ((IStatefulTransformer)Base).GetStatefulRowToRowMapper(inputSchema);
Copy link
Member

@wschin wschin Feb 6, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly, I am not sure this method is good for being exposed. Could you take a look at other public attributes and functions in this class? I am definitely not the durid (which is @TomFinley) who can judge which function should be public or not, so feel free to blame me for stupid questions. #WontFix

@@ -82,11 +82,29 @@ public static Double SquaredDifference(Double actual, Double predicted)
}

/// <summary>
/// This base class that implements the general anomaly detection transform based on Singular Spectrum modeling of the time-series.
/// The wrapper to the base class that implements the general anomaly detection transform based on Singular Spectrum modeling of the time-series.
Copy link
Member

@wschin wschin Feb 6, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you use <see cref=> to reference the base class? #Resolved

StateRef = new State();
StateRef.InitState(WindowSize, InitialWindowSize, this, Host);
}
public SsaAnomalyDetectionBaseWrapper(SsaArguments args, string name, IHostEnvironment env) { Base = new SsaAnomalyDetectionBase(args, name, env, this); }
Copy link
Contributor

@artidoro artidoro Feb 6, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SsaAnomalyDetectionBaseWrapper [](start = 15, length = 30)

If this is a base class, and users don't need to instantiate it can we make the two constructors internal? #Resolved

internal IStatefulRowMapper MakeRowMapper(Schema schema) => Base.MakeRowMapper(schema);

internal IDataTransform MakeDataTransform(IDataView input) => Base.MakeDataTransform(input);

public abstract class SsaArguments : ArgumentsBase
Copy link
Contributor

@artidoro artidoro Feb 6, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SsaArguments [](start = 30, length = 12)

Can you rename them to SsaOptions? and also rename local variables to options
If the arguments are not used in other places can we make them internal? #Resolved

@artidoro
Copy link
Contributor

artidoro commented Feb 6, 2019

    {

Can you add the usual xml? #Resolved


Refers to: src/Microsoft.ML.TimeSeries/SsaChangePointDetector.cs:279 in 23fefa4. [](commit_id = 23fefa4, deletion_comment = False)

@artidoro
Copy link
Contributor

artidoro commented Feb 6, 2019

    {

Can you add the usual xml? #Resolved


Refers to: src/Microsoft.ML.TimeSeries/SsaChangePointDetector.cs:273 in 23fefa4. [](commit_id = 23fefa4, deletion_comment = False)

@artidoro
Copy link
Contributor

artidoro commented Feb 6, 2019

    {

Same here, and in the above Fit() #ByDesign


Refers to: src/Microsoft.ML.TimeSeries/SsaSpikeDetector.cs:258 in 23fefa4. [](commit_id = 23fefa4, deletion_comment = False)

@codemzs
Copy link
Member Author

codemzs commented Feb 8, 2019

New API surface:

ID

N:Microsoft.ML
T:Microsoft.ML.TimeSeriesCatalog
M:Microsoft.ML.TimeSeriesCatalog.IidChangePointEstimator(Microsoft.ML.TransformsCatalog,System.String,System.String,System.Int32,System.Int32,Microsoft.ML.TimeSeriesProcessing.MartingaleType,System.Double)
M:Microsoft.ML.TimeSeriesCatalog.IidSpikeEstimator(Microsoft.ML.TransformsCatalog,System.String,System.String,System.Int32,System.Int32,Microsoft.ML.TimeSeriesProcessing.AnomalySide)
M:Microsoft.ML.TimeSeriesCatalog.SsaChangePointEstimator(Microsoft.ML.TransformsCatalog,System.String,System.String,System.Int32,System.Int32,System.Int32,System.Int32,Microsoft.ML.TimeSeriesProcessing.ErrorFunction,Microsoft.ML.TimeSeriesProcessing.MartingaleType,System.Double)
M:Microsoft.ML.TimeSeriesCatalog.SsaSpikeEstimator(Microsoft.ML.TransformsCatalog,System.String,System.String,System.Int32,System.Int32,System.Int32,System.Int32,Microsoft.ML.TimeSeriesProcessing.AnomalySide,Microsoft.ML.TimeSeriesProcessing.ErrorFunction)
N:Microsoft.ML.TimeSeries
T:Microsoft.ML.TimeSeries.PredictionFunctionExtensions
M:Microsoft.ML.TimeSeries.PredictionFunctionExtensions.CreateTimeSeriesPredictionFunction``2(Microsoft.ML.Core.Data.ITransformer,Microsoft.ML.IHostEnvironment,System.Boolean,Microsoft.ML.Data.SchemaDefinition,Microsoft.ML.Data.SchemaDefinition)
T:Microsoft.ML.TimeSeries.TimeSeriesPredictionFunction2 M:Microsoft.ML.TimeSeries.TimeSeriesPredictionFunction2.#ctor(Microsoft.ML.IHostEnvironment,Microsoft.ML.Core.Data.ITransformer,System.Boolean,Microsoft.ML.Data.SchemaDefinition,Microsoft.ML.Data.SchemaDefinition)
M:Microsoft.ML.TimeSeries.TimeSeriesPredictionFunction`2.CheckPoint(Microsoft.ML.IHostEnvironment,System.String)
M:Microsoft.ML.TimeSeries.TimeSeriesPredictionFunction`2.Predict(`0,`1@)
N:Microsoft.ML.TimeSeriesProcessing
T:Microsoft.ML.TimeSeriesProcessing.AnomalySide
F:Microsoft.ML.TimeSeriesProcessing.AnomalySide.Negative
F:Microsoft.ML.TimeSeriesProcessing.AnomalySide.Positive
F:Microsoft.ML.TimeSeriesProcessing.AnomalySide.TwoSided
F:Microsoft.ML.TimeSeriesProcessing.AnomalySide.value__
T:Microsoft.ML.TimeSeriesProcessing.ErrorFunction
F:Microsoft.ML.TimeSeriesProcessing.ErrorFunction.AbsoluteDifference
F:Microsoft.ML.TimeSeriesProcessing.ErrorFunction.AbsoluteProportion
F:Microsoft.ML.TimeSeriesProcessing.ErrorFunction.SignedDifference
F:Microsoft.ML.TimeSeriesProcessing.ErrorFunction.SignedProportion
F:Microsoft.ML.TimeSeriesProcessing.ErrorFunction.SquaredDifference
F:Microsoft.ML.TimeSeriesProcessing.ErrorFunction.value__
T:Microsoft.ML.TimeSeriesProcessing.IidAnomalyDetectionBaseWrapper
P:Microsoft.ML.TimeSeriesProcessing.IidAnomalyDetectionBaseWrapper.IsRowToRowMapper
M:Microsoft.ML.TimeSeriesProcessing.IidAnomalyDetectionBaseWrapper.GetOutputSchema(Microsoft.Data.DataView.Schema)
M:Microsoft.ML.TimeSeriesProcessing.IidAnomalyDetectionBaseWrapper.GetRowToRowMapper(Microsoft.Data.DataView.Schema)
M:Microsoft.ML.TimeSeriesProcessing.IidAnomalyDetectionBaseWrapper.GetStatefulRowToRowMapper(Microsoft.Data.DataView.Schema)
M:Microsoft.ML.TimeSeriesProcessing.IidAnomalyDetectionBaseWrapper.get_IsRowToRowMapper
M:Microsoft.ML.TimeSeriesProcessing.IidAnomalyDetectionBaseWrapper.Save(Microsoft.ML.Model.ModelSaveContext)
M:Microsoft.ML.TimeSeriesProcessing.IidAnomalyDetectionBaseWrapper.Transform(Microsoft.Data.DataView.IDataView)
T:Microsoft.ML.TimeSeriesProcessing.IidChangePointDetector
M:Microsoft.ML.TimeSeriesProcessing.IidChangePointDetector.Save(Microsoft.ML.Model.ModelSaveContext)
T:Microsoft.ML.TimeSeriesProcessing.IidChangePointEstimator
M:Microsoft.ML.TimeSeriesProcessing.IidChangePointEstimator.GetOutputSchema(Microsoft.ML.Core.Data.SchemaShape)
T:Microsoft.ML.TimeSeriesProcessing.IidSpikeDetector
M:Microsoft.ML.TimeSeriesProcessing.IidSpikeDetector.#ctor(Microsoft.ML.IHostEnvironment,Microsoft.ML.Model.ModelLoadContext)
M:Microsoft.ML.TimeSeriesProcessing.IidSpikeDetector.Save(Microsoft.ML.Model.ModelSaveContext)
T:Microsoft.ML.TimeSeriesProcessing.IidSpikeEstimator
M:Microsoft.ML.TimeSeriesProcessing.IidSpikeEstimator.GetOutputSchema(Microsoft.ML.Core.Data.SchemaShape)
T:Microsoft.ML.TimeSeriesProcessing.MartingaleType
F:Microsoft.ML.TimeSeriesProcessing.MartingaleType.Mixture
F:Microsoft.ML.TimeSeriesProcessing.MartingaleType.None
F:Microsoft.ML.TimeSeriesProcessing.MartingaleType.Power
F:Microsoft.ML.TimeSeriesProcessing.MartingaleType.value__
T:Microsoft.ML.TimeSeriesProcessing.SsaAnomalyDetectionBaseWrapper
P:Microsoft.ML.TimeSeriesProcessing.SsaAnomalyDetectionBaseWrapper.IsRowToRowMapper
M:Microsoft.ML.TimeSeriesProcessing.SsaAnomalyDetectionBaseWrapper.GetOutputSchema(Microsoft.Data.DataView.Schema)
M:Microsoft.ML.TimeSeriesProcessing.SsaAnomalyDetectionBaseWrapper.GetRowToRowMapper(Microsoft.Data.DataView.Schema)
M:Microsoft.ML.TimeSeriesProcessing.SsaAnomalyDetectionBaseWrapper.GetStatefulRowToRowMapper(Microsoft.Data.DataView.Schema)
M:Microsoft.ML.TimeSeriesProcessing.SsaAnomalyDetectionBaseWrapper.get_IsRowToRowMapper
M:Microsoft.ML.TimeSeriesProcessing.SsaAnomalyDetectionBaseWrapper.Save(Microsoft.ML.Model.ModelSaveContext)
M:Microsoft.ML.TimeSeriesProcessing.SsaAnomalyDetectionBaseWrapper.Transform(Microsoft.Data.DataView.IDataView)
T:Microsoft.ML.TimeSeriesProcessing.SsaChangePointDetector
M:Microsoft.ML.TimeSeriesProcessing.SsaChangePointDetector.Save(Microsoft.ML.Model.ModelSaveContext)
T:Microsoft.ML.TimeSeriesProcessing.SsaChangePointEstimator
M:Microsoft.ML.TimeSeriesProcessing.SsaChangePointEstimator.Fit(Microsoft.Data.DataView.IDataView)
M:Microsoft.ML.TimeSeriesProcessing.SsaChangePointEstimator.GetOutputSchema(Microsoft.ML.Core.Data.SchemaShape)
T:Microsoft.ML.TimeSeriesProcessing.SsaSpikeDetector
M:Microsoft.ML.TimeSeriesProcessing.SsaSpikeDetector.Save(Microsoft.ML.Model.ModelSaveContext)
T:Microsoft.ML.TimeSeriesProcessing.SsaSpikeEstimator
M:Microsoft.ML.TimeSeriesProcessing.SsaSpikeEstimator.Fit(Microsoft.Data.DataView.IDataView)
M:Microsoft.ML.TimeSeriesProcessing.SsaSpikeEstimator.GetOutputSchema(Microsoft.ML.Core.Data.SchemaShape)

#Resolved

@artidoro
Copy link
Contributor

artidoro commented Feb 9, 2019

        : base(env, ctx, LoaderSignature)

Can you make this internal? #Resolved


Refers to: src/Microsoft.ML.TimeSeries/IidSpikeDetector.cs:145 in e11cf53. [](commit_id = e11cf53, deletion_comment = False)

Copy link
Contributor

@artidoro artidoro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still have a few minor comments, but this is great work @codemzs!

@@ -98,7 +98,7 @@ private static VersionInfo GetVersionInfo()
}

// Factory method for SignatureDataTransform.
private static IDataTransform Create(IHostEnvironment env, Arguments args, IDataView input)
private static IDataTransform Create(IHostEnvironment env, Options args, IDataView input)
Copy link
Contributor

@artidoro artidoro Feb 9, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you rename to options? #Resolved

@@ -258,38 +258,45 @@ public sealed class SsaChangePointEstimator : IEstimator<SsaChangePointDetector>
{
}

public SsaChangePointEstimator(IHostEnvironment env, SsaChangePointDetector.Arguments args)
internal SsaChangePointEstimator(IHostEnvironment env, SsaChangePointDetector.Options args)
Copy link
Contributor

@artidoro artidoro Feb 9, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, if you could rename to options that would be great. #Resolved

@@ -237,38 +237,45 @@ public sealed class SsaSpikeEstimator : IEstimator<SsaSpikeDetector>
{
}

public SsaSpikeEstimator(IHostEnvironment env, SsaSpikeDetector.Arguments args)
internal SsaSpikeEstimator(IHostEnvironment env, SsaSpikeDetector.Options args)
Copy link
Contributor

@artidoro artidoro Feb 9, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here if you could rename args to options. #Resolved

@@ -148,7 +147,7 @@ public IidSpikeDetector(IHostEnvironment env, ModelLoadContext ctx)
// *** Binary format ***
// <base>

Host.CheckDecode(ThresholdScore == AlertingScore.PValueScore);
InternalTransform.Host.CheckDecode(InternalTransform.ThresholdScore == AlertingScore.PValueScore);
}
private IidSpikeDetector(IHostEnvironment env, IidSpikeDetector transform)
: base(new BaseArguments(transform), LoaderSignature, env)
Copy link
Contributor

@artidoro artidoro Feb 9, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And since you are at it, why don't you add a line before this method. #Resolved

@@ -61,7 +63,7 @@ public abstract class StateBase
/// </summary>
protected long RowCounter { get; private set; }

private protected StateBase()
public StateBase()
{
Copy link
Contributor

@artidoro artidoro Feb 9, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we even need this constructor? #Resolved

/// <param name="outputColumnName">Name of the column resulting from the transformation of <paramref name="inputColumnName"/>.
/// <param name="inputColumnName">Name of column to transform. If set to <see langword="null"/>, the value of the <paramref name="outputColumnName"/> will be used as source.</param>
/// Column is a vector of type double and size 4. The vector contains Alert, Raw Score, P-Value as first three values.</param>
/// <param name="confidence">The confidence for spike detection in the range [0, 100].</param>
Copy link
Contributor

@artidoro artidoro Feb 9, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this supposed to qualify the outputColumnName? #Resolved

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sorry but can you please clarify?


In reply to: 255283542 [](ancestors = 255283542)

@artidoro
Copy link
Contributor

artidoro commented Feb 9, 2019

Also, just wanted to make sure that we need to expose the following directly rather than through MLContext. I am not too familiar with the predictionengine/predictionfunction that's why I am just pointing out for you to double check:


T:Microsoft.ML.TimeSeries.PredictionFunctionExtensions
M:Microsoft.ML.TimeSeries.PredictionFunctionExtensions.CreateTimeSeriesPredictionFunction``2(Microsoft.ML.Core.Data.ITransformer,Microsoft.ML.IHostEnvironment,System.Boolean,Microsoft.ML.Data.SchemaDefinition,Microsoft.ML.Data.SchemaDefinition)
T:Microsoft.ML.TimeSeries.TimeSeriesPredictionFunction`2 M:Microsoft.ML.TimeSeries.TimeSeriesPredictionFunction`2.#ctor(Microsoft.ML.IHostEnvironment,Microsoft.ML.Core.Data.ITransformer,System.Boolean,Microsoft.ML.Data.SchemaDefinition,Microsoft.ML.Data.SchemaDefinition)
M:Microsoft.ML.TimeSeries.TimeSeriesPredictionFunction`2.CheckPoint(Microsoft.ML.IHostEnvironment,System.String)

``` #Resolved

@codemzs
Copy link
Member Author

codemzs commented Feb 10, 2019

These are exposed directly as extension methods for ITransformer, not through ML Context.


In reply to: 462005919 [](ancestors = 462005919)

Copy link
Member

@wschin wschin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚢 on its way.

@codemzs codemzs merged commit 069abb7 into dotnet:master Feb 11, 2019
@ghost ghost locked as resolved and limited conversation to collaborators Mar 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Lockdown Microsoft.ML.TimeSeries public surface
4 participants