kernlab

R caret unusually slow when tuning SVM with linear kernel

家住魔仙堡 提交于 2021-02-07 18:31:28
问题 I have observed a very strange behavior when tuning SVM parameters with caret . When training a single model without tuning, SVM with radial basis kernel takes more time than SVM with linear kernel, which is expected. However, when tuning SVM with both kernels over the same penalty grid, SVM with linear kernel takes substantially more time than SVM with radial basis kernel. This behavior can be easily reproduced in both Windows and Linux with R 3.2 and caret 6.0-47. Does anyone know why

Plot SVM linear model trained by caret package in R

醉酒当歌 提交于 2020-07-22 03:19:38
问题 Purpose I was trying to visualize SVMLinear classification model via plot . I am using the example code and data provided in kernlab package having noticed caret actually train svm via ksvm function (referring to src code here (https://github.com/topepo/caret/blob/master/models/files/svmLinear.R)) Problem When I plot the final model of caret model object, it did not yield figure. And I did not find a way out after I tried three ways. Code require(caret) require(kernlab) # ===== sample codes

Plot SVM linear model trained by caret package in R

狂风中的少年 提交于 2020-07-22 03:18:12
问题 Purpose I was trying to visualize SVMLinear classification model via plot . I am using the example code and data provided in kernlab package having noticed caret actually train svm via ksvm function (referring to src code here (https://github.com/topepo/caret/blob/master/models/files/svmLinear.R)) Problem When I plot the final model of caret model object, it did not yield figure. And I did not find a way out after I tried three ways. Code require(caret) require(kernlab) # ===== sample codes

Class Weight Syntax in Kernlab?

北战南征 提交于 2019-12-24 07:59:21
问题 Hi I am trying out classification for imbalanced dataset in R using kernlab package, as the class distribution is not 1:1 I am using the option of class.weights in the ksvm() function call however I do not get any difference in the classification scenario when I add weights or remove weights? So the question is what is the correct syntax for declaring the class weights? I am using the following function calls: model = ksvm(dummy[1:466], lab_tr,type='C-svc',kernel=pre,cross=10,C=10,prob.model

Why are probabilities and response in ksvm in R not consistent?

依然范特西╮ 提交于 2019-12-18 05:47:38
问题 I am using ksvm from the kernlab package in R to predict probabilities, using the type="probabilities" option in predict.ksvm . However, I find that sometimes using predict(model,observation,type="r") yields not the class with the highest probability given by predict(model,observation,type="p") . Example: > predict(model,observation,type="r") [1] A Levels: A B > predict(model,observation,type="p") A B [1,] 0.21 0.79 Is this correct behavior, or a bug? If it is correct behavior, how can I

Kernlab kraziness: inconsistent results for identical problems

ぃ、小莉子 提交于 2019-12-12 12:19:39
问题 I've found some puzzling behavior in the kernlab package: estimating SVMs which are mathematically identical produces different results in software. This code snippet just takes the iris data and makes it a binary classification problem for the sake of simplicity. As you can see, I'm using linear kernels in both SVMs. library(kernlab) library(e1071) data(iris) x <- as.matrix(iris[, 1:4]) y <- as.factor(ifelse(iris[, 5] == 'versicolor', 1, -1)) C <- 5.278031643091578 svm1 <- ksvm(x = x, y = y,

R: SVM performance using custom kernel (user defined kernel) is not working in kernlab

半世苍凉 提交于 2019-12-10 20:23:49
问题 I'm trying to use user defined kernel. I know that kernlab offer user defined kernel(custom kernel functions) in R. I used data spam including package kernlab. (number of variables=57 number of examples =4061) I'm defined kernel's form, kp=function(d,e){ as=v*d bs=v*e cs=as-bs cs=as.matrix(cs) exp(-(norm(cs,"F")^2)/2) } class(kp)="kernel" It is the transformed kernel for gaussian kernel, where v is the continuously changed values that are inverse of standard deviation vector about each

kernel matrix computation outside SVM training in kernlab

丶灬走出姿态 提交于 2019-12-06 06:14:31
问题 I was developing a new algorithm that generates a modified kernel matrix for training with a SVM and encountered a strange problem. For testing purposes I was comparing the SVM models learned using kernelMatrix interface and normal kernel interface. For example, # Model with kernelMatrix computation within ksvm svp1 <- ksvm(x, y, type="C-svc", kernel=vanilladot(), scaled=F) # Model with kernelMatrix computed outside ksvm K <- kernelMatrix(vanilladot(), x) svp2 <- ksvm(K, y, type="C-svc")

Line search fails in training ksvm prob.model

吃可爱长大的小学妹 提交于 2019-12-03 16:13:03
问题 Following up from Invalid probability model for large support vector machines using ksvm in R: I am training an SVM using ksvm from the kernlab package in R. I want to use the probability model, but during the sigmoid fitting I get the following error message: line search fails -1.833726 0.5772808 5.844462e-05 5.839508e-05 -1.795008e-08 -1.794263e-08 -2.096847e-12 When this happens, the resulting value of prob.model(m) is a vector of all probabilities, rather than the expected parameters of a

Line search fails in training ksvm prob.model

不羁的心 提交于 2019-12-03 05:32:11
Following up from Invalid probability model for large support vector machines using ksvm in R : I am training an SVM using ksvm from the kernlab package in R. I want to use the probability model, but during the sigmoid fitting I get the following error message: line search fails -1.833726 0.5772808 5.844462e-05 5.839508e-05 -1.795008e-08 -1.794263e-08 -2.096847e-12 When this happens, the resulting value of prob.model(m) is a vector of all probabilities, rather than the expected parameters of a sigmoid function fitted over these probabilities. What causes this error and how can I prevent it?