简体   繁体   English

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

[英]SVM packages that support data instances weighting in R

I am looking for a SVM package in R that accepts specifying a weight for each instance of the data.我正在 R 中寻找一个支持为每个数据实例指定权重的 SVM 包。 I have found e1071 package, it provides a class weighting option with class.weights parameter, but it does not provide any option for instance weighting.我找到了e1071包,它提供了一个带有class.weights参数的类权重选项,但它没有提供任何实例权重选项。 I also found wsvm package, but neither it provides that functionality.我还找到了wsvm包,但它都没有提供该功能。 I am looking for something like libsvm-weights-3.17 in R.我正在 R 中寻找类似libsvm-weights-3.17 的东西。

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

It uses a modified version of 'libsvm' and is able to deal with instance weighting.它使用“libsvm”的修改版本,并且能够处理实例权重。

For example.例如。 You have simulated data (x,y)您有模拟数据 (x,y)

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

This is an unweighted SVM:这是一个未加权的 SVM:

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

Blue dots is the unweighted SVM and do not fit the first instance well.蓝点是未加权的 SVM,不适合第一个实例。 We want to put more weights on the first several instances.我们想在前几个实例上放置更多的权重。

So we can use a weighted SVM:所以我们可以使用加权 SVM:

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

Green dots is the weighted SVM and fit the first instance better.绿点是加权 SVM,更适合第一个实例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM