Multiclass SVM SKLearn 中返回了哪些支​​持向量 [英] Which Support Vectors returned in Multiclass SVM SKLearn

查看:49
本文介绍了Multiclass SVM SKLearn 中返回了哪些支​​持向量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

默认情况下,SKLearn 使用

解决方案

更新:dual_coef_ 是关键,它为您提供决策函数中支持向量的系数.每个支持向量都用于 n_class - 1 个分类器.每行中的 n_class - 1 个条目对应于这些分类器的双系数.".

<块引用>

看看本节的最后(1.4.1.1),表格清楚地解释了它http://scikit-learn.org/stable/modules/svm.html#multi-class-classification)

实现细节也让我很困惑.多类决策函数中支持向量的系数非常重要.

但是,每当我想详细了解所选支持向量的特定属性时,我都会使用以下经验法则:

y[svm.support_]

输出:

array([0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2])

通过这种方式,您可以了解(可能出于调试目的)哪个支持向量对应于哪个类.当然,您可以检查支持向量:

X[svm.support_]

我的直觉是,顾名思义,您可以获取相关类别的样本子集.假设我们有 3 个类别 A、B 和 C:

  • A vs. B --> 它为您提供了来自 A 和 B (a,a,a,b,b,...) 的多个支持向量
  • A vs. C --> 相同... a,a,a,c,c,c,c(可能之前重复了一些a")
  • B 与 C --> 同上

所以 svm.support_vectors_ 返回所有支持向量 但是它如何在 decision_function 中使用对我来说仍然很棘手,因为我'我不确定在做 A 对 C 对时它是否可以使用来自 A 对 B 的支持向量 - 而且我找不到实现细节(http://scikit-learn.org/stable/modules/generated/sklearn.multiclass.OneVsOneClassifier.html#sklearn.multiclass.OneVsOneClassifier.decision_function)

By default, SKLearn uses a One vs One classification scheme when training SVM's in the multiclass case.

I'm a bit confused as to, when you call attributes such as svm.n_support_ or svm.support_vectors_, which support vectors you're getting? For instance, in the case of iris dataset, there are 3 classes, so there should be a total of 3*(3-1)/2 = 3 different SVM classifiers built. Of which classifier are you getting support vectors back?

解决方案

Update: dual_coef_ is the key, giving you the coefficients of the support vectors in the decision function. "Each of the support vectors is used in n_class - 1 classifiers. The n_class - 1 entries in each row correspond to the dual coefficients for these classifiers." .

Take a look at the very end of this section (1.4.1.1), the table clearly explains it http://scikit-learn.org/stable/modules/svm.html#multi-class-classification)

Implementation details are very confusing to me as well. Coefficients of the support vector in the decision function for multiclass are non-trivial.

But here is the rule of thumb I use whenever I want to go into detail of specific properties of chosen support vectors:

y[svm.support_]

outputs:

array([0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
       1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2])

This way you get to know (maybe for debugging purposes) which support vector corresponds to which class. And of course you can check support vectors:

X[svm.support_]

My intuition here is that, as its name indicates, you take subsets of samples of the involved categories. Let's say we have 3 categories A, B and C:

  • A vs. B --> it gives you several support vectors from A and B (a,a,a,b,b,...)
  • A vs. C --> same... a,a,a,c,c,c,c (maybe some 'a' are repeated from before)
  • B vs. C --> idem

So the svm.support_vectors_ returns all the support vectors but how it uses then in the decision_function is still tricky to me as I'm not sure if it could use for example support vectors from A vs. B when doing the pair A vs. C - and I couldn't find implementation details (http://scikit-learn.org/stable/modules/generated/sklearn.multiclass.OneVsOneClassifier.html#sklearn.multiclass.OneVsOneClassifier.decision_function)

这篇关于Multiclass SVM SKLearn 中返回了哪些支​​持向量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆