-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Modify API for advanced settings (LightGBM) #2261
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 all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,23 +24,31 @@ public static class LightGbmExtensions | |
/// <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="learningRate">The learning rate.</param> | ||
/// <param name="advancedSettings">A delegate to set more settings. | ||
/// The settings here will override the ones provided in the direct signature, | ||
/// if both are present and have different values. | ||
/// The columns names, however need to be provided directly, not through the <paramref name="advancedSettings"/>.</param> | ||
public static LightGbmRegressorTrainer LightGbm(this RegressionCatalog.RegressionTrainers catalog, | ||
string labelColumn = DefaultColumnNames.Label, | ||
string featureColumn = DefaultColumnNames.Features, | ||
string weights = null, | ||
int? numLeaves = null, | ||
int? minDataPerLeaf = null, | ||
double? learningRate = null, | ||
int numBoostRound = LightGbmArguments.Defaults.NumBoostRound, | ||
Action<LightGbmArguments> advancedSettings = null) | ||
int numBoostRound = Options.Defaults.NumBoostRound) | ||
{ | ||
Contracts.CheckValue(catalog, nameof(catalog)); | ||
var env = CatalogUtils.GetEnvironment(catalog); | ||
return new LightGbmRegressorTrainer(env, labelColumn, featureColumn, weights, numLeaves, minDataPerLeaf, learningRate, numBoostRound, advancedSettings); | ||
return new LightGbmRegressorTrainer(env, labelColumn, featureColumn, weights, numLeaves, minDataPerLeaf, learningRate, numBoostRound); | ||
} | ||
|
||
/// <summary> | ||
/// Predict a target using a decision tree regression model trained with the <see cref="LightGbmRegressorTrainer"/>. | ||
/// </summary> | ||
/// <param name="catalog">The <see cref="RegressionCatalog"/>.</param> | ||
/// <param name="options">Advanced options to the algorithm.</param> | ||
public static LightGbmRegressorTrainer LightGbm(this RegressionCatalog.RegressionTrainers catalog, | ||
Options options) | ||
{ | ||
Contracts.CheckValue(catalog, nameof(catalog)); | ||
var env = CatalogUtils.GetEnvironment(catalog); | ||
return new LightGbmRegressorTrainer(env, options); | ||
} | ||
|
||
/// <summary> | ||
|
@@ -54,28 +62,35 @@ public static LightGbmRegressorTrainer LightGbm(this RegressionCatalog.Regressio | |
/// <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="learningRate">The learning rate.</param> | ||
/// <param name="advancedSettings">A delegate to set more settings. | ||
/// The settings here will override the ones provided in the direct signature, | ||
/// if both are present and have different values. | ||
/// The columns names, however need to be provided directly, not through the <paramref name="advancedSettings"/>.</param> | ||
public static LightGbmBinaryTrainer LightGbm(this BinaryClassificationCatalog.BinaryClassificationTrainers catalog, | ||
string labelColumn = DefaultColumnNames.Label, | ||
string featureColumn = DefaultColumnNames.Features, | ||
string weights = null, | ||
int? numLeaves = null, | ||
int? minDataPerLeaf = null, | ||
double? learningRate = null, | ||
int numBoostRound = LightGbmArguments.Defaults.NumBoostRound, | ||
Action<LightGbmArguments> advancedSettings = null) | ||
int numBoostRound = Options.Defaults.NumBoostRound) | ||
{ | ||
Contracts.CheckValue(catalog, nameof(catalog)); | ||
var env = CatalogUtils.GetEnvironment(catalog); | ||
return new LightGbmBinaryTrainer(env, labelColumn, featureColumn, weights, numLeaves, minDataPerLeaf, learningRate, numBoostRound, advancedSettings); | ||
return new LightGbmBinaryTrainer(env, labelColumn, featureColumn, weights, numLeaves, minDataPerLeaf, learningRate, numBoostRound); | ||
} | ||
|
||
/// <summary> | ||
/// Predict a target using a decision tree binary classification model trained with the <see cref="LightGbmBinaryTrainer"/>. | ||
/// </summary> | ||
/// <param name="catalog">The <see cref="BinaryClassificationCatalog"/>.</param> | ||
/// <param name="options">Advanced options to the algorithm.</param> | ||
public static LightGbmBinaryTrainer LightGbm(this BinaryClassificationCatalog.BinaryClassificationTrainers catalog, | ||
Options options) | ||
{ | ||
Contracts.CheckValue(catalog, nameof(catalog)); | ||
var env = CatalogUtils.GetEnvironment(catalog); | ||
return new LightGbmBinaryTrainer(env, options); | ||
} | ||
|
||
/// <summary> | ||
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. binary classification => ranking #Resolved |
||
/// Predict a target using a decision tree binary classification model trained with the <see cref="LightGbmRankingTrainer"/>. | ||
/// Predict a target using a decision tree ranking model trained with the <see cref="LightGbmRankingTrainer"/>. | ||
/// </summary> | ||
/// <param name="catalog">The <see cref="RankingCatalog"/>.</param> | ||
/// <param name="labelColumn">The labelColumn column.</param> | ||
|
@@ -86,10 +101,6 @@ public static LightGbmBinaryTrainer LightGbm(this BinaryClassificationCatalog.Bi | |
/// <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="learningRate">The learning rate.</param> | ||
/// <param name="advancedSettings">A delegate to set more settings. | ||
/// The settings here will override the ones provided in the direct signature, | ||
/// if both are present and have different values. | ||
/// The columns names, however need to be provided directly, not through the <paramref name="advancedSettings"/>.</param> | ||
public static LightGbmRankingTrainer LightGbm(this RankingCatalog.RankingTrainers catalog, | ||
string labelColumn = DefaultColumnNames.Label, | ||
string featureColumn = DefaultColumnNames.Features, | ||
|
@@ -98,44 +109,62 @@ public static LightGbmRankingTrainer LightGbm(this RankingCatalog.RankingTrainer | |
int? numLeaves = null, | ||
int? minDataPerLeaf = null, | ||
double? learningRate = null, | ||
int numBoostRound = LightGbmArguments.Defaults.NumBoostRound, | ||
Action<LightGbmArguments> advancedSettings = null) | ||
int numBoostRound = Options.Defaults.NumBoostRound) | ||
{ | ||
Contracts.CheckValue(catalog, nameof(catalog)); | ||
var env = CatalogUtils.GetEnvironment(catalog); | ||
return new LightGbmRankingTrainer(env, labelColumn, featureColumn, groupIdColumn, weights, numLeaves, minDataPerLeaf, learningRate, numBoostRound, advancedSettings); | ||
|
||
return new LightGbmRankingTrainer(env, labelColumn, featureColumn, groupIdColumn, weights, numLeaves, minDataPerLeaf, learningRate, numBoostRound); | ||
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. There are some pretty long lines in this file. Over the permitted length? #Resolved 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 do not see any warnings related to long lines. i am actually reducing the length, by dropping In reply to: 251535698 [](ancestors = 251535698) |
||
} | ||
|
||
/// <summary> | ||
/// Predict a target using a decision tree binary classification model trained with the <see cref="LightGbmRankingTrainer"/>. | ||
/// Predict a target using a decision tree ranking model trained with the <see cref="LightGbmRankingTrainer"/>. | ||
/// </summary> | ||
/// <param name="catalog">The <see cref="RankingCatalog"/>.</param> | ||
/// <param name="options">Advanced options to the algorithm.</param> | ||
public static LightGbmRankingTrainer LightGbm(this RankingCatalog.RankingTrainers catalog, | ||
Options options) | ||
{ | ||
Contracts.CheckValue(catalog, nameof(catalog)); | ||
var env = CatalogUtils.GetEnvironment(catalog); | ||
return new LightGbmRankingTrainer(env, options); | ||
} | ||
|
||
/// <summary> | ||
/// Predict a target using a decision tree multiclass classification model trained with the <see cref="LightGbmMulticlassTrainer"/>. | ||
/// </summary> | ||
/// <param name="catalog">The <see cref="MulticlassClassificationCatalog"/>.</param> | ||
/// <param name="labelColumn">The labelColumn column.</param> | ||
/// <param name="featureColumn">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="learningRate">The learning rate.</param> | ||
/// <param name="advancedSettings">A delegate to set more settings. | ||
/// The settings here will override the ones provided in the direct signature, | ||
/// if both are present and have different values. | ||
/// The columns names, however need to be provided directly, not through the <paramref name="advancedSettings"/>.</param> | ||
public static LightGbmMulticlassTrainer LightGbm(this MulticlassClassificationCatalog.MulticlassClassificationTrainers catalog, | ||
string labelColumn = DefaultColumnNames.Label, | ||
string featureColumn = DefaultColumnNames.Features, | ||
string weights = null, | ||
int? numLeaves = null, | ||
int? minDataPerLeaf = null, | ||
double? learningRate = null, | ||
int numBoostRound = LightGbmArguments.Defaults.NumBoostRound, | ||
Action<LightGbmArguments> advancedSettings = null) | ||
int numBoostRound = Options.Defaults.NumBoostRound) | ||
{ | ||
Contracts.CheckValue(catalog, nameof(catalog)); | ||
var env = CatalogUtils.GetEnvironment(catalog); | ||
return new LightGbmMulticlassTrainer(env, labelColumn, featureColumn, weights, numLeaves, minDataPerLeaf, learningRate, numBoostRound, advancedSettings); | ||
return new LightGbmMulticlassTrainer(env, labelColumn, featureColumn, weights, numLeaves, minDataPerLeaf, learningRate, numBoostRound); | ||
} | ||
|
||
/// <summary> | ||
/// Predict a target using a decision tree multiclass classification model trained with the <see cref="LightGbmMulticlassTrainer"/>. | ||
/// </summary> | ||
/// <param name="catalog">The <see cref="MulticlassClassificationCatalog"/>.</param> | ||
/// <param name="options">Advanced options to the algorithm.</param> | ||
public static LightGbmMulticlassTrainer LightGbm(this MulticlassClassificationCatalog.MulticlassClassificationTrainers catalog, | ||
Options options) | ||
{ | ||
Contracts.CheckValue(catalog, nameof(catalog)); | ||
var env = CatalogUtils.GetEnvironment(catalog); | ||
return new LightGbmMulticlassTrainer(env, options); | ||
} | ||
} | ||
} |
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.
Is it not possible to combine the two constructors?
Or have you added this work to the reconciliation issue #2100? #Resolved
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.
yeap. exactly. added to #2100
want to focus on cleanup of public surface first
In reply to: 251541952 [](ancestors = 251541952)