16
16
using Microsoft . ML . Numeric ;
17
17
using Microsoft . ML . Training ;
18
18
19
- [ assembly: LoadableClass ( LogisticRegression . Summary , typeof ( LogisticRegression ) , typeof ( LogisticRegression . Arguments ) ,
19
+ [ assembly: LoadableClass ( LogisticRegression . Summary , typeof ( LogisticRegression ) , typeof ( LogisticRegression . Options ) ,
20
20
new [ ] { typeof ( SignatureBinaryClassifierTrainer ) , typeof ( SignatureTrainer ) , typeof ( SignatureFeatureScorerTrainer ) } ,
21
21
LogisticRegression . UserNameValue ,
22
22
LogisticRegression . LoadNameValue ,
@@ -30,15 +30,15 @@ namespace Microsoft.ML.Learners
30
30
31
31
/// <include file='doc.xml' path='doc/members/member[@name="LBFGS"]/*' />
32
32
/// <include file='doc.xml' path='docs/members/example[@name="LogisticRegressionBinaryClassifier"]/*' />
33
- public sealed partial class LogisticRegression : LbfgsTrainerBase < LogisticRegression . Arguments , BinaryPredictionTransformer < ParameterMixingCalibratedPredictor > , ParameterMixingCalibratedPredictor >
33
+ public sealed partial class LogisticRegression : LbfgsTrainerBase < LogisticRegression . Options , BinaryPredictionTransformer < ParameterMixingCalibratedPredictor > , ParameterMixingCalibratedPredictor >
34
34
{
35
35
public const string LoadNameValue = "LogisticRegression" ;
36
36
internal const string UserNameValue = "Logistic Regression" ;
37
37
internal const string ShortName = "lr" ;
38
38
internal const string Summary = "Logistic Regression is a method in statistics used to predict the probability of occurrence of an event and can "
39
39
+ "be used as a classification algorithm. The algorithm predicts the probability of occurrence of an event by fitting data to a logistical function." ;
40
40
41
- public sealed class Arguments : ArgumentsBase
41
+ public sealed class Options : ArgumentsBase
42
42
{
43
43
/// <summary>
44
44
/// If set to <value>true</value>training statistics will be generated at the end of training.
@@ -53,7 +53,7 @@ public sealed class Arguments : ArgumentsBase
53
53
/// <summary>
54
54
/// The instance of <see cref="ComputeLRTrainingStd"/> that computes the std of the training statistics, at the end of training.
55
55
/// The calculations are not part of Microsoft.ML package, due to the size of MKL.
56
- /// If you need these calculations, add the Microsoft.ML.HalLearners package, and initialize <see cref="LogisticRegression.Arguments .StdComputer"/>.
56
+ /// If you need these calculations, add the Microsoft.ML.HalLearners package, and initialize <see cref="LogisticRegression.Options .StdComputer"/>.
57
57
/// to the <see cref="ComputeLRTrainingStd"/> implementation in the Microsoft.ML.HalLearners package.
58
58
/// </summary>
59
59
public ComputeLRTrainingStd StdComputer ;
@@ -74,18 +74,16 @@ public sealed class Arguments : ArgumentsBase
74
74
/// <param name="l2Weight">Weight of L2 regularizer term.</param>
75
75
/// <param name="memorySize">Memory size for <see cref="LogisticRegression"/>. Low=faster, less accurate.</param>
76
76
/// <param name="optimizationTolerance">Threshold for optimizer convergence.</param>
77
- /// <param name="advancedSettings">A delegate to apply all the advanced arguments to the algorithm.</param>
78
- public LogisticRegression ( IHostEnvironment env ,
77
+ internal LogisticRegression ( IHostEnvironment env ,
79
78
string labelColumn = DefaultColumnNames . Label ,
80
79
string featureColumn = DefaultColumnNames . Features ,
81
80
string weights = null ,
82
- float l1Weight = Arguments . Defaults . L1Weight ,
83
- float l2Weight = Arguments . Defaults . L2Weight ,
84
- float optimizationTolerance = Arguments . Defaults . OptTol ,
85
- int memorySize = Arguments . Defaults . MemorySize ,
86
- bool enforceNoNegativity = Arguments . Defaults . EnforceNonNegativity ,
87
- Action < Arguments > advancedSettings = null )
88
- : base ( env , featureColumn , TrainerUtils . MakeBoolScalarLabel ( labelColumn ) , weights , advancedSettings ,
81
+ float l1Weight = Options . Defaults . L1Weight ,
82
+ float l2Weight = Options . Defaults . L2Weight ,
83
+ float optimizationTolerance = Options . Defaults . OptTol ,
84
+ int memorySize = Options . Defaults . MemorySize ,
85
+ bool enforceNoNegativity = Options . Defaults . EnforceNonNegativity )
86
+ : base ( env , featureColumn , TrainerUtils . MakeBoolScalarLabel ( labelColumn ) , weights ,
89
87
l1Weight , l2Weight , optimizationTolerance , memorySize , enforceNoNegativity )
90
88
{
91
89
Host . CheckNonEmpty ( featureColumn , nameof ( featureColumn ) ) ;
@@ -98,8 +96,8 @@ public LogisticRegression(IHostEnvironment env,
98
96
/// <summary>
99
97
/// Initializes a new instance of <see cref="LogisticRegression"/>
100
98
/// </summary>
101
- internal LogisticRegression ( IHostEnvironment env , Arguments args )
102
- : base ( env , args , TrainerUtils . MakeBoolScalarLabel ( args . LabelColumn ) )
99
+ internal LogisticRegression ( IHostEnvironment env , Options options )
100
+ : base ( env , options , TrainerUtils . MakeBoolScalarLabel ( options . LabelColumn ) )
103
101
{
104
102
_posWeight = 0 ;
105
103
ShowTrainingStats = Args . ShowTrainingStats ;
@@ -410,14 +408,14 @@ protected override ParameterMixingCalibratedPredictor CreatePredictor()
410
408
XmlInclude = new [ ] { @"<include file='../Microsoft.ML.StandardLearners/Standard/LogisticRegression/doc.xml' path='doc/members/member[@name=""LBFGS""]/*' />" ,
411
409
@"<include file='../Microsoft.ML.StandardLearners/Standard/LogisticRegression/doc.xml' path='doc/members/example[@name=""LogisticRegressionBinaryClassifier""]/*' />" } ) ]
412
410
413
- public static CommonOutputs . BinaryClassificationOutput TrainBinary ( IHostEnvironment env , Arguments input )
411
+ public static CommonOutputs . BinaryClassificationOutput TrainBinary ( IHostEnvironment env , Options input )
414
412
{
415
413
Contracts . CheckValue ( env , nameof ( env ) ) ;
416
414
var host = env . Register ( "TrainLRBinary" ) ;
417
415
host . CheckValue ( input , nameof ( input ) ) ;
418
416
EntryPointUtils . CheckInputArgs ( host , input ) ;
419
417
420
- return LearnerEntryPointsUtils . Train < Arguments , CommonOutputs . BinaryClassificationOutput > ( host , input ,
418
+ return LearnerEntryPointsUtils . Train < Options , CommonOutputs . BinaryClassificationOutput > ( host , input ,
421
419
( ) => new LogisticRegression ( host , input ) ,
422
420
( ) => LearnerEntryPointsUtils . FindColumn ( host , input . TrainingData . Schema , input . LabelColumn ) ,
423
421
( ) => LearnerEntryPointsUtils . FindColumn ( host , input . TrainingData . Schema , input . WeightColumn ) ) ;
@@ -437,7 +435,7 @@ public abstract class ComputeLRTrainingStd
437
435
/// Computes the standard deviation matrix of each of the non-zero training weights, needed to calculate further the standard deviation,
438
436
/// p-value and z-Score.
439
437
/// The calculations are not part of Microsoft.ML package, due to the size of MKL.
440
- /// If you need these calculations, add the Microsoft.ML.HalLearners package, and initialize <see cref="LogisticRegression.Arguments .StdComputer"/>
438
+ /// If you need these calculations, add the Microsoft.ML.HalLearners package, and initialize <see cref="LogisticRegression.Options .StdComputer"/>
441
439
/// to the <see cref="ComputeLRTrainingStd"/> implementation in the Microsoft.ML.HalLearners package.
442
440
/// Due to the existence of regularization, an approximation is used to compute the variances of the trained linear coefficients.
443
441
/// </summary>
0 commit comments