gpt4 book ai didi

machine-learning - svm.svm_predict_probability 方法(对于返回类型)如何工作?

转载 作者:行者123 更新时间:2023-11-30 09:30:01 29 4
gpt4 key购买 nike

认为我们有两个类别,其中有很多文档,其中一些属于第一类,其他属于第二类,我成功获得了类别模型,正如你所知 svm.svm_predict_probability方法返回 1 or -1

我想知道它什么时候返回1当它返回 -1 时我怎样才能找到分配给第一类别的数字以及分配给第二类别的数字

提前致谢,

最佳答案

根据libsvm FAQ :

Internally class labels are ordered by their first occurrence in the training set. For a k-class data, internally labels are 0, ..., k-1, and each two-class SVM considers pair (i, j) with i < j. Then class i is treated as positive (+1) and j as negative (-1). For example, if the data set has labels +5/+10 and +10 appears first, then internally the +5 versus +10 SVM problem has +10 as positive (+1) and +5 as negative (-1).

By this setting, if you have labels +1 and -1, it's possible that internally they correspond to -1 and +1, respectively. Some new users have been confused about this, so after version 3.17, if the data set has only two labels +1 and -1, internally we ensure +1 to be before -1. Then class +1 is always treated as positive in the SVM problem. Note that this is for two-class data only.

所以在现代libsvm(3.17之后)有两种情况:

  • 如果训练数据中有 +1 和 -1 类,则模型中的类是相同的
  • 否则,训练数据中出现的第一个类别为+1类别,第二个类别为-1类别

内部决策是根据SVM问题的具体表述做出的,可以简单地表述为:

f(x) = sgn( SUM_i alpha_i y_i K(SV_i,x) + b )

哪里

  • alpha_i - 优化过程中发现的拉格朗系数(针对第 i 个支持向量)
  • y_i - 第 i 个支持向量的标签
  • SV_i - 第 i 个支持向量
  • b - 截距/偏差值(优化过程中发现)
  • K(.,.) - 训练中使用的核函数,例如线性核 K(x,y) = x'y,或 rbf 核 K(x,y) = exp(-gamma ||x-y|| ^2)

关于machine-learning - svm.svm_predict_probability 方法(对于返回类型)如何工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21305302/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com