【问题标题】:Number of Support vectors in SVMSVM 中的支持向量数
【发布时间】:2022-05-10 03:00:07
【问题描述】:

如何打印特定 SVM 模型的支持向量数量? 请在 Python 中建议一个代码 sn-p。

from sklearn.multiclass import OneVsRestClassifier

x, y = make_classification(n_samples=1000, n_features=10, n_informative=5,
                           n_redundant=5, n_classes=3, random_state=1)
model = SVC()
ovr = OneVsRestClassifier(model)
ovr.fit(x, y)
ovr.support_vectors_

最后一行打印出所有支持向量,但不打印支持向量的数量。

【问题讨论】:

标签: python machine-learning vector svm


【解决方案1】:

使用len()

len(ovr.support_vectors_)

【讨论】:

    猜你喜欢
    • 2011-11-09
    • 2015-02-08
    • 2023-03-15
    • 2019-06-27
    • 2016-06-21
    • 2020-07-13
    • 2018-10-26
    • 2016-03-17
    • 2013-08-21
    相关资源
    最近更新 更多