Skip to content

Commit 2d427bd

Browse files
authored
Update documentation for LightGBM and add missing binary references to console app. (#452)
* Add LightGBM to the entrypoint manifest and references to trainers and transform including native code to console command line binary. * Add documentation to use LightGBM nuget for LightGBM APIs.
1 parent 62095cb commit 2d427bd

File tree

16 files changed

+7555
-4857
lines changed

16 files changed

+7555
-4857
lines changed

Directory.Build.targets

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,33 @@
55
Text="The tools directory [$(ToolsDir)] does not exist. Please run build in the root of the repo to ensure the tools are installed before attempting to build an individual project." />
66
</Target>
77

8+
<Target Name="CopyNativeAssemblies"
9+
BeforeTargets="PrepareForRun">
10+
11+
<PropertyGroup>
12+
<LibPrefix Condition="'$(OS)' != 'Windows_NT'">lib</LibPrefix>
13+
<LibExtension Condition="'$(OS)' == 'Windows_NT'">.dll</LibExtension>
14+
<LibExtension Condition="'$(OS)' != 'Windows_NT'">.so</LibExtension>
15+
<LibExtension Condition="$([MSBuild]::IsOSPlatform('osx'))">.dylib</LibExtension>
16+
</PropertyGroup>
17+
18+
<ItemGroup>
19+
<NativeAssemblyReference>
20+
<FullAssemblyPath>$(NativeOutputPath)$(LibPrefix)%(NativeAssemblyReference.Identity)$(LibExtension)</FullAssemblyPath>
21+
</NativeAssemblyReference>
22+
</ItemGroup>
23+
24+
<Copy SourceFiles = "@(NativeAssemblyReference->'%(FullAssemblyPath)')"
25+
DestinationFolder="$(OutputPath)"
26+
OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)"
27+
Retries="$(CopyRetryCount)"
28+
RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"
29+
UseHardlinksIfPossible="$(CreateHardLinksForPublishFilesIfPossible)"
30+
UseSymboliclinksIfPossible="$(CreateSymbolicLinksForPublishFilesIfPossible)">
31+
<Output TaskParameter="DestinationFiles" ItemName="FileWrites"/>
32+
</Copy>
33+
34+
</Target>
35+
836
<Import Project="$(ToolsDir)/versioning.targets" Condition="Exists('$(ToolsDir)/versioning.targets')" />
937
</Project>

src/Microsoft.ML.Console/Console.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ public static class Console
88
{
99
public static int Main(string[] args) => Maml.Main(args);
1010
}
11-
}
11+
}

src/Microsoft.ML.Console/Microsoft.ML.Console.csproj

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,34 @@
33
<PropertyGroup>
44
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
55
<DefineConstants>CORECLR</DefineConstants>
6-
<TargetFramework>netcoreapp2.0</TargetFramework>
7-
<OutputType>Exe</OutputType>
8-
<AssemblyName>MML</AssemblyName>
9-
<StartupObject>Microsoft.ML.Runtime.Tools.Console.Console</StartupObject>
6+
<TargetFramework>netcoreapp2.0</TargetFramework>
7+
<OutputType>Exe</OutputType>
8+
<AssemblyName>MML</AssemblyName>
9+
<StartupObject>Microsoft.ML.Runtime.Tools.Console.Console</StartupObject>
1010
</PropertyGroup>
1111

1212
<ItemGroup>
1313
<ProjectReference Include="..\Microsoft.ML.Core\Microsoft.ML.Core.csproj" />
14+
<ProjectReference Include="..\Microsoft.ML.CpuMath\Microsoft.ML.CpuMath.csproj" />
1415
<ProjectReference Include="..\Microsoft.ML.Data\Microsoft.ML.Data.csproj" />
16+
<ProjectReference Include="..\Microsoft.ML.Ensemble\Microsoft.ML.Ensemble.csproj" />
17+
<ProjectReference Include="..\Microsoft.ML.FastTree\Microsoft.ML.FastTree.csproj" />
18+
<ProjectReference Include="..\Microsoft.ML.InternalStreams\Microsoft.ML.InternalStreams.csproj" />
19+
<ProjectReference Include="..\Microsoft.ML.KMeansClustering\Microsoft.ML.KMeansClustering.csproj" />
20+
<ProjectReference Include="..\Microsoft.ML.LightGBM\Microsoft.ML.LightGBM.csproj" />
1521
<ProjectReference Include="..\Microsoft.ML.Maml\Microsoft.ML.Maml.csproj" />
22+
<ProjectReference Include="..\Microsoft.ML.PCA\Microsoft.ML.PCA.csproj" />
1623
<ProjectReference Include="..\Microsoft.ML.PipelineInference\Microsoft.ML.PipelineInference.csproj" />
17-
</ItemGroup>
24+
<ProjectReference Include="..\Microsoft.ML.ResultProcessor\Microsoft.ML.ResultProcessor.csproj" />
25+
<ProjectReference Include="..\Microsoft.ML.StandardLearners\Microsoft.ML.StandardLearners.csproj" />
26+
<ProjectReference Include="..\Microsoft.ML.Sweeper\Microsoft.ML.Sweeper.csproj" />
27+
<ProjectReference Include="..\Microsoft.ML.Transforms\Microsoft.ML.Transforms.csproj" />
28+
<ProjectReference Include="..\Microsoft.ML.UniversalModelFormat\Microsoft.ML.UniversalModelFormat.csproj" />
1829

30+
<NativeAssemblyReference Include="FastTreeNative" />
31+
<NativeAssemblyReference Include="CpuMathNative" />
32+
<NativeAssemblyReference Include="FactorizationMachineNative" />
33+
<NativeAssemblyReference Include="LdaNative" />
34+
</ItemGroup>
35+
1936
</Project>

src/Microsoft.ML.LightGBM/LightGbmBinaryTrainer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public static partial class LightGbm
128128
{
129129
[TlcModule.EntryPoint(
130130
Name = "Trainers.LightGbmBinaryClassifier",
131-
Desc = "Train an LightGBM binary class model",
131+
Desc = "Train a LightGBM binary class model.",
132132
UserName = LightGbmBinaryTrainer.Summary,
133133
ShortName = LightGbmBinaryTrainer.ShortName)]
134134
public static CommonOutputs.BinaryClassificationOutput TrainBinary(IHostEnvironment env, LightGbmArguments input)

src/Microsoft.ML.LightGBM/LightGbmMulticlassTrainer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ public static partial class LightGbm
180180
{
181181
[TlcModule.EntryPoint(
182182
Name = "Trainers.LightGbmClassifier",
183-
Desc = "Train an LightGBM multi class model",
183+
Desc = "Train a LightGBM multi class model.",
184184
UserName = LightGbmMulticlassTrainer.Summary,
185185
ShortName = LightGbmMulticlassTrainer.ShortName)]
186186
public static CommonOutputs.MulticlassClassificationOutput TrainMultiClass(IHostEnvironment env, LightGbmArguments input)

src/Microsoft.ML.LightGBM/LightGbmRankingTrainer.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,11 @@ protected override void CheckAndUpdateParametersBeforeTraining(IChannel ch, Role
127127
/// </summary>
128128
public static partial class LightGbm
129129
{
130-
[TlcModule.EntryPoint(Name = "Trainers.LightGbmRanker", Desc = "Train an LightGBM ranking model", UserName = LightGbmRankingTrainer.Summary, ShortName = LightGbmRankingTrainer.ShortName)]
130+
[TlcModule.EntryPoint(
131+
Name = "Trainers.LightGbmRanker",
132+
Desc = "Train a LightGBM ranking model.",
133+
UserName = LightGbmRankingTrainer.Summary,
134+
ShortName = LightGbmRankingTrainer.ShortName)]
131135
public static CommonOutputs.RankingOutput TrainRanking(IHostEnvironment env, LightGbmArguments input)
132136
{
133137
Contracts.CheckValue(env, nameof(env));

src/Microsoft.ML.LightGBM/LightGbmRegressionTrainer.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,11 @@ protected override void CheckAndUpdateParametersBeforeTraining(IChannel ch, Role
120120
/// </summary>
121121
public static partial class LightGbm
122122
{
123-
[TlcModule.EntryPoint(Name = "Trainers.LightGbmRegressor", Desc = LightGbmRegressorTrainer.Summary, UserName = LightGbmRegressorTrainer.UserNameValue, ShortName = LightGbmRegressorTrainer.ShortName)]
123+
[TlcModule.EntryPoint(
124+
Name = "Trainers.LightGbmRegressor",
125+
Desc = LightGbmRegressorTrainer.Summary,
126+
UserName = LightGbmRegressorTrainer.UserNameValue,
127+
ShortName = LightGbmRegressorTrainer.ShortName)]
124128
public static CommonOutputs.RegressionOutput TrainRegression(IHostEnvironment env, LightGbmArguments input)
125129
{
126130
Contracts.CheckValue(env, nameof(env));

src/Microsoft.ML/CSharpApi.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7320,7 +7320,7 @@ public enum LightGbmArgumentsEvalMetricType
73207320

73217321

73227322
/// <summary>
7323-
/// Train an LightGBM binary class model
7323+
/// Train a LightGBM binary class model.
73247324
/// </summary>
73257325
public sealed partial class LightGbmBinaryClassifier : Microsoft.ML.Runtime.EntryPoints.CommonInputs.ITrainerInputWithGroupId, Microsoft.ML.Runtime.EntryPoints.CommonInputs.ITrainerInputWithWeight, Microsoft.ML.Runtime.EntryPoints.CommonInputs.ITrainerInputWithLabel, Microsoft.ML.Runtime.EntryPoints.CommonInputs.ITrainerInput, Microsoft.ML.ILearningPipelineItem
73267326
{
@@ -7525,7 +7525,7 @@ namespace Trainers
75257525
{
75267526

75277527
/// <summary>
7528-
/// Train an LightGBM multi class model
7528+
/// Train a LightGBM multi class model.
75297529
/// </summary>
75307530
public sealed partial class LightGbmClassifier : Microsoft.ML.Runtime.EntryPoints.CommonInputs.ITrainerInputWithGroupId, Microsoft.ML.Runtime.EntryPoints.CommonInputs.ITrainerInputWithWeight, Microsoft.ML.Runtime.EntryPoints.CommonInputs.ITrainerInputWithLabel, Microsoft.ML.Runtime.EntryPoints.CommonInputs.ITrainerInput, Microsoft.ML.ILearningPipelineItem
75317531
{
@@ -7730,7 +7730,7 @@ namespace Trainers
77307730
{
77317731

77327732
/// <summary>
7733-
/// Train an LightGBM ranking model
7733+
/// Train a LightGBM ranking model.
77347734
/// </summary>
77357735
public sealed partial class LightGbmRanker : Microsoft.ML.Runtime.EntryPoints.CommonInputs.ITrainerInputWithGroupId, Microsoft.ML.Runtime.EntryPoints.CommonInputs.ITrainerInputWithWeight, Microsoft.ML.Runtime.EntryPoints.CommonInputs.ITrainerInputWithLabel, Microsoft.ML.Runtime.EntryPoints.CommonInputs.ITrainerInput, Microsoft.ML.ILearningPipelineItem
77367736
{
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
namespace Microsoft.ML.Trainers
6+
{
7+
/// <summary>
8+
/// This API requires Microsoft.ML.LightGBM nuget.
9+
/// </summary>
10+
/// <example>
11+
/// <code>
12+
/// pipeline.Add(new LightGbmBinaryClassifier() { NumLeaves = 5, NumBoostRound = 5, MinDataPerLeaf = 2 })
13+
/// </code>
14+
/// </example>
15+
public sealed partial class LightGbmBinaryClassifier
16+
{
17+
18+
}
19+
20+
/// <summary>
21+
/// This API requires Microsoft.ML.LightGBM nuget.
22+
/// </summary>
23+
/// <example>
24+
/// <code>
25+
/// pipeline.Add(new LightGbmClassifier() { NumLeaves = 5, NumBoostRound = 5, MinDataPerLeaf = 2 })
26+
/// </code>
27+
/// </example>
28+
public sealed partial class LightGbmClassifier
29+
{
30+
31+
}
32+
33+
/// <summary>
34+
/// This API requires Microsoft.ML.LightGBM nuget.
35+
/// </summary>
36+
/// <example>
37+
/// <code>
38+
/// pipeline.Add(new LightGbmRanker() { NumLeaves = 5, NumBoostRound = 5, MinDataPerLeaf = 2 })
39+
/// </code>
40+
/// </example>
41+
public sealed partial class LightGbmRanker
42+
{
43+
44+
}
45+
46+
/// <summary>
47+
/// This API requires Microsoft.ML.LightGBM nuget.
48+
/// </summary>
49+
/// <example>
50+
/// <code>
51+
/// pipeline.Add(new LightGbmRegressor() { NumLeaves = 5, NumBoostRound = 5, MinDataPerLeaf = 2 })
52+
/// </code>
53+
/// </example>
54+
public sealed partial class LightGbmRegressor
55+
{
56+
57+
}
58+
}

test/BaselineOutput/Common/EntryPoints/core_ep-list.tsv

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ Trainers.FieldAwareFactorizationMachineBinaryClassifier Train a field-aware fact
5050
Trainers.GeneralizedAdditiveModelBinaryClassifier Trains a gradient boosted stump per feature, on all features simultaneously, to fit target values using least-squares. It mantains no interactions between features. Microsoft.ML.Runtime.FastTree.Gam TrainBinary Microsoft.ML.Runtime.FastTree.BinaryClassificationGamTrainer+Arguments Microsoft.ML.Runtime.EntryPoints.CommonOutputs+BinaryClassificationOutput
5151
Trainers.GeneralizedAdditiveModelRegressor Trains a gradient boosted stump per feature, on all features simultaneously, to fit target values using least-squares. It mantains no interactions between features. Microsoft.ML.Runtime.FastTree.Gam TrainRegression Microsoft.ML.Runtime.FastTree.RegressionGamTrainer+Arguments Microsoft.ML.Runtime.EntryPoints.CommonOutputs+RegressionOutput
5252
Trainers.KMeansPlusPlusClusterer K-means is a popular clustering algorithm. With K-means, the data is clustered into a specified number of clusters in order to minimize the within-cluster sum of squares. K-means++ improves upon K-means by using a better method for choosing the initial cluster centers. Microsoft.ML.Runtime.KMeans.KMeansPlusPlusTrainer TrainKMeans Microsoft.ML.Runtime.KMeans.KMeansPlusPlusTrainer+Arguments Microsoft.ML.Runtime.EntryPoints.CommonOutputs+ClusteringOutput
53+
Trainers.LightGbmBinaryClassifier Train a LightGBM binary class model. Microsoft.ML.Runtime.LightGBM.LightGbm TrainBinary Microsoft.ML.Runtime.LightGBM.LightGbmArguments Microsoft.ML.Runtime.EntryPoints.CommonOutputs+BinaryClassificationOutput
54+
Trainers.LightGbmClassifier Train a LightGBM multi class model. Microsoft.ML.Runtime.LightGBM.LightGbm TrainMultiClass Microsoft.ML.Runtime.LightGBM.LightGbmArguments Microsoft.ML.Runtime.EntryPoints.CommonOutputs+MulticlassClassificationOutput
55+
Trainers.LightGbmRanker Train a LightGBM ranking model. Microsoft.ML.Runtime.LightGBM.LightGbm TrainRanking Microsoft.ML.Runtime.LightGBM.LightGbmArguments Microsoft.ML.Runtime.EntryPoints.CommonOutputs+RankingOutput
56+
Trainers.LightGbmRegressor LightGBM Regression Microsoft.ML.Runtime.LightGBM.LightGbm TrainRegression Microsoft.ML.Runtime.LightGBM.LightGbmArguments Microsoft.ML.Runtime.EntryPoints.CommonOutputs+RegressionOutput
5357
Trainers.LinearSvmBinaryClassifier Train a linear SVM. Microsoft.ML.Runtime.Learners.LinearSvm TrainLinearSvm Microsoft.ML.Runtime.Learners.LinearSvm+Arguments Microsoft.ML.Runtime.EntryPoints.CommonOutputs+BinaryClassificationOutput
5458
Trainers.LogisticRegressionBinaryClassifier Logistic Regression is a classification method used to predict the value of a categorical dependent variable from its relationship to one or more independent variables assumed to have a logistic distribution. If the dependent variable has only two possible values (success/failure), then the logistic regression is binary. If the dependent variable has more than two possible values (blood type given diagnostic test results), then the logistic regression is multinomial.The optimization technique used for LogisticRegressionBinaryClassifier is the limited memory Broyden-Fletcher-Goldfarb-Shanno (L-BFGS). Both the L-BFGS and regular BFGS algorithms use quasi-Newtonian methods to estimate the computationally intensive Hessian matrix in the equation used by Newton's method to calculate steps. But the L-BFGS approximation uses only a limited amount of memory to compute the next step direction, so that it is especially suited for problems with a large number of variables. The memory_size parameter specifies the number of past positions and gradients to store for use in the computation of the next step.This learner can use elastic net regularization: a linear combination of L1 (lasso) and L2 (ridge) regularizations. Regularization is a method that can render an ill-posed problem more tractable by imposing constraints that provide information to supplement the data and that prevents overfitting by penalizing models with extreme coefficient values. This can improve the generalization of the model learned by selecting the optimal complexity in the bias-variance tradeoff. Regularization works by adding the penalty that is associated with coefficient values to the error of the hypothesis. An accurate model with extreme coefficient values would be penalized more, but a less accurate model with more conservative values would be penalized less. L1 and L2 regularization have different effects and uses that are complementary in certain respects.l1_weight: can be applied to sparse models, when working with high-dimensional data. It pulls small weights associated features that are relatively unimportant towards 0. l2_weight: is preferable for data that is not sparse. It pulls large weights towards zero. Adding the ridge penalty to the regularization overcomes some of lasso's limitations. It can improve its predictive accuracy, for example, when the number of predictors is greater than the sample size. If x = l1_weight and y = l2_weight, ax + by = c defines the linear span of the regularization terms. The default values of x and y are both 1. An agressive regularization can harm predictive capacity by excluding important variables out of the model. So choosing the optimal values for the regularization parameters is important for the performance of the logistic regression model.<see href='http://en.wikipedia.org/wiki/L-BFGS'>Wikipedia: L-BFGS</see>.<see href='http://en.wikipedia.org/wiki/Logistic_regression'>Wikipedia: Logistic regression</see>.<see href='http://research.microsoft.com/apps/pubs/default.aspx?id=78900'>Scalable Training of L1-Regularized Log-Linear Models</see>.<see href='https://msdn.microsoft.com/en-us/magazine/dn904675.aspx'>Test Run - L1 and L2 Regularization for Machine Learning</see>. Microsoft.ML.Runtime.Learners.LogisticRegression TrainBinary Microsoft.ML.Runtime.Learners.LogisticRegression+Arguments Microsoft.ML.Runtime.EntryPoints.CommonOutputs+BinaryClassificationOutput
5559
Trainers.LogisticRegressionClassifier Logistic Regression is a classification method used to predict the value of a categorical dependent variable from its relationship to one or more independent variables assumed to have a logistic distribution. If the dependent variable has only two possible values (success/failure), then the logistic regression is binary. If the dependent variable has more than two possible values (blood type given diagnostic test results), then the logistic regression is multinomial.The optimization technique used for LogisticRegressionBinaryClassifier is the limited memory Broyden-Fletcher-Goldfarb-Shanno (L-BFGS). Both the L-BFGS and regular BFGS algorithms use quasi-Newtonian methods to estimate the computationally intensive Hessian matrix in the equation used by Newton's method to calculate steps. But the L-BFGS approximation uses only a limited amount of memory to compute the next step direction, so that it is especially suited for problems with a large number of variables. The memory_size parameter specifies the number of past positions and gradients to store for use in the computation of the next step.This learner can use elastic net regularization: a linear combination of L1 (lasso) and L2 (ridge) regularizations. Regularization is a method that can render an ill-posed problem more tractable by imposing constraints that provide information to supplement the data and that prevents overfitting by penalizing models with extreme coefficient values. This can improve the generalization of the model learned by selecting the optimal complexity in the bias-variance tradeoff. Regularization works by adding the penalty that is associated with coefficient values to the error of the hypothesis. An accurate model with extreme coefficient values would be penalized more, but a less accurate model with more conservative values would be penalized less. L1 and L2 regularization have different effects and uses that are complementary in certain respects.l1_weight: can be applied to sparse models, when working with high-dimensional data. It pulls small weights associated features that are relatively unimportant towards 0. l2_weight: is preferable for data that is not sparse. It pulls large weights towards zero. Adding the ridge penalty to the regularization overcomes some of lasso's limitations. It can improve its predictive accuracy, for example, when the number of predictors is greater than the sample size. If x = l1_weight and y = l2_weight, ax + by = c defines the linear span of the regularization terms. The default values of x and y are both 1. An agressive regularization can harm predictive capacity by excluding important variables out of the model. So choosing the optimal values for the regularization parameters is important for the performance of the logistic regression model.<see href='http://en.wikipedia.org/wiki/L-BFGS'>Wikipedia: L-BFGS</see>.<see href='http://en.wikipedia.org/wiki/Logistic_regression'>Wikipedia: Logistic regression</see>.<see href='http://research.microsoft.com/apps/pubs/default.aspx?id=78900'>Scalable Training of L1-Regularized Log-Linear Models</see>.<see href='https://msdn.microsoft.com/en-us/magazine/dn904675.aspx'>Test Run - L1 and L2 Regularization for Machine Learning</see>. Microsoft.ML.Runtime.Learners.LogisticRegression TrainMultiClass Microsoft.ML.Runtime.Learners.MulticlassLogisticRegression+Arguments Microsoft.ML.Runtime.EntryPoints.CommonOutputs+MulticlassClassificationOutput

0 commit comments

Comments
 (0)