例如,有没有办法统计这个分类模型中支持向量的数量?
library(LiblineaR)
data(iris)
attach(iris)
x <- iris[,1:4]
y <- factor(iris[, 5])
set.seed(1)
train <- sample(1:dim(iris)[1],100)
detach(iris)
xTrain <- x[train,]
xTest <- x[-train,]
yTrain <- y[train]
yTest <- y[-train]
s <- scale(xTrain, center=T, scale=T)
m <- LiblineaR(data=s, target=yTrain, type=5, cost=0.1)
m
输出
$TypeDetail
[1] "L1-regularized L2-loss support vector classification (L1R_L2LOSS_SVC)"
$Type
[1] 5
$W
Sepal.Length Sepal.Width Petal.Length Petal.Width Bias
setosa 0 0.2075367 -0.9154018 0.000000 -0.4105989
versicolor 0 -0.4238142 0.0303085 0.000000 -0.2447197
virginica 0 0.0000000 0.0000000 1.183732 -0.6795709
$Bias
[1] 1
$ClassNames
[1] setosa versicolor virginica
Levels: setosa versicolor virginica
$NbClass
[1] 3
attr(,"class")
[1] "LiblineaR"