-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Renaming .Train to .Fit in TrainerEstimators #2528
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
Conversation
@@ -509,7 +513,8 @@ internal static CommonOutputs.BinaryClassificationOutput TrainBinary(IHostEnviro | |||
return new FieldAwareFactorizationMachinePredictionTransformer(Host, model, trainData.Schema, FeatureColumns.Select(x => x.Name).ToArray()); | |||
} | |||
|
|||
public FieldAwareFactorizationMachinePredictionTransformer Fit(IDataView input) => Train(input); | |||
/// <summary> Trains and returns a <see cref="ITransformer"/>.</summary> | |||
public FieldAwareFactorizationMachinePredictionTransformer Fit(IDataView input) => Fit(input); |
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.
public FieldAwareFactorizationMachinePredictionTransformer Fit(IDataView input) => Fit(input); [](start = 8, length = 94)
public FieldAwareFactorizationMachinePredictionTransformer Fit(IDataView input) => Fit(input); [](start = 8, length = 94)
Ghostbusters theme playing:
If there's something strange,
In your test runs.
Who you gonna blame?
STACKOVERFLOW! #Closed
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.
on a serious note, you call yourself here.
change it to Fit(IDataView input) => Fit(input, null, null)
In reply to: 256597651 [](ancestors = 256597651)
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.
Ah makes sense! Thank you I thought there was something strange thanks a lot 👍 #Closed
/// </summary> | ||
/// <param name="input">The training data set.</param> | ||
public MatrixFactorizationPredictionTransformer Fit(IDataView input) => Train(input); | ||
public MatrixFactorizationPredictionTransformer Fit(IDataView input) => Fit(input); |
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.
Fit(IDataView input) => Fit(input) [](start = 56, length = 34)
Fit(IDataView input) => Fit(input) [](start = 56, length = 34)
See my other comment on your PR. #Closed
/// <summary> | ||
/// Continues the training of a <see cref="OlsLinearRegressionTrainer"/> using an initial predictor and returns a <see cref="ITransformer"/>. | ||
/// </summary> | ||
public RegressionPredictionTransformer<OlsLinearRegressionModelParameters> Fit(IDataView trainData, IPredictor initialPredictor) |
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.
IPredictor [](start = 108, length = 10)
Can we file issue, to clean IPredictor
from public interface? @TomFinley trying to hide them in #2251 and we should accept strictly typed classes, like LinearModelParameters
here. #Closed
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.
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.
Codecov Report
@@ Coverage Diff @@
## master #2528 +/- ##
==========================================
+ Coverage 71.26% 71.27% +0.01%
==========================================
Files 797 799 +2
Lines 141292 141377 +85
Branches 16118 16118
==========================================
+ Hits 100692 100769 +77
- Misses 36138 36147 +9
+ Partials 4462 4461 -1
|
Codecov Report
@@ Coverage Diff @@
## master #2528 +/- ##
==========================================
- Coverage 71.43% 71.42% -0.01%
==========================================
Files 801 801
Lines 141784 141793 +9
Branches 16135 16135
==========================================
- Hits 101278 101277 -1
- Misses 36039 36048 +9
- Partials 4467 4468 +1
|
@@ -64,6 +64,7 @@ public abstract class TrainerEstimatorBase<TTransformer, TModel> : ITrainerEstim | |||
WeightColumn = weight; | |||
} | |||
|
|||
/// <summary> Trains and returns a <see cref="ITransformer"/>.</summary> |
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.
///
Trains and returns a .
[](start = 8, length = 72)
Please mention something like Derived class can overload this function. For example, in <see cref="FastTreeBinaryClassificationTrainer">, another <see cref="FastTreeBinaryClassificationTrainer.Fit"> which consumes two data sets, training and validation sets, is implemented
.
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.
Why? This is a base class, anyone who derives from it can overload everything.
In reply to: 256967851 [](ancestors = 256967851)
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.
This is for design documentation. Closely related things should be documented explicitly. We are not only writing code for Microsoft, ML.NET is for the public.
In reply to: 256974019 [](ancestors = 256974019,256967851)
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.
It's weird to have references to derived classes in base class especially it it's not functionality of base class. References from top to bottom make sense since you rely on base class and you know what is underneath you. Over way around, I don't see how it make sense.
In reply to: 256976207 [](ancestors = 256976207,256974019,256967851)
@@ -456,7 +456,10 @@ protected override string GetTestGraphHeader() | |||
protected override RankingPredictionTransformer<FastTreeRankingModelParameters> MakeTransformer(FastTreeRankingModelParameters model, Schema trainSchema) | |||
=> new RankingPredictionTransformer<FastTreeRankingModelParameters>(Host, model, trainSchema, FeatureColumn.Name); | |||
|
|||
public RankingPredictionTransformer<FastTreeRankingModelParameters> Train(IDataView trainData, IDataView validationData = null) | |||
/// <summary> | |||
/// Trains a <see cref="FastTreeRankingTrainer"/> using both training and validation data, returns a <see cref="ITransformer"/>. |
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.
ITransformer [](start = 120, length = 12)
Whenever possible, I'd choose a more specific type. Does RankingPredictionTransformer<FastTreeRankingModelParameters>
look good to you?
@@ -277,7 +277,10 @@ protected override void InitializeTests() | |||
CalibratedModelParametersBase<FastTreeBinaryModelParameters, PlattCalibrator> model, Schema trainSchema) | |||
=> new BinaryPredictionTransformer<CalibratedModelParametersBase<FastTreeBinaryModelParameters, PlattCalibrator>>(Host, model, trainSchema, FeatureColumn.Name); | |||
|
|||
public BinaryPredictionTransformer<CalibratedModelParametersBase<FastTreeBinaryModelParameters, PlattCalibrator>> Train(IDataView trainData, IDataView validationData = null) | |||
/// <summary> | |||
/// Trains a <see cref="FastTreeBinaryClassificationTrainer"/> using both training and validation data, returns a <see cref="ITransformer"/>. |
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.
ITransformer [](start = 133, length = 12)
As mentioned in other comments, it'd be more informative to specify the exact returned type here. Could you please also double-check other uses of ITransformer
in those doc strings.
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.
Yes will search everywhere
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.
Overall LGTM so approved. Please do address those comments around doc strings before merging. Other questions about design can be closed by creating issues if you feel they are really problems.
Fixes #2527.
As further explained in the issue, there were two methods with two different names to train a TrainerEstimator. I renamed one of them so that the additional functionalities come with an overload.
In particular the methods
Train(IDataView trainData, IDataView validData)
, andTrain(IDataView trainData, IPredictor initialPredictor)
have been renamed toFit(...
.