支持向量机--svm.SVC类

svm.SVC(*, C=1.0, kernel='rbf', degree=3, gamma='scale', coef0=0.0, shrinking=True, probability=False, tol=0.001, cache_size=200, class_weight=None, verbose=False, max_iter=- 1, decision_function_shape='ovr', break_ties=False, random_state=None)

参数

C

float, default=1.0
正则化参数。正则化程度与C成反比,必须严格保持积极,该惩罚项是I2的开平方

Regularization parameter. The strength of the regularization is inversely proportional to C. Must be strictly positive. The penalty is a squared l2 penalty.

kernel

{‘linear’, ‘poly’, ‘rbf’, ‘sigmoid’, ‘precomputed’} or callable, default=’rbf’
指定算法所使用的内核函数类型,默认rdf
如果该参数为可迭代类型,它的维度必须是(n_samples, n_samples).,它将用来从数据矩阵中预先计算得到核矩阵

Specifies the kernel type to be used in the algorithm. If none is given, ‘rbf’ will be used. If a callable is given it is used to pre-compute the kernel matrix from data matrices; that matrix should be an array of shape (n_samples, n_samples).

可选值描述
linear线性函数
poly多项式核函数
rbf高斯核函数(默认
sigmoidsigmoid函数
precomputed

degree

int, default=3
多项式核函数的阶数,仅当参数kernel='poly’时有效

Degree of the polynomial kernel function (‘poly’). Ignored by all other kernels.

gamma

{‘scale’, ‘auto’} or float, default=’scale’
核系数

Kernel coefficient for ‘rbf’, ‘poly’ and ‘sigmoid’.

可选值该参数取值
scale1 / (n_features * X.var())
auto1/n_features
float

coef0

float, default=0.0
核函数的独立期限,(当参数kernel=‘poly’,'sigmoid’时生效)

Independent term in kernel function. It is only significant in ‘poly’ and ‘sigmoid’.

shrinking

bool, default=True
是否使用启发式收缩

Whether to use the shrinking heuristic

probability

bool, default=False
是否启用概率估计

Whether to enable probability estimates. This must be enabled prior to calling fit, will slow down that method as it internally uses 5-fold cross-validation, and predict_proba may be inconsistent with predict. Read more in the User Guide.

tol

float, default=1e-3
算法的优化标准

Tolerance for stopping criterion.

cache_size

float, default=200
以MB为单位指定内核缓存大小

Specify the size of the kernel cache (in MB).

属性

class_weight_

ndarray of shape (n_classes,)
每个类参数c的乘数,基于属性class_weight计算

Multipliers of parameter C for each class. Computed based on the class_weight parameter.

classes_

ndarray of shape (n_classes,)
类标签

The classes labels.

coef_

ndarray of shape (n_classes * (n_classes - 1) / 2, n_features)
分配给每个特征的权重(当参数kernel='linear’时生效)

Weights assigned to the features when kernel=“linear”.

dual_coef_

ndarray of shape (n_classes -1, n_SV)
决策函数中支持向量的双系数

Dual coefficients of the support vector in the decision function (see Mathematical formulation), multiplied by their targets. For multiclass, coefficient for all 1-vs-1 classifiers. The layout of the coefficients in the multiclass case is somewhat non-trivial. See the multi-class section of the User Guide for details.

fit_status_

int
成功fit(拟合)将会返回0,否则返回1(触发警告)

0 if correctly fitted, 1 otherwise (will raise warning)

intercept_

ndarray of shape (n_classes * (n_classes - 1) / 2,)
决策函数中的常量

Constants in decision function.

n_features_in_

int
拟合过程中出现的特征数量

Number of features seen during fit.

feature_names_in_

ndarray of shape (n_features_in_,)
拟合过程中出现的特征名称(仅当参数X拥有字符串类型的特征名称时生效)

Names of features seen during fit. Defined only when X has feature names that are all strings.

n_iter_

ndarray of shape (n_classes * (n_classes - 1) // 2,)
为了拟合模型,优化算法运行的迭代次数。取决于优化模型的数量,后者又取决于类的数量

Number of iterations run by the optimization routine to fit the model. The shape of this attribute depends on the number of models optimized which in turn depends on the number of classes.

support_

ndarray of shape (n_SV)
支持向量的索引

Indices of support vectors.

support_vectors_

ndarray of shape (n_SV, n_features)
支持向量

Support vectors.

n_support_

ndarray of shape (n_classes,), dtype=int32
每个类的支持向量数量

Number of support vectors for each class.

probA_

ndarray of shape (n_classes * (n_classes - 1) / 2)
在platt scaling1(把模型的输出转化成一种基于类别的概率分布的方法)中学习到的参数

Parameter learned in Platt scaling when probability=True.

probB_

ndarray of shape (n_classes * (n_classes - 1) / 2)
在platt scaling(把模型的输出转化成一种基于类别的概率分布的方法)中学习到的参数

Parameter learned in Platt scaling when probability=True.

shape_fit_

tuple of int of shape (n_dimensions_of_X,)
用于训练的向量X的数组维度

Array dimensions of training vector X.

类方法

decision_function(X)

通过X中的样本数据评估决策函数

Evaluate the decision function for the samples in X.

fit(X, y[, sample_weight])

根据给定的训练数据拟合SVM模型

Fit the SVM model according to the given training data.

get_params([deep])

返回该模型的参数

Get parameters for this estimator.

predict(X)

对X中的样本进行分类

Perform classification on samples in X.

predict_log_proba(X)

计算X中样本的可能输出类型的概率的对数函数值

Compute log probabilities of possible outcomes for samples in X.

predict_proba(X)

计算X中样本的可能输出类型的概率

Compute probabilities of possible outcomes for samples in X.

score(X, y[, sample_weight])

根据给定的测试数据集和标签返回模型平均得分

Return the mean accuracy on the given test data and labels.

set_params(**params)

设置模型参数

Set the parameters of this estimator.


  1. 关于platt scaling可以参考博客:Platt scaling ↩︎

  • 0
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

夺笋123

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值