r-caret

Caret package - cross-validating GAM with both smooth and linear predictors

独自空忆成欢 提交于 2020-08-21 18:37:06
问题 I would like to cross validate a GAM model using caret. My GAM model has a binary outcome variable, an isotropic smooth of latitude and longitude coordinate pairs, and then linear predictors. Typical syntax when using mgcv is: gam1 <- gam( y ~ s(lat , long) + x1 + x2, family = binomial(logit) ) I'm not quite sure how to specify this model using the train function in caret. This is my syntax more or less: cv <- train(y ~ lat + long + x1 + x2, data = data, method = "gam", family = "binomial",

Setting hidden layers and neurons in neuralnet and caret (R)

≯℡__Kan透↙ 提交于 2020-07-23 06:32:09
问题 I would like to cross-validate a neural network using the package neuralnet and caret . The data df can be copied from this post. When running the neuralnet() function, there is an argument called hidden where you can set the hidden layers and neurons in each. Let's say I want 2 hidden layers with 3 and 2 neurons respectively. It would be written as hidden = c(3, 2) . However, as I want to cross-validate it, I decided to use the fantastic caret package. But when using the function train() , I

Setting hidden layers and neurons in neuralnet and caret (R)

早过忘川 提交于 2020-07-23 06:31:19
问题 I would like to cross-validate a neural network using the package neuralnet and caret . The data df can be copied from this post. When running the neuralnet() function, there is an argument called hidden where you can set the hidden layers and neurons in each. Let's say I want 2 hidden layers with 3 and 2 neurons respectively. It would be written as hidden = c(3, 2) . However, as I want to cross-validate it, I decided to use the fantastic caret package. But when using the function train() , I

Setting hidden layers and neurons in neuralnet and caret (R)

心已入冬 提交于 2020-07-23 06:30:42
问题 I would like to cross-validate a neural network using the package neuralnet and caret . The data df can be copied from this post. When running the neuralnet() function, there is an argument called hidden where you can set the hidden layers and neurons in each. Let's say I want 2 hidden layers with 3 and 2 neurons respectively. It would be written as hidden = c(3, 2) . However, as I want to cross-validate it, I decided to use the fantastic caret package. But when using the function train() , I

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

R - caret createDataPartition returns more samples than expected

我们两清 提交于 2020-07-18 20:18:55
问题 I'm trying to split the iris dataset into a training set and a test set. I used createDataPartition() like this: library(caret) createDataPartition(iris$Species, p=0.1) # [1] 12 22 26 41 42 57 63 79 89 93 114 117 134 137 142 createDataPartition(iris$Sepal.Length, p=0.1) # [1] 1 27 44 46 54 68 72 77 83 84 93 99 104 109 117 132 134 I understand the first query. I have a vector of 0.1*150 elements (150 is the number of samples in the dataset). However, I should have the same vector on the second