Skip to content

Commit ba22e12

Browse files
committed
Sync names in logistic regression and maximum entropy trainers based on L-BFGS
1 parent 3af9a5d commit ba22e12

File tree

14 files changed

+63
-63
lines changed

14 files changed

+63
-63
lines changed

src/Microsoft.ML.StandardTrainers/Standard/LogisticRegression/LogisticRegression.cs

+15-15
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,21 @@
1515
using Microsoft.ML.Runtime;
1616
using Microsoft.ML.Trainers;
1717

18-
[assembly: LoadableClass(LogisticRegressionBinaryTrainer.Summary, typeof(LogisticRegressionBinaryTrainer), typeof(LogisticRegressionBinaryTrainer.Options),
18+
[assembly: LoadableClass(LbfgsLogisticRegressionTrainer.Summary, typeof(LbfgsLogisticRegressionTrainer), typeof(LbfgsLogisticRegressionTrainer.Options),
1919
new[] { typeof(SignatureBinaryClassifierTrainer), typeof(SignatureTrainer), typeof(SignatureFeatureScorerTrainer) },
20-
LogisticRegressionBinaryTrainer.UserNameValue,
21-
LogisticRegressionBinaryTrainer.LoadNameValue,
22-
LogisticRegressionBinaryTrainer.ShortName,
20+
LbfgsLogisticRegressionTrainer.UserNameValue,
21+
LbfgsLogisticRegressionTrainer.LoadNameValue,
22+
LbfgsLogisticRegressionTrainer.ShortName,
2323
"logisticregressionwrapper")]
2424

25-
[assembly: LoadableClass(typeof(void), typeof(LogisticRegressionBinaryTrainer), null, typeof(SignatureEntryPointModule), LogisticRegressionBinaryTrainer.LoadNameValue)]
25+
[assembly: LoadableClass(typeof(void), typeof(LbfgsLogisticRegressionTrainer), null, typeof(SignatureEntryPointModule), LbfgsLogisticRegressionTrainer.LoadNameValue)]
2626

2727
namespace Microsoft.ML.Trainers
2828
{
2929

3030
/// <include file='doc.xml' path='doc/members/member[@name="LBFGS"]/*' />
3131
/// <include file='doc.xml' path='docs/members/example[@name="LogisticRegressionBinaryClassifier"]/*' />
32-
public sealed partial class LogisticRegressionBinaryTrainer : LbfgsTrainerBase<LogisticRegressionBinaryTrainer.Options,
32+
public sealed partial class LbfgsLogisticRegressionTrainer : LbfgsTrainerBase<LbfgsLogisticRegressionTrainer.Options,
3333
BinaryPredictionTransformer<CalibratedModelParametersBase<LinearBinaryModelParameters, PlattCalibrator>>,
3434
CalibratedModelParametersBase<LinearBinaryModelParameters, PlattCalibrator>>
3535
{
@@ -54,7 +54,7 @@ public sealed class Options : OptionsBase
5454
/// <summary>
5555
/// The instance of <see cref="ComputeLogisticRegressionStandardDeviation"/> that computes the std of the training statistics, at the end of training.
5656
/// The calculations are not part of Microsoft.ML package, due to the size of MKL.
57-
/// If you need these calculations, add the Microsoft.ML.Mkl.Components package, and initialize <see cref="LogisticRegressionBinaryTrainer.Options.ComputeStandardDeviation"/>.
57+
/// If you need these calculations, add the Microsoft.ML.Mkl.Components package, and initialize <see cref="LbfgsLogisticRegressionTrainer.Options.ComputeStandardDeviation"/>.
5858
/// to the <see cref="ComputeLogisticRegressionStandardDeviation"/> implementation in the Microsoft.ML.Mkl.Components package.
5959
/// </summary>
6060
public ComputeLogisticRegressionStandardDeviation ComputeStandardDeviation;
@@ -64,7 +64,7 @@ public sealed class Options : OptionsBase
6464
private ModelStatisticsBase _stats;
6565

6666
/// <summary>
67-
/// Initializes a new instance of <see cref="LogisticRegressionBinaryTrainer"/>
67+
/// Initializes a new instance of <see cref="LbfgsLogisticRegressionTrainer"/>
6868
/// </summary>
6969
/// <param name="env">The environment to use.</param>
7070
/// <param name="labelColumn">The name of the label column.</param>
@@ -73,9 +73,9 @@ public sealed class Options : OptionsBase
7373
/// <param name="enforceNoNegativity">Enforce non-negative weights.</param>
7474
/// <param name="l1Weight">Weight of L1 regularizer term.</param>
7575
/// <param name="l2Weight">Weight of L2 regularizer term.</param>
76-
/// <param name="memorySize">Memory size for <see cref="LogisticRegressionBinaryTrainer"/>. Low=faster, less accurate.</param>
76+
/// <param name="memorySize">Memory size for <see cref="LbfgsLogisticRegressionTrainer"/>. Low=faster, less accurate.</param>
7777
/// <param name="optimizationTolerance">Threshold for optimizer convergence.</param>
78-
internal LogisticRegressionBinaryTrainer(IHostEnvironment env,
78+
internal LbfgsLogisticRegressionTrainer(IHostEnvironment env,
7979
string labelColumn = DefaultColumnNames.Label,
8080
string featureColumn = DefaultColumnNames.Features,
8181
string weights = null,
@@ -95,9 +95,9 @@ internal LogisticRegressionBinaryTrainer(IHostEnvironment env,
9595
}
9696

9797
/// <summary>
98-
/// Initializes a new instance of <see cref="LogisticRegressionBinaryTrainer"/>
98+
/// Initializes a new instance of <see cref="LbfgsLogisticRegressionTrainer"/>
9999
/// </summary>
100-
internal LogisticRegressionBinaryTrainer(IHostEnvironment env, Options options)
100+
internal LbfgsLogisticRegressionTrainer(IHostEnvironment env, Options options)
101101
: base(env, options, TrainerUtils.MakeBoolScalarLabel(options.LabelColumnName))
102102
{
103103
_posWeight = 0;
@@ -127,7 +127,7 @@ private protected override BinaryPredictionTransformer<CalibratedModelParameters
127127
=> new BinaryPredictionTransformer<CalibratedModelParametersBase<LinearBinaryModelParameters, PlattCalibrator>>(Host, model, trainSchema, FeatureColumn.Name);
128128

129129
/// <summary>
130-
/// Continues the training of a <see cref="LogisticRegressionBinaryTrainer"/> using an already trained <paramref name="modelParameters"/> and returns
130+
/// Continues the training of a <see cref="LbfgsLogisticRegressionTrainer"/> using an already trained <paramref name="modelParameters"/> and returns
131131
/// a <see cref="BinaryPredictionTransformer{CalibratedModelParametersBase}"/>.
132132
/// </summary>
133133
public BinaryPredictionTransformer<CalibratedModelParametersBase<LinearBinaryModelParameters, PlattCalibrator>> Fit(IDataView trainData, LinearModelParameters modelParameters)
@@ -417,7 +417,7 @@ internal static CommonOutputs.BinaryClassificationOutput TrainBinary(IHostEnviro
417417
EntryPointUtils.CheckInputArgs(host, input);
418418

419419
return TrainerEntryPointsUtils.Train<Options, CommonOutputs.BinaryClassificationOutput>(host, input,
420-
() => new LogisticRegressionBinaryTrainer(host, input),
420+
() => new LbfgsLogisticRegressionTrainer(host, input),
421421
() => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.LabelColumnName),
422422
() => TrainerEntryPointsUtils.FindColumn(host, input.TrainingData.Schema, input.ExampleWeightColumnName));
423423
}
@@ -436,7 +436,7 @@ public abstract class ComputeLogisticRegressionStandardDeviation
436436
/// Computes the standard deviation matrix of each of the non-zero training weights, needed to calculate further the standard deviation,
437437
/// p-value and z-Score.
438438
/// The calculations are not part of Microsoft.ML package, due to the size of MKL.
439-
/// If you need these calculations, add the Microsoft.ML.Mkl.Components package, and initialize <see cref="LogisticRegressionBinaryTrainer.Options.ComputeStandardDeviation"/>
439+
/// If you need these calculations, add the Microsoft.ML.Mkl.Components package, and initialize <see cref="LbfgsLogisticRegressionTrainer.Options.ComputeStandardDeviation"/>
440440
/// to the <see cref="ComputeLogisticRegressionStandardDeviation"/> implementation in the Microsoft.ML.Mkl.Components package.
441441
/// Due to the existence of regularization, an approximation is used to compute the variances of the trained linear coefficients.
442442
/// </summary>

src/Microsoft.ML.StandardTrainers/Standard/LogisticRegression/MulticlassLogisticRegression.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public sealed class Options : OptionsBase
8383
/// <param name="enforceNoNegativity">Enforce non-negative weights.</param>
8484
/// <param name="l1Weight">Weight of L1 regularizer term.</param>
8585
/// <param name="l2Weight">Weight of L2 regularizer term.</param>
86-
/// <param name="memorySize">Memory size for <see cref="LogisticRegressionBinaryTrainer"/>. Low=faster, less accurate.</param>
86+
/// <param name="memorySize">Memory size for <see cref="LbfgsLogisticRegressionTrainer"/>. Low=faster, less accurate.</param>
8787
/// <param name="optimizationTolerance">Threshold for optimizer convergence.</param>
8888
internal LbfgsMaximumEntropyTrainer(IHostEnvironment env,
8989
string labelColumn = DefaultColumnNames.Label,

src/Microsoft.ML.StandardTrainers/Standard/PoissonRegression/PoissonRegression.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public sealed class Options : OptionsBase
4848
/// <param name="l1Weight">Weight of L1 regularizer term.</param>
4949
/// <param name="l2Weight">Weight of L2 regularizer term.</param>
5050
/// <param name="optimizationTolerance">Threshold for optimizer convergence.</param>
51-
/// <param name="memorySize">Memory size for <see cref="LogisticRegressionBinaryTrainer"/>. Low=faster, less accurate.</param>
51+
/// <param name="memorySize">Memory size for <see cref="LbfgsLogisticRegressionTrainer"/>. Low=faster, less accurate.</param>
5252
/// <param name="enforceNoNegativity">Enforce non-negative weights.</param>
5353
internal PoissonRegressionTrainer(IHostEnvironment env,
5454
string labelColumn = DefaultColumnNames.Label,

src/Microsoft.ML.StandardTrainers/StandardTrainersCatalog.cs

+8-8
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
namespace Microsoft.ML
1111
{
12-
using LROptions = LogisticRegressionBinaryTrainer.Options;
12+
using LROptions = LbfgsLogisticRegressionTrainer.Options;
1313

1414
/// <summary>
1515
/// TrainerEstimator extension methods.
@@ -498,7 +498,7 @@ public static OnlineGradientDescentTrainer OnlineGradientDescent(this Regression
498498
}
499499

500500
/// <summary>
501-
/// Predict a target using a linear binary classification model trained with the <see cref="Trainers.LogisticRegressionBinaryTrainer"/> trainer.
501+
/// Predict a target using a linear binary classification model trained with the <see cref="Trainers.LbfgsLogisticRegressionTrainer"/> trainer.
502502
/// </summary>
503503
/// <param name="catalog">The binary classification catalog trainer object.</param>
504504
/// <param name="labelColumnName">The name of the label column.</param>
@@ -507,7 +507,7 @@ public static OnlineGradientDescentTrainer OnlineGradientDescent(this Regression
507507
/// <param name="enforceNonNegativity">Enforce non-negative weights.</param>
508508
/// <param name="l1Regularization">Weight of L1 regularization term.</param>
509509
/// <param name="l2Regularization">Weight of L2 regularization term.</param>
510-
/// <param name="historySize">Memory size for <see cref="Trainers.LogisticRegressionBinaryTrainer"/>. Low=faster, less accurate.</param>
510+
/// <param name="historySize">Memory size for <see cref="Trainers.LbfgsLogisticRegressionTrainer"/>. Low=faster, less accurate.</param>
511511
/// <param name="optimizationTolerance">Threshold for optimizer convergence.</param>
512512
/// <example>
513513
/// <format type="text/markdown">
@@ -516,7 +516,7 @@ public static OnlineGradientDescentTrainer OnlineGradientDescent(this Regression
516516
/// ]]>
517517
/// </format>
518518
/// </example>
519-
public static LogisticRegressionBinaryTrainer LogisticRegression(this BinaryClassificationCatalog.BinaryClassificationTrainers catalog,
519+
public static LbfgsLogisticRegressionTrainer LogisticRegression(this BinaryClassificationCatalog.BinaryClassificationTrainers catalog,
520520
string labelColumnName = DefaultColumnNames.Label,
521521
string featureColumnName = DefaultColumnNames.Features,
522522
string exampleWeightColumnName = null,
@@ -528,21 +528,21 @@ public static LogisticRegressionBinaryTrainer LogisticRegression(this BinaryClas
528528
{
529529
Contracts.CheckValue(catalog, nameof(catalog));
530530
var env = CatalogUtils.GetEnvironment(catalog);
531-
return new LogisticRegressionBinaryTrainer(env, labelColumnName, featureColumnName, exampleWeightColumnName, l1Regularization, l2Regularization, optimizationTolerance, historySize, enforceNonNegativity);
531+
return new LbfgsLogisticRegressionTrainer(env, labelColumnName, featureColumnName, exampleWeightColumnName, l1Regularization, l2Regularization, optimizationTolerance, historySize, enforceNonNegativity);
532532
}
533533

534534
/// <summary>
535-
/// Predict a target using a linear binary classification model trained with the <see cref="Trainers.LogisticRegressionBinaryTrainer"/> trainer.
535+
/// Predict a target using a linear binary classification model trained with the <see cref="Trainers.LbfgsLogisticRegressionTrainer"/> trainer.
536536
/// </summary>
537537
/// <param name="catalog">The binary classification catalog trainer object.</param>
538538
/// <param name="options">Advanced arguments to the algorithm.</param>
539-
public static LogisticRegressionBinaryTrainer LogisticRegression(this BinaryClassificationCatalog.BinaryClassificationTrainers catalog, LROptions options)
539+
public static LbfgsLogisticRegressionTrainer LogisticRegression(this BinaryClassificationCatalog.BinaryClassificationTrainers catalog, LROptions options)
540540
{
541541
Contracts.CheckValue(catalog, nameof(catalog));
542542
Contracts.CheckValue(options, nameof(options));
543543

544544
var env = CatalogUtils.GetEnvironment(catalog);
545-
return new LogisticRegressionBinaryTrainer(env, options);
545+
return new LbfgsLogisticRegressionTrainer(env, options);
546546
}
547547

548548
/// <summary>

src/Microsoft.ML.StaticPipe/LbfgsStatic.cs

+11-11
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@
99

1010
namespace Microsoft.ML.StaticPipe
1111
{
12-
using Options = LogisticRegressionBinaryTrainer.Options;
12+
using Options = LbfgsLogisticRegressionTrainer.Options;
1313

1414
/// <summary>
1515
/// Binary Classification trainer estimators.
1616
/// </summary>
17-
public static class LbfgsBinaryClassificationStaticExtensions
17+
public static class LbfgsBinaryExtensions
1818
{
1919
/// <summary>
20-
/// Predict a target using a linear binary classification model trained with the <see cref="Microsoft.ML.Trainers.LogisticRegressionBinaryTrainer"/> trainer.
20+
/// Predict a target using a linear binary classification model trained with the <see cref="Microsoft.ML.Trainers.LbfgsLogisticRegressionTrainer"/> trainer.
2121
/// </summary>
2222
/// <param name="catalog">The binary classification catalog trainer object.</param>
2323
/// <param name="label">The label, or dependent variable.</param>
@@ -26,7 +26,7 @@ public static class LbfgsBinaryClassificationStaticExtensions
2626
/// <param name="enforceNonNegativity">Enforce non-negative weights.</param>
2727
/// <param name="l1Regularization">Weight of L1 regularization term.</param>
2828
/// <param name="l2Regularization">Weight of L2 regularization term.</param>
29-
/// <param name="historySize">Memory size for <see cref="Microsoft.ML.Trainers.LogisticRegressionBinaryTrainer"/>. Low=faster, less accurate.</param>
29+
/// <param name="historySize">Memory size for <see cref="Microsoft.ML.Trainers.LbfgsLogisticRegressionTrainer"/>. Low=faster, less accurate.</param>
3030
/// <param name="optimizationTolerance">Threshold for optimizer convergence.</param>
3131
/// <param name="onFit">A delegate that is called every time the
3232
/// <see cref="Estimator{TInShape, TOutShape, TTransformer}.Fit(DataView{TInShape})"/> method is called on the
@@ -50,7 +50,7 @@ public static (Scalar<float> score, Scalar<float> probability, Scalar<bool> pred
5050
var rec = new TrainerEstimatorReconciler.BinaryClassifier(
5151
(env, labelName, featuresName, weightsName) =>
5252
{
53-
var trainer = new LogisticRegressionBinaryTrainer(env, labelName, featuresName, weightsName,
53+
var trainer = new LbfgsLogisticRegressionTrainer(env, labelName, featuresName, weightsName,
5454
l1Regularization, l2Regularization, optimizationTolerance, historySize, enforceNonNegativity);
5555

5656
if (onFit != null)
@@ -63,7 +63,7 @@ public static (Scalar<float> score, Scalar<float> probability, Scalar<bool> pred
6363
}
6464

6565
/// <summary>
66-
/// Predict a target using a linear binary classification model trained with the <see cref="Microsoft.ML.Trainers.LogisticRegressionBinaryTrainer"/> trainer.
66+
/// Predict a target using a linear binary classification model trained with the <see cref="Microsoft.ML.Trainers.LbfgsLogisticRegressionTrainer"/> trainer.
6767
/// </summary>
6868
/// <param name="catalog">The binary classification catalog trainer object.</param>
6969
/// <param name="label">The label, or dependent variable.</param>
@@ -95,7 +95,7 @@ public static (Scalar<float> score, Scalar<float> probability, Scalar<bool> pred
9595
options.FeatureColumnName = featuresName;
9696
options.ExampleWeightColumnName = weightsName;
9797

98-
var trainer = new LogisticRegressionBinaryTrainer(env, options);
98+
var trainer = new LbfgsLogisticRegressionTrainer(env, options);
9999

100100
if (onFit != null)
101101
return trainer.WithOnFitDelegate(trans => onFit(trans.Model));
@@ -113,7 +113,7 @@ public static (Scalar<float> score, Scalar<float> probability, Scalar<bool> pred
113113
public static class LbfgsRegressionExtensions
114114
{
115115
/// <summary>
116-
/// Predict a target using a linear regression model trained with the <see cref="Microsoft.ML.Trainers.LogisticRegressionBinaryTrainer"/> trainer.
116+
/// Predict a target using a linear regression model trained with the <see cref="Microsoft.ML.Trainers.LbfgsLogisticRegressionTrainer"/> trainer.
117117
/// </summary>
118118
/// <param name="catalog">The regression catalog trainer object.</param>
119119
/// <param name="label">The label, or dependent variable.</param>
@@ -122,7 +122,7 @@ public static class LbfgsRegressionExtensions
122122
/// <param name="enforceNonNegativity">Enforce non-negative weights.</param>
123123
/// <param name="l1Regularization">Weight of L1 regularization term.</param>
124124
/// <param name="l2Regularization">Weight of L2 regularization term.</param>
125-
/// <param name="historySize">Memory size for <see cref="Microsoft.ML.Trainers.LogisticRegressionBinaryTrainer"/>. Low=faster, less accurate.</param>
125+
/// <param name="historySize">Memory size for <see cref="Microsoft.ML.Trainers.LbfgsLogisticRegressionTrainer"/>. Low=faster, less accurate.</param>
126126
/// <param name="optimizationTolerance">Threshold for optimizer convergence.</param>
127127
/// <param name="onFit">A delegate that is called every time the
128128
/// <see cref="Estimator{TInShape, TOutShape, TTransformer}.Fit(DataView{TInShape})"/> method is called on the
@@ -159,7 +159,7 @@ public static Scalar<float> PoissonRegression(this RegressionCatalog.RegressionT
159159
}
160160

161161
/// <summary>
162-
/// Predict a target using a linear regression model trained with the <see cref="Microsoft.ML.Trainers.LogisticRegressionBinaryTrainer"/> trainer.
162+
/// Predict a target using a linear regression model trained with the <see cref="Microsoft.ML.Trainers.LbfgsLogisticRegressionTrainer"/> trainer.
163163
/// </summary>
164164
/// <param name="catalog">The regression catalog trainer object.</param>
165165
/// <param name="label">The label, or dependent variable.</param>
@@ -218,7 +218,7 @@ public static class LbfgsMulticlassExtensions
218218
/// <param name="enforceNonNegativity">Enforce non-negative weights.</param>
219219
/// <param name="l1Regularization">Weight of L1 regularization term.</param>
220220
/// <param name="l2Regularization">Weight of L2 regularization term.</param>
221-
/// <param name="historySize">Memory size for <see cref="Microsoft.ML.Trainers.LogisticRegressionBinaryTrainer"/>. Low=faster, less accurate.</param>
221+
/// <param name="historySize">Memory size for <see cref="Microsoft.ML.Trainers.LbfgsLogisticRegressionTrainer"/>. Low=faster, less accurate.</param>
222222
/// <param name="optimizationTolerance">Threshold for optimizer convergence.</param>
223223
/// <param name="onFit">A delegate that is called every time the
224224
/// <see cref="Estimator{TInShape, TOutShape, TTransformer}.Fit(DataView{TInShape})"/> method is called on the

0 commit comments

Comments
 (0)