-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Comments added to LearningPipeline class to make Intellisense more helpful. #50
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
Changes from 9 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
d80ade9
Merge pull request #1 from dotnet/master
zeahmed 7856abd
Comments added to LearningPipeline class in accordance with #Bug 2406…
zeahmed d090170
Merge branch 'master' into comments_learningpipeline
zeahmed 77d21ff
Comments added to LearningPipeline class in accordance with #Bug 2406…
zeahmed 5471ed1
Fixed a typo in namespace
zeahmed 203d9fe
Merge branch 'master' of https://github.com/zeahmed/machinelearning
zeahmed 5c67672
Merge branch 'master' into comments_learningpipeline
zeahmed 98fc8d0
Addressed reviewers' comments.
zeahmed e7dc707
Addressed reviewers' comments.
zeahmed 5089e98
Addressed reviewers' comments.
zeahmed File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
---|---|---|
|
@@ -26,25 +26,113 @@ public ScorerPipelineStep(Var<IDataView> data, Var<ITransformModel> model) | |
public Var<ITransformModel> Model { get; } | ||
} | ||
|
||
|
||
/// <summary> | ||
/// <see cref="LearningPipeline"/> class is used to define the steps needed to perform a desired machine learning task.<para/> | ||
/// The steps are defined by adding a data loader (e.g. <see cref="TextLoader"/>) followed by zero or more transforms (e.g. <see cref="Microsoft.ML.Transforms.TextFeaturizer"/>) | ||
/// and at most one trainer/learner (e.g. <see cref="Microsoft.ML.Trainers.FastTreeBinaryClassifier"/>) in the pipeline. | ||
/// | ||
/// </summary> | ||
/// <example> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/xmldoc/example it shows that |
||
/// <para/> | ||
/// For example,<para/> | ||
/// <code> | ||
/// 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>(); | ||
/// </code> | ||
/// </example> | ||
[DebuggerTypeProxy(typeof(LearningPipelineDebugProxy))] | ||
public class LearningPipeline : ICollection<ILearningPipelineItem> | ||
{ | ||
private List<ILearningPipelineItem> Items { get; } = new List<ILearningPipelineItem>(); | ||
|
||
/// <summary> | ||
/// Construct an empty <see cref="LearningPipeline"/> object. | ||
/// </summary> | ||
public LearningPipeline() | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Get the count of ML components in the <see cref="LearningPipeline"/> object | ||
/// </summary> | ||
public int Count => Items.Count; | ||
public bool IsReadOnly => false; | ||
|
||
/// <summary> | ||
/// Add a data loader, transform or trainer into the pipeline. | ||
/// Possible data loader(s), transforms and trainers options are | ||
/// <para> | ||
/// Data Loader: | ||
/// <see cref="Microsoft.ML.TextLoader{TInput}" /> | ||
/// etc. | ||
/// </para> | ||
/// <para> | ||
/// Transforms: | ||
/// <see cref="Microsoft.ML.Transforms.Dictionarizer"/>, | ||
/// <see cref="Microsoft.ML.Transforms.CategoricalOneHotVectorizer"/> | ||
/// <see cref="Microsoft.ML.Transforms.MinMaxNormalizer"/>, | ||
/// <see cref="Microsoft.ML.Transforms.ColumnCopier"/>, | ||
/// <see cref="Microsoft.ML.Transforms.ColumnConcatenator"/>, | ||
/// <see cref="Microsoft.ML.Transforms.TextFeaturizer"/>, | ||
/// etc. | ||
/// </para> | ||
/// <para> | ||
/// Trainers: | ||
/// <see cref="Microsoft.ML.Trainers.AveragedPerceptronBinaryClassifier"/>, | ||
/// <see cref="Microsoft.ML.Trainers.LogisticRegressor"/>, | ||
/// <see cref="Microsoft.ML.Trainers.StochasticDualCoordinateAscentClassifier"/>, | ||
/// <see cref="Microsoft.ML.Trainers.FastTreeRegressor"/>, | ||
/// etc. | ||
/// </para> | ||
/// For a complete list of transforms and trainers, please see "Microsoft.ML.Transforms" and "Microsoft.ML.Trainers" namespaces. | ||
/// </summary> | ||
/// <param name="item">Any ML component (data loader, transform or trainer) defined as <see cref="ILearningPipelineItem"/>.</param> | ||
public void Add(ILearningPipelineItem item) => Items.Add(item); | ||
|
||
/// <summary> | ||
/// Remove all the loaders/transforms/trainers from the pipeline. | ||
/// </summary> | ||
public void Clear() => Items.Clear(); | ||
|
||
/// <summary> | ||
/// Check if a specific loader/transform/trainer is in the pipeline? | ||
/// </summary> | ||
/// <param name="item">Any ML component (data loader, transform or trainer) defined as <see cref="ILearningPipelineItem"/>.</param> | ||
/// <returns>true if item is found in the pipeline; otherwise, false.</returns> | ||
public bool Contains(ILearningPipelineItem item) => Items.Contains(item); | ||
|
||
/// <summary> | ||
/// Copy the pipeline items into an array. | ||
/// </summary> | ||
/// <param name="array">The one-dimensional Array that is the destination of the elements copied from.</param> | ||
/// <param name="arrayIndex">The zero-based index in <paramref name="array" /> at which copying begins.</param> | ||
public void CopyTo(ILearningPipelineItem[] array, int arrayIndex) => Items.CopyTo(array, arrayIndex); | ||
public IEnumerator<ILearningPipelineItem> GetEnumerator() => Items.GetEnumerator(); | ||
|
||
/// <summary> | ||
/// Remove an item from the pipeline. | ||
/// </summary> | ||
/// <param name="item"><see cref="ILearningPipelineItem"/> to remove.</param> | ||
/// <returns>true if item was removed from the pipeline; otherwise, false.</returns> | ||
public bool Remove(ILearningPipelineItem item) => Items.Remove(item); | ||
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); | ||
|
||
/// <summary> | ||
/// Train the model using the ML components in the pipeline. | ||
/// </summary> | ||
/// <typeparam name="TInput">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. | ||
/// <para/> | ||
/// Please see https://www.microsoft.com/net/learn/apps/machine-learning-and-ai/ml-dotnet/get-started/windows for more details on input type. | ||
/// </typeparam> | ||
/// <typeparam name="TOutput">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. | ||
/// </typeparam> | ||
/// <returns>PredictionModel object. This is the model object used for prediction on new instances. </returns> | ||
public PredictionModel<TInput, TOutput> Train<TInput, TOutput>() | ||
where TInput : class | ||
where TOutput : class, new() | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd really prefer "This class", but if you really want the actual name of the class referenced, for grammar reasons maybe prefix with "The" so that it's The LearningPipeline class" vs. "LearningPipeline class."