支持R中数据实例加权的SVM软件包

问题描述 投票:1回答:1

我正在R中寻找一个SVM软件包,该软件包接受为每个数据实例指定权重。我发现e1071包,它提供了带有class.weights参数的类加权选项,但是它不提供任何实例加权选项。我还找到了wsvm程序包,但都没有提供该功能。我正在寻找R中的libsvm-weights-3.17之类的东西。

r svm libsvm
1个回答
0
投票

尝试此软件包: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.

© www.soinside.com 2019 - 2024. All rights reserved.