【问题标题】:SVM packages that support data instances weighting in R在 R 中支持数据实例加权的 SVM 包
【发布时间】:2018-12-06 17:00:55
【问题描述】:

我正在寻找 R 中的 SVM 包,它接受为每个数据实例指定权重。我找到了e1071 包,它提供了一个带有 class.weights 参数的类权重选项,但它没有提供任何实例权重选项。我还找到了wsvm 包,但它都没有提供该功能。我在 R 中寻找类似 @​​987654323@ 的东西。

【问题讨论】:

标签: r svm libsvm


【解决方案1】:

试试这个包:https://CRAN.R-project.org/package=WeightSVM

它使用'libsvm' 的修改版本并且能够处理实例权重。

例如。你有模拟数据 (x,y)

x <- seq(0.1, 5, by = 0.05)
y <- log(x) + rnorm(x, sd = 0.2)

这是一个未加权的 SVM:

model1 <- wsvm(x, y, weight = rep(1,99))

Blue dots is the unweighted SVM and do not fit the first instance well. We want to put more weights on the first several instances.

所以我们可以使用加权 SVM:

model2 <- wsvm(x, y, weight = seq(99,1,length.out = 99))

Green dots is the weighted SVM and fit the first instance better.

【讨论】:

    猜你喜欢
    • 2016-06-21
    • 2019-04-02
    • 1970-01-01
    • 2018-09-04
    • 2013-05-27
    • 2019-06-04
    • 2011-03-27
    • 2020-09-01
    • 2020-11-14
    相关资源
    最近更新 更多