SdcaLogisticRegressionBinaryTrainer Class
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
The IEstimator<TTransformer> for training a binary logistic regression classification model using the stochastic dual coordinate ascent method. The trained model is calibrated and can produce probability by feeding the output value of the linear function to a PlattCalibrator.
public sealed class SdcaLogisticRegressionBinaryTrainer : Microsoft.ML.Trainers.SdcaBinaryTrainerBase<Microsoft.ML.Calibrators.CalibratedModelParametersBase<Microsoft.ML.Trainers.LinearBinaryModelParameters,Microsoft.ML.Calibrators.PlattCalibrator>>
type SdcaLogisticRegressionBinaryTrainer = class
inherit SdcaBinaryTrainerBase<CalibratedModelParametersBase<LinearBinaryModelParameters, PlattCalibrator>>
Public NotInheritable Class SdcaLogisticRegressionBinaryTrainer
Inherits SdcaBinaryTrainerBase(Of CalibratedModelParametersBase(Of LinearBinaryModelParameters, PlattCalibrator))
- Inheritance
-
SdcaTrainerBase<SdcaBinaryTrainerBase<TModelParameters>.BinaryOptionsBase,BinaryPredictionTransformer<TModelParameters>,TModelParameters>SdcaLogisticRegressionBinaryTrainer
To create this trainer, use SdcaLogisticRegression or SdcaLogisticRegression(Options).
The input label column data must be Boolean. The input features column data must be a known-sized vector of Single.
This trainer outputs the following columns:
Output Column Name | Column Type | Description | |
---|---|---|---|
Score |
Single | The unbounded score that was calculated by the model. | |
PredictedLabel |
Boolean | The predicted label, based on the sign of the score. A negative score maps to false and a positive score maps to true . |
|
Probability |
Single | The probability calculated by calibrating the score of having true as the label. Probability value is in range [0, 1]. |
Machine learning task | Binary classification |
Is normalization required? | Yes |
Is caching required? | No |
Required NuGet in addition to Microsoft.ML | None |
Exportable to ONNX | Yes |
This trainer is based on the Stochastic Dual Coordinate Ascent (SDCA) method, a state-of-the-art optimization technique for convex objective functions. The algorithm can be scaled because it's a streaming training algorithm as described in a KDD best paper.
Convergence is underwritten by periodically enforcing synchronization between primal and dual variables in a separate thread. Several choices of loss functions are also provided such as hinge-loss and logistic loss. Depending on the loss used, the trained model can be, for example, support vector machine or logistic regression. The SDCA method combines several of the best properties such the ability to do streaming learning (without fitting the entire data set into your memory), reaching a reasonable result with a few scans of the whole data set (for example, see experiments in this paper), and spending no computation on zeros in sparse data sets.
Note that SDCA is a stochastic and streaming optimization algorithm. The result depends on the order of training data because the stopping tolerance is not tight enough. In strongly-convex optimization, the optimal solution is unique and therefore everyone eventually reaches the same place. Even in non-strongly-convex cases, you will get equally-good solutions from run to run. For reproducible results, it is recommended that one sets 'Shuffle' to False and 'NumThreads' to 1.
This class uses empirical risk minimization (i.e., ERM)
to formulate the optimization problem built upon collected data.
Note that empirical risk is usually measured by applying a loss function on the model's predictions on collected data points.
If the training data does not contain enough data points
(for example, to train a linear model in
Together with the implemented optimization algorithm, L1-norm regularization can increase the sparsity of the model weights,
An aggressive regularization (that is, assigning large coefficients to L1-norm or L2-norm regularization terms) can harm predictive capacity by excluding important variables from the model. For example, a very large L1-norm coefficient may force all parameters to be zeros and lead to a trivial model. Therefore, choosing the right regularization coefficients is important in practice.
For more information, see:
- Scaling Up Stochastic Dual Coordinate Ascent.
- Stochastic Dual Coordinate Ascent Methods for Regularized Loss Minimization.
Check the See Also section for links to examples of the usage.
Feature |
The feature column that the trainer expects. (Inherited from TrainerEstimatorBase<TTransformer,TModel>) |
Label |
The label column that the trainer expects. Can be |
Weight |
The weight column that the trainer expects. Can be |
Info | (Inherited from SdcaBinaryTrainerBase<TModelParameters>) |
Fit(IData |
Trains and returns a ITransformer. (Inherited from TrainerEstimatorBase<TTransformer,TModel>) |
Get |
(Inherited from TrainerEstimatorBase<TTransformer,TModel>) |
Append |
Append a 'caching checkpoint' to the estimator chain. This will ensure that the downstream estimators will be trained against cached data. It is helpful to have a caching checkpoint before trainers that take multiple data passes. |
With |
Given an estimator, return a wrapping object that will call a delegate once Fit(IDataView) is called. It is often important for an estimator to return information about what was fit, which is why the Fit(IDataView) method returns a specifically typed object, rather than just a general ITransformer. However, at the same time, IEstimator<TTransformer> are often formed into pipelines with many objects, so we may need to build a chain of estimators via EstimatorChain<TLastTransformer> where the estimator for which we want to get the transformer is buried somewhere in this chain. For that scenario, we can through this method attach a delegate that will be called once fit is called. |
Продукт | Версии |
---|---|
ML.NET | 1.0.0, 1.1.0, 1.2.0, 1.3.1, 1.4.0, 1.5.0, 1.6.0, 1.7.0, 2.0.0, 3.0.0, Preview, 4.0.0 |
- SdcaLogisticRegression(BinaryClassificationCatalog+BinaryClassificationTrainers, SdcaLogisticRegressionBinaryTrainer+Options)
- SdcaLogisticRegressionBinaryTrainer.Options
- SdcaLogisticRegression(BinaryClassificationCatalog+BinaryClassificationTrainers, String, String, String, Nullable<Single>, Nullable<Single>, Nullable<Int32>)