diff --git a/src/Microsoft.ML/LearningPipeline.cs b/src/Microsoft.ML/LearningPipeline.cs index 0ece3697a..8056d0341 100644 --- a/src/Microsoft.ML/LearningPipeline.cs +++ b/src/Microsoft.ML/LearningPipeline.cs @@ -26,25 +26,113 @@ namespace Microsoft.ML public Var Model { get; } } + + /// + /// The class is used to define the steps needed to perform a desired machine learning task. + /// The steps are defined by adding a data loader (e.g. ) followed by zero or more transforms (e.g. ) + /// and at most one trainer/learner (e.g. ) in the pipeline. + /// + /// + /// + /// + /// For example, + /// + /// var pipeline = new LearningPipeline(); + /// pipeline.Add(new TextLoader <SentimentData> (dataPath, separator: ",")); + /// pipeline.Add(new TextFeaturizer("Features", "SentimentText")); + /// pipeline.Add(new FastTreeBinaryClassifier()); + /// + /// var model = pipeline.Train<SentimentData, SentimentPrediction>(); + /// + /// [DebuggerTypeProxy(typeof(LearningPipelineDebugProxy))] public class LearningPipeline : ICollection { private List Items { get; } = new List(); + /// + /// Construct an empty object. + /// public LearningPipeline() { } + /// + /// Get the count of ML components in the object + /// public int Count => Items.Count; public bool IsReadOnly => false; + + /// + /// Add a data loader, transform or trainer into the pipeline. + /// Possible data loader(s), transforms and trainers options are + /// + /// Data Loader: + /// + /// etc. + /// + /// + /// Transforms: + /// , + /// + /// , + /// , + /// , + /// , + /// etc. + /// + /// + /// Trainers: + /// , + /// , + /// , + /// , + /// etc. + /// + /// For a complete list of transforms and trainers, please see "Microsoft.ML.Transforms" and "Microsoft.ML.Trainers" namespaces. + /// + /// Any ML component (data loader, transform or trainer) defined as . public void Add(ILearningPipelineItem item) => Items.Add(item); + + /// + /// Remove all the loaders/transforms/trainers from the pipeline. + /// public void Clear() => Items.Clear(); + + /// + /// Check if a specific loader/transform/trainer is in the pipeline? + /// + /// Any ML component (data loader, transform or trainer) defined as . + /// true if item is found in the pipeline; otherwise, false. public bool Contains(ILearningPipelineItem item) => Items.Contains(item); + + /// + /// Copy the pipeline items into an array. + /// + /// The one-dimensional Array that is the destination of the elements copied from. + /// The zero-based index in at which copying begins. public void CopyTo(ILearningPipelineItem[] array, int arrayIndex) => Items.CopyTo(array, arrayIndex); public IEnumerator GetEnumerator() => Items.GetEnumerator(); + + /// + /// Remove an item from the pipeline. + /// + /// to remove. + /// true if item was removed from the pipeline; otherwise, false. public bool Remove(ILearningPipelineItem item) => Items.Remove(item); IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); + /// + /// Train the model using the ML components in the pipeline. + /// + /// Type of data instances the model will be trained on. It's a custom type defined by the user according to the structure of data. + /// + /// Please see https://www.microsoft.com/net/learn/apps/machine-learning-and-ai/ml-dotnet/get-started/windows for more details on input type. + /// + /// Ouput type. The prediction will be return based on this type. + /// Please see https://www.microsoft.com/net/learn/apps/machine-learning-and-ai/ml-dotnet/get-started/windows for more details on output type. + /// + /// PredictionModel object. This is the model object used for prediction on new instances. public PredictionModel Train() where TInput : class where TOutput : class, new()