LinearSvmTrainer 类
定义
IEstimator<TTransformer>使用线性 SVM 定型的线性二元分类模型预测目标的。
public sealed class LinearSvmTrainer : Microsoft.ML.Trainers.OnlineLinearTrainer<Microsoft.ML.Data.BinaryPredictionTransformer<Microsoft.ML.Trainers.LinearBinaryModelParameters>,Microsoft.ML.Trainers.LinearBinaryModelParameters>
type LinearSvmTrainer = class
inherit OnlineLinearTrainer<BinaryPredictionTransformer<LinearBinaryModelParameters>, LinearBinaryModelParameters>
Public NotInheritable Class LinearSvmTrainer
Inherits OnlineLinearTrainer(Of BinaryPredictionTransformer(Of LinearBinaryModelParameters), LinearBinaryModelParameters)
- 继承
注解
To create this trainer, use LinearSvm or LinearSvm(Options).
Input and Output Columns
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 . |
Trainer Characteristics
机器学习任务 | 二元分类 |
是否需要规范化? | 是 |
是否需要缓存? | 否 |
除 Microsoft.ML 外,必需的 NuGet | 无 |
可导出到 ONNX | 是 |
Training Algorithm Details
Linear SVM implements an algorithm that finds a hyperplane in the feature space for binary classification, by solving an SVM problem. For instance, with feature values $f_0, f_1,..., f_{D-1}$, the prediction is given by determining what side of the hyperplane the point falls into. That is the same as the sign of the feautures' weighted sum, i.e. $\sum_{i = 0}^{D-1} \left(w_i * f_i \right) + b$, where $w_0, w_1,..., w_{D-1}$ are the weights computed by the algorithm, and $b$ is the bias computed by the algorithm.
Linear SVM implements the PEGASOS method, which alternates between stochastic gradient descent steps and projection steps, introduced in this paper by Shalev-Shwartz, Singer and Srebro.
Check the See Also section for links to usage examples.
字段
FeatureColumn |
讲师期望的功能列。 (继承自 TrainerEstimatorBase<TTransformer,TModel>) |
LabelColumn |
讲师期望的标签列。 可以为 |
WeightColumn |
讲师期望的权重列。 可以为 |
属性
Info | (继承自 OnlineLinearTrainer<TTransformer,TModel>) |
方法
Fit(IDataView) |
训练并返回一个 ITransformer 。 (继承自 TrainerEstimatorBase<TTransformer,TModel>) |
Fit(IDataView, LinearModelParameters) |
继续 OnlineLinearTrainer<TTransformer,TModel> 使用已定型的培训 |
GetOutputSchema(SchemaShape) | (继承自 TrainerEstimatorBase<TTransformer,TModel>) |
扩展方法
AppendCacheCheckpoint<TTrans>(IEstimator<TTrans>, IHostEnvironment) |
将 "缓存检查点" 追加到估计器链。 这将确保下游估算将针对缓存的数据进行训练。 在执行多个数据传递的培训之前,最好具有一个缓存检查点。 |
WithOnFitDelegate<TTransformer>(IEstimator<TTransformer>, Action<TTransformer>) |
给定一个估计器,返回一个将调用委托的包装对象 Fit(IDataView) 。 通常,估计器返回有关内容的信息是非常重要的,这就是该 Fit(IDataView) 方法返回特定类型的对象而不只是常规的原因 ITransformer 。 但同时, IEstimator<TTransformer> 通常会形成包含多个对象的管道,因此,我们可能需要通过 EstimatorChain<TLastTransformer> 在其中获得转换器的估计器在此链中的某个位置,来构建估算链。 对于这种情况,我们可以通过此方法附加将调用的委托。 |