正在加载图片...
10 Support Vector Machines in R type ="C-bsvc",kernel ="rbfdot", kpar list(sigma =0.1),C=10, prob.model TRUE) irismodel Support Vector Machine object of class "ksvm" SV type:C-bsvc (classification) parameter cost C =10 Gaussian Radial Basis kernel function. Hyperparameter sigma =0.1 Number of Support Vectors 32 Training error:0.02 Probability model included. predict(irismodel,iris[c(3,10,56,68, 107,120),-5],type "probabilities") setosa versicolor virginica [1,]0.9864328200.0073594070.006207773 [2,]0.9833238130.0101189920.006557195 [3,]0.0048525280.9675551260.027592346 [4,]0.0095468230.9884967240.001956452 [5,]0.0127673400.0694960290.917736631 [6,]0.0115481760.1500353840.838416441 predict(irismodel,iris[c(3,10,56,68, 107,120),-5],type "decision") [,1] [,2] [,3] [1,]-1.460398-1.1910251-3.8868836 [2,]-1.357355-1.1749491-4.2107843 [3,]1.647272 0.7655001-1.3205306 [4,]1.412721 0.4736201-2.7521640 [5,]1.844763 1.00000001.0000019 [6,]1.848985 1.00690100.6742889 ksvm allows for the use of any valid user defined kernel function by just defining a function which takes two vector arguments and returns its Hilbert Space dot product in scalar form. >k <-function(x,y) (sum(x*y)+1)*exp(0.001*sum((x- y)2) +}10 Support Vector Machines in R + type = "C-bsvc", kernel = "rbfdot", + kpar = list(sigma = 0.1), C = 10, + prob.model = TRUE) > irismodel Support Vector Machine object of class "ksvm" SV type: C-bsvc (classification) parameter : cost C = 10 Gaussian Radial Basis kernel function. Hyperparameter : sigma = 0.1 Number of Support Vectors : 32 Training error : 0.02 Probability model included. > predict(irismodel, iris[c(3, 10, 56, 68, + 107, 120), -5], type = "probabilities") setosa versicolor virginica [1,] 0.986432820 0.007359407 0.006207773 [2,] 0.983323813 0.010118992 0.006557195 [3,] 0.004852528 0.967555126 0.027592346 [4,] 0.009546823 0.988496724 0.001956452 [5,] 0.012767340 0.069496029 0.917736631 [6,] 0.011548176 0.150035384 0.838416441 > predict(irismodel, iris[c(3, 10, 56, 68, + 107, 120), -5], type = "decision") [,1] [,2] [,3] [1,] -1.460398 -1.1910251 -3.8868836 [2,] -1.357355 -1.1749491 -4.2107843 [3,] 1.647272 0.7655001 -1.3205306 [4,] 1.412721 0.4736201 -2.7521640 [5,] 1.844763 1.0000000 1.0000019 [6,] 1.848985 1.0069010 0.6742889 ksvm allows for the use of any valid user defined kernel function by just defining a function which takes two vector arguments and returns its Hilbert Space dot product in scalar form. > k <- function(x, y) { + (sum(x * y) + 1) * exp(0.001 * sum((x - + y)^2)) + }
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有