-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Scrub changes for LightGBM #2808
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
Changes from 1 commit
8dd53e1
23812b5
ce21121
b958c37
90e3ee2
d32e44e
27172f1
a355b31
4a1fbb0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -20,10 +20,10 @@ public static void Example() | |||||||
|
|
||||||||
| // Create the Estimator pipeline. For simplicity, we will train a small tree with 4 leaves and 2 boosting iterations. | ||||||||
| var pipeline = mlContext.Ranking.Trainers.LightGbm( | ||||||||
| numLeaves: 4, | ||||||||
| minDataPerLeaf: 10, | ||||||||
| leafCount: 4, | ||||||||
| minimumDataPerLeaf: 10, | ||||||||
|
Contributor
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.
Suggested change
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. Should the arguments have the same name as FastTreeArguments? In reply to: 261456738 [](ancestors = 261456738) 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.
Member
Author
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. My preference is that they should follow what is in LightGBM, but in a more verbose form to align with what we have in C#. For example, num_iterations == NumberOfIterations, min_data_in_leaf == minimumDataInLeaf. This way they bear some resemblance of the LightGBM arguments if a user looks it up. In reply to: 261699860 [](ancestors = 261699860,261698972,261456738)
Member
Author
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. Resolved to we use our own parameter names and use a mapping of names -> light gbm arguments. Parameter names that are the same between FastTree and LightGBM will use the same name. In reply to: 261722064 [](ancestors = 261722064,261699860,261698972,261456738)
Member
Author
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. @yaeld@microsoft.com Wei-Sheng has a PR for fast tree that is updating the parameters to match with the changes that we are doing here. In reply to: 261698972 [](ancestors = 261698972,261456738) |
||||||||
| learningRate: 0.1, | ||||||||
| numBoostRound: 2); | ||||||||
| numberOfIterations: 2); | ||||||||
|
|
||||||||
| // Fit this Pipeline to the Training Data. | ||||||||
| var model = pipeline.Fit(split.TrainSet); | ||||||||
|
|
||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,8 +35,8 @@ public static void Example() | |
| var pipeline = mlContext.Transforms.Concatenate("Features", featureNames) | ||
| .Append(mlContext.Regression.Trainers.LightGbm( | ||
| labelColumnName: labelName, | ||
| numLeaves: 4, | ||
| minDataPerLeaf: 6, | ||
| leafCount: 4, | ||
|
Contributor
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. |
||
| minimumDataPerLeaf: 6, | ||
| learningRate: 0.001)); | ||
|
|
||
| // Fit this pipeline to the training data. | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -38,8 +38,8 @@ public static void LightGbmRegression() | |||||||
| .Append(r => (r.label, score: mlContext.Regression.Trainers.LightGbm( | ||||||||
| r.label, | ||||||||
| r.features, | ||||||||
| numLeaves: 4, | ||||||||
| minDataPerLeaf: 6, | ||||||||
| numberOfLeaves: 4, | ||||||||
| minimumDataPerLeaf: 6, | ||||||||
|
Contributor
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.
Suggested change
|
||||||||
| learningRate: 0.001, | ||||||||
| onFit: p => pred = p) | ||||||||
| ) | ||||||||
|
|
||||||||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -21,10 +21,10 @@ public static class LightGbmStaticExtensions | |||||||
| /// <param name="label">The label column.</param> | ||||||||
| /// <param name="features">The features column.</param> | ||||||||
| /// <param name="weights">The weights column.</param> | ||||||||
| /// <param name="numLeaves">The number of leaves to use.</param> | ||||||||
| /// <param name="numBoostRound">Number of iterations.</param> | ||||||||
| /// <param name="minDataPerLeaf">The minimal number of documents allowed in a leaf of the tree, out of the subsampled data.</param> | ||||||||
| /// <param name="numberOfLeaves">The number of leaves to use.</param> | ||||||||
| /// <param name="minimumDataPerLeaf">The minimal number of documents allowed in a leaf of the tree, out of the subsampled data.</param> | ||||||||
|
Contributor
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.
Suggested change
|
||||||||
| /// <param name="learningRate">The learning rate.</param> | ||||||||
| /// <param name="numberOfIterations">Number of iterations.</param> | ||||||||
| /// <param name="onFit">A delegate that is called every time the | ||||||||
| /// <see cref="Estimator{TInShape, TOutShape, TTransformer}.Fit(DataView{TInShape})"/> method is called on the | ||||||||
| /// <see cref="Estimator{TInShape, TOutShape, TTransformer}"/> instance created out of this. This delegate will receive | ||||||||
|
|
@@ -39,19 +39,19 @@ public static class LightGbmStaticExtensions | |||||||
| /// </example> | ||||||||
| public static Scalar<float> LightGbm(this RegressionCatalog.RegressionTrainers catalog, | ||||||||
| Scalar<float> label, Vector<float> features, Scalar<float> weights = null, | ||||||||
| int? numLeaves = null, | ||||||||
| int? minDataPerLeaf = null, | ||||||||
| int? numberOfLeaves = null, | ||||||||
| int? minimumDataPerLeaf = null, | ||||||||
|
Contributor
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.
Suggested change
|
||||||||
| double? learningRate = null, | ||||||||
| int numBoostRound = Options.Defaults.NumBoostRound, | ||||||||
| int numberOfIterations = Options.Defaults.NumberOfIterations, | ||||||||
| Action<LightGbmRegressionModelParameters> onFit = null) | ||||||||
| { | ||||||||
| CheckUserValues(label, features, weights, numLeaves, minDataPerLeaf, learningRate, numBoostRound, onFit); | ||||||||
| CheckUserValues(label, features, weights, numberOfLeaves, minimumDataPerLeaf, learningRate, numberOfIterations, onFit); | ||||||||
|
|
||||||||
| var rec = new TrainerEstimatorReconciler.Regression( | ||||||||
| (env, labelName, featuresName, weightsName) => | ||||||||
| { | ||||||||
| var trainer = new LightGbmRegressorTrainer(env, labelName, featuresName, weightsName, numLeaves, | ||||||||
| minDataPerLeaf, learningRate, numBoostRound); | ||||||||
| var trainer = new LightGbmRegressorTrainer(env, labelName, featuresName, weightsName, numberOfLeaves, | ||||||||
| minimumDataPerLeaf, learningRate, numberOfIterations); | ||||||||
| if (onFit != null) | ||||||||
| return trainer.WithOnFitDelegate(trans => onFit(trans.Model)); | ||||||||
| return trainer; | ||||||||
|
|
@@ -122,11 +122,13 @@ public static Scalar<float> LightGbm(this RegressionCatalog.RegressionTrainers c | |||||||
| /// ]]></format> | ||||||||
| /// </example> | ||||||||
| public static (Scalar<float> score, Scalar<float> probability, Scalar<bool> predictedLabel) LightGbm(this BinaryClassificationCatalog.BinaryClassificationTrainers catalog, | ||||||||
| Scalar<bool> label, Vector<float> features, Scalar<float> weights = null, | ||||||||
| Scalar<bool> label, | ||||||||
| Vector<float> features, | ||||||||
| Scalar<float> weights = null, | ||||||||
| int? numLeaves = null, | ||||||||
|
Contributor
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.
Suggested change
|
||||||||
| int? minDataPerLeaf = null, | ||||||||
|
Contributor
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.
Suggested change
|
||||||||
| double? learningRate = null, | ||||||||
| int numBoostRound = Options.Defaults.NumBoostRound, | ||||||||
| int numBoostRound = Options.Defaults.NumberOfIterations, | ||||||||
|
Contributor
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.
Suggested change
Member
Author
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. |
||||||||
| Action<CalibratedModelParametersBase<LightGbmBinaryModelParameters, PlattCalibrator>> onFit = null) | ||||||||
| { | ||||||||
| CheckUserValues(label, features, weights, numLeaves, minDataPerLeaf, learningRate, numBoostRound, onFit); | ||||||||
|
|
@@ -194,9 +196,9 @@ public static (Scalar<float> score, Scalar<float> probability, Scalar<bool> pred | |||||||
| /// <param name="features">The features column.</param> | ||||||||
| /// <param name="groupId">The groupId column.</param> | ||||||||
| /// <param name="weights">The weights column.</param> | ||||||||
| /// <param name="numLeaves">The number of leaves to use.</param> | ||||||||
| /// <param name="numBoostRound">Number of iterations.</param> | ||||||||
| /// <param name="minDataPerLeaf">The minimal number of documents allowed in a leaf of the tree, out of the subsampled data.</param> | ||||||||
| /// <param name="numberOfLeaves">The number of leaves to use.</param> | ||||||||
| /// <param name="numberOfIterations">Number of iterations.</param> | ||||||||
| /// <param name="minimumDataPerLeaf">The minimal number of documents allowed in a leaf of the tree, out of the subsampled data.</param> | ||||||||
| /// <param name="learningRate">The learning rate.</param> | ||||||||
| /// <param name="onFit">A delegate that is called every time the | ||||||||
| /// <see cref="Estimator{TInShape, TOutShape, TTransformer}.Fit(DataView{TInShape})"/> method is called on the | ||||||||
|
|
@@ -206,21 +208,24 @@ public static (Scalar<float> score, Scalar<float> probability, Scalar<bool> pred | |||||||
| /// <returns>The set of output columns including in order the predicted binary classification score (which will range | ||||||||
| /// from negative to positive infinity), the calibrated prediction (from 0 to 1), and the predicted label.</returns> | ||||||||
| public static Scalar<float> LightGbm<TVal>(this RankingCatalog.RankingTrainers catalog, | ||||||||
| Scalar<float> label, Vector<float> features, Key<uint, TVal> groupId, Scalar<float> weights = null, | ||||||||
| int? numLeaves = null, | ||||||||
| int? minDataPerLeaf = null, | ||||||||
| Scalar<float> label, | ||||||||
| Vector<float> features, | ||||||||
| Key<uint, TVal> groupId, | ||||||||
| Scalar<float> weights = null, | ||||||||
| int? numberOfLeaves = null, | ||||||||
| int? minimumDataPerLeaf = null, | ||||||||
|
Contributor
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.
Suggested change
|
||||||||
| double? learningRate = null, | ||||||||
| int numBoostRound = Options.Defaults.NumBoostRound, | ||||||||
| int numberOfIterations = Options.Defaults.NumberOfIterations, | ||||||||
| Action<LightGbmRankingModelParameters> onFit = null) | ||||||||
| { | ||||||||
| CheckUserValues(label, features, weights, numLeaves, minDataPerLeaf, learningRate, numBoostRound, onFit); | ||||||||
| CheckUserValues(label, features, weights, numberOfLeaves, minimumDataPerLeaf, learningRate, numberOfIterations, onFit); | ||||||||
| Contracts.CheckValue(groupId, nameof(groupId)); | ||||||||
|
|
||||||||
| var rec = new TrainerEstimatorReconciler.Ranker<TVal>( | ||||||||
| (env, labelName, featuresName, groupIdName, weightsName) => | ||||||||
| { | ||||||||
| var trainer = new LightGbmRankingTrainer(env, labelName, featuresName, groupIdName, weightsName, numLeaves, | ||||||||
| minDataPerLeaf, learningRate, numBoostRound); | ||||||||
| var trainer = new LightGbmRankingTrainer(env, labelName, featuresName, groupIdName, weightsName, numberOfLeaves, | ||||||||
| minimumDataPerLeaf, learningRate, numberOfIterations); | ||||||||
|
|
||||||||
| if (onFit != null) | ||||||||
| return trainer.WithOnFitDelegate(trans => onFit(trans.Model)); | ||||||||
|
|
@@ -279,10 +284,10 @@ public static Scalar<float> LightGbm<TVal>(this RankingCatalog.RankingTrainers c | |||||||
| /// <param name="label">The label, or dependent variable.</param> | ||||||||
| /// <param name="features">The features, or independent variables.</param> | ||||||||
| /// <param name="weights">The weights column.</param> | ||||||||
| /// <param name="numLeaves">The number of leaves to use.</param> | ||||||||
| /// <param name="numBoostRound">Number of iterations.</param> | ||||||||
| /// <param name="minDataPerLeaf">The minimal number of documents allowed in a leaf of the tree, out of the subsampled data.</param> | ||||||||
| /// <param name="numberOfLeaves">The number of leaves to use.</param> | ||||||||
| /// <param name="minimumDataPerLeaf">The minimal number of documents allowed in a leaf of the tree, out of the subsampled data.</param> | ||||||||
|
Contributor
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.
Suggested change
Member
Author
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. I am using minimumExampleCountPerLeaf based on the previous comments. In reply to: 261458306 [](ancestors = 261458306)
Member
Author
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. Also replaced all comments with what you provided above. In reply to: 261777274 [](ancestors = 261777274,261458306) |
||||||||
| /// <param name="learningRate">The learning rate.</param> | ||||||||
| /// <param name="numberOfIterations">Number of iterations.</param> | ||||||||
| /// <param name="onFit">A delegate that is called every time the | ||||||||
| /// <see cref="Estimator{TInShape, TOutShape, TTransformer}.Fit(DataView{TInShape})"/> method is called on the | ||||||||
| /// <see cref="Estimator{TInShape, TOutShape, TTransformer}"/> instance created out of this. This delegate will receive | ||||||||
|
|
@@ -301,19 +306,19 @@ public static (Vector<float> score, Key<uint, TVal> predictedLabel) | |||||||
| Key<uint, TVal> label, | ||||||||
| Vector<float> features, | ||||||||
| Scalar<float> weights = null, | ||||||||
| int? numLeaves = null, | ||||||||
| int? minDataPerLeaf = null, | ||||||||
| int? numberOfLeaves = null, | ||||||||
| int? minimumDataPerLeaf = null, | ||||||||
|
Contributor
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.
minimumExampleCountPerLeaf #Resolved |
||||||||
| double? learningRate = null, | ||||||||
| int numBoostRound = Options.Defaults.NumBoostRound, | ||||||||
| int numberOfIterations = Options.Defaults.NumberOfIterations, | ||||||||
| Action<OvaModelParameters> onFit = null) | ||||||||
| { | ||||||||
| CheckUserValues(label, features, weights, numLeaves, minDataPerLeaf, learningRate, numBoostRound, onFit); | ||||||||
| CheckUserValues(label, features, weights, numberOfLeaves, minimumDataPerLeaf, learningRate, numberOfIterations, onFit); | ||||||||
|
|
||||||||
| var rec = new TrainerEstimatorReconciler.MulticlassClassifier<TVal>( | ||||||||
| (env, labelName, featuresName, weightsName) => | ||||||||
| { | ||||||||
| var trainer = new LightGbmMulticlassTrainer(env, labelName, featuresName, weightsName, numLeaves, | ||||||||
| minDataPerLeaf, learningRate, numBoostRound); | ||||||||
| var trainer = new LightGbmMulticlassTrainer(env, labelName, featuresName, weightsName, numberOfLeaves, | ||||||||
| minimumDataPerLeaf, learningRate, numberOfIterations); | ||||||||
|
|
||||||||
| if (onFit != null) | ||||||||
| return trainer.WithOnFitDelegate(trans => onFit(trans.Model)); | ||||||||
|
|
||||||||
Uh oh!
There was an error while loading. Please reload this page.
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.
as suggested in #2613. #Resolved