Skip to content

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

Merged
merged 5 commits into from
Feb 15, 2019
Merged

Conversation

artidoro
Copy link
Contributor

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), and Train(IDataView trainData, IPredictor initialPredictor) have been renamed to Fit(....

@artidoro artidoro added the API Issues pertaining the friendly API label Feb 13, 2019
@artidoro artidoro self-assigned this Feb 13, 2019
@@ -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);
Copy link
Contributor

@Ivanidzo4ka Ivanidzo4ka Feb 13, 2019

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

Copy link
Contributor

@Ivanidzo4ka Ivanidzo4ka Feb 13, 2019

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)

Copy link
Contributor Author

@artidoro artidoro Feb 13, 2019

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);
Copy link
Contributor

@Ivanidzo4ka Ivanidzo4ka Feb 13, 2019

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)
Copy link
Contributor

@Ivanidzo4ka Ivanidzo4ka Feb 13, 2019

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

Copy link
Contributor

Choose a reason for hiding this comment

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

#2553


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

Copy link
Contributor

@Ivanidzo4ka Ivanidzo4ka left a comment

Choose a reason for hiding this comment

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

:shipit:

@codecov
Copy link

codecov bot commented Feb 14, 2019

Codecov Report

Merging #2528 into master will increase coverage by 0.01%.
The diff coverage is 100%.

@@            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
Flag Coverage Δ
#Debug 71.27% <100%> (+0.01%) ⬆️
#production 67.6% <100%> (+0.01%) ⬆️
#test 85.36% <100%> (ø) ⬆️

@codecov
Copy link

codecov bot commented Feb 14, 2019

Codecov Report

Merging #2528 into master will decrease coverage by <.01%.
The diff coverage is 100%.

@@            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
Flag Coverage Δ
#Debug 71.42% <100%> (-0.01%) ⬇️
#production 67.71% <100%> (-0.01%) ⬇️
#test 85.51% <100%> (ø) ⬆️

@@ -64,6 +64,7 @@ public abstract class TrainerEstimatorBase<TTransformer, TModel> : ITrainerEstim
WeightColumn = weight;
}

/// <summary> Trains and returns a <see cref="ITransformer"/>.</summary>
Copy link
Member

@wschin wschin Feb 14, 2019

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.

Copy link
Contributor

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)

Copy link
Member

@wschin wschin Feb 14, 2019

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)

Copy link
Contributor

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"/>.
Copy link
Member

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"/>.
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes will search everywhere

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.

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.

@artidoro artidoro merged commit b2587fa into dotnet:master Feb 15, 2019
@artidoro artidoro deleted the trainfit branch March 13, 2019 17:55
@ghost ghost locked as resolved and limited conversation to collaborators Mar 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
API Issues pertaining the friendly API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants