Questions tagged [r-caret]

caret is an R package for classification and regression training. It provides a standardized interface to several of R's machine learning packages, along with utilities for training and plotting.

caret is an package for and training. It provides a standardized interface to several of R's packages, along with utilities for and ting.

Repositories

Vignettes

Books

Other resources

Related tags

Unrelated tags

  • refers to an onscreen text cursor. Please re-tag any questions with both the and tags as .
2088 questions
17
votes
1 answer

Pass PCA preprocessing arguments to train()

I'm trying to build a predictive model in caret using PCA as pre-processing. The pre-processing would be as follows: preProc <- preProcess(IL_train[,-1], method="pca", thresh = 0.8) Is it possible to pass the thresh argument directly to caret's…
Timm S.
  • 5,135
  • 6
  • 24
  • 38
17
votes
1 answer

SVM with cross validation in R using caret

I was told to use the caret package in order to perform Support Vector Machine regression with 10 fold cross validation on a data set I have. I'm plotting my response variable against 151 variables. I did the following:- > ctrl <-…
user2062207
  • 955
  • 4
  • 18
  • 34
17
votes
2 answers

Variable importance using the caret package (error); RandomForest algorithm

I am trying to obtain the variable importance of a rf model in any way. This is the approach I have tried so far, but alternate suggestions are very welcome. I have trained a model in R: require(caret) require(randomForest) myControl =…
Jakub Langr
  • 617
  • 1
  • 6
  • 18
16
votes
1 answer

R understanding {caret} train(tuneLength = ) and SVM methods from {kernlab}

Trying to better understand how train(tuneLength = ) works in {caret}. My confusion happened when trying to understand some of the differences between the SVM methods from {kernlab} I've reviewed the documentation (here) and the caret training page…
J.M.
  • 257
  • 1
  • 2
  • 13
16
votes
3 answers

Usage of caret with gbm method for multiclass classification

I am solving a multiclass classification problem and trying to use Generalized Boosted Models (gbm package in R). The issue I faced: caret's train function with method="gbm" seems not to work with multiclass data properly. A simple example is…
maruan
  • 376
  • 1
  • 4
  • 13
15
votes
3 answers

Combining Rolling Origin Forecast Resampling and Group V-Fold Cross-Validation in rsample

I would like to use the R package rsample to generate resamples of my data. The package offers the function rolling_origin to produce resamples that keep the time series structure of the data. This means that training data (in the package called…
Richi W
  • 3,534
  • 4
  • 20
  • 39
15
votes
2 answers

Fit a no-intercept model in caret

In R, I specify a model with no intercept as follows: data(iris) lmFit <- lm(Sepal.Length ~ 0 + Petal.Length + Petal.Width, data=iris) > round(coef(lmFit),2) Petal.Length Petal.Width 2.86 -4.48 However, if I fit the same model…
Zach
  • 29,791
  • 35
  • 142
  • 201
14
votes
1 answer

Error in summary.connection(connection) : invalid connection

Having an issue while running a logistic regression model using caret::train(). LR = caret::train(Satisfaction ~., data= log_train, method = "glm", preProcess = c("scale"), family="binomial") keep getting the following line of error: Error in…
Manasi bhargav
  • 141
  • 1
  • 1
  • 3
14
votes
2 answers

Caret package - defining Positive result

While using Caret package for machine learning, I am struck with Caret's default "Positive" outcome picking i.e the first level of the outcome factor in binary classification problems. Package says it can be set to the alternative level. Can any…
duvvurum
  • 337
  • 2
  • 4
  • 9
14
votes
1 answer

R caret train glmnet final model lambda values not as specified

I was using caret package to tune a glmnet logistic regression model. While the lambda value from best tune is one of the values I specified in the tuneGrid, the lambda values of the final model are totally different: require(caret) set.seed(1) x <-…
maksay
  • 277
  • 3
  • 10
14
votes
1 answer

How to retrieve overall accuracy value from confusionMatrix in R?

In R caret library, if I got a confusion matrix like this below, if there a way to retrieve the overall accuracy 0.992? I can't get this single value out, since I need to store this value and use it for later processing. Is this possible at all? …
user697911
  • 10,043
  • 25
  • 95
  • 169
14
votes
1 answer

createTimeSlices function in CARET package in R

I am working with multivariate financial time series data and having problems using the createTimeSlices function. I cannot find any use of the function except the one used by Max Kuhn. Can anybody help me in understanding the usage of the function?
Panchacookie
  • 427
  • 1
  • 6
  • 22
14
votes
2 answers

How to preProcess features when some of them are factors?

My question is related to this one regarding categorical data (factors in R terms) when using the Caret package. I understand from the linked post that if you use the "formula interface", some features can be factors and the training will work…
mchangun
  • 9,814
  • 18
  • 71
  • 101
13
votes
2 answers

Caret package Custom metric

I'm using the caret function "train()" in one of my project and I'd like to add a "custom metric" F1-score. I looked at this url caret package But I cannot understand how I can build this score with the parameter available. There is an example of…
MarcelRitos
  • 179
  • 1
  • 1
  • 8
13
votes
1 answer

Caret train method complains Something is wrong; all the RMSE metric values are missing

On numerous occasions I've been getting this error when trying to fit a gbm or rpart model. Finally I was able to reproduce it consistently using publicly available data. I have noticed that this error happens when using CV (or repeated cv). When I…
Fred R.
  • 557
  • 3
  • 7
  • 16