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
74
votes
2 answers

Using Caret Package but Getting Error in library(e1071)

Here is my code: library(caret) set.seed(32343) modelFit = train(type~.,data=training, method='glm') It's pretty standard but I am getting the error message: Error in library(e1071) : there is no package called ‘e1071’ What's the cause, and how…
PMa
  • 1,751
  • 7
  • 22
  • 28
48
votes
3 answers

Fully reproducible parallel models using caret

When I run 2 random forests in caret, I get the exact same results if I set a random seed: library(caret) library(doParallel) set.seed(42) myControl <- trainControl(method='cv', index=createFolds(iris$Species)) set.seed(42) model1 <-…
Zach
  • 29,791
  • 35
  • 142
  • 201
42
votes
3 answers

Saving and loading a model in R

When working with caret, how can I save a model after training, and load it later (e.g. in a different session) for prediction?
Amelio Vazquez-Reina
  • 91,494
  • 132
  • 359
  • 564
33
votes
6 answers

Warning message: "missing values in resampled performance measures" in caret train() using rpart

I am using the caret package to train a model with "rpart" package; tr = train(y ~ ., data = trainingDATA, method = "rpart") Data has no missing values or NA's, but when running the command a warning message comes up; Warning message: In…
USER_1
  • 2,409
  • 1
  • 28
  • 28
32
votes
3 answers

ROC curve from training data in caret

Using the R package caret, how can I generate a ROC curve based on the cross-validation results of the train() function? Say, I do the following: data(Sonar) ctrl <- trainControl(method="cv", summaryFunction=twoClassSummary, …
January
  • 16,320
  • 6
  • 52
  • 74
32
votes
1 answer

caret train() predicts very different then predict.glm()

I am trying to estimate a logistic regression, using the 10-fold cross-validation. #import libraries library(car); library(caret); library(e1071); library(verification) #data import and preparation data(Chile) chile <-…
Vincent
  • 1,361
  • 2
  • 20
  • 33
30
votes
5 answers

Error when I try to predict class probabilities in R - caret

I've build a model using caret. When the training was completed I got the following warning: Warning message: In train.default(x, y, weights = w, ...) : At least one of the class levels are not valid R variables names; This may cause errors if…
Stergios
  • 3,126
  • 6
  • 33
  • 55
26
votes
11 answers

Error in ConfusionMatrix the data and reference factors must have the same number of levels

I've trained a tree model with R caret. I'm now trying to generate a confusion matrix and keep getting the following error: Error in confusionMatrix.default(predictionsTree, testdata$catgeory) : the data and reference factors must have the same…
user2987739
  • 713
  • 2
  • 7
  • 9
25
votes
3 answers

How to make a tree plot in caret package?

I'm using caret package to model the data using rpart package. library('caret') data(iris) formula <- as.formula(Species ~.) t <- train(formula,iris,method = "rpart",cp=0.002,maxdepth=8) plot(t) As a result I get object 't' and I'm trying to plot…
Jot eN
  • 6,120
  • 4
  • 40
  • 59
24
votes
3 answers

Variable importance with ranger

I trained a random forest using caret + ranger. fit <- train( y ~ x1 + x2 ,data = total_set ,method = "ranger" ,trControl = trainControl(method="cv", number = 5, allowParallel = TRUE, verbose = TRUE) ,tuneGrid = expand.grid(mtry…
François M.
  • 4,027
  • 11
  • 30
  • 81
21
votes
3 answers

Why is caret train taking up so much memory?

When I train just using glm, everything works, and I don't even come close to exhausting memory. But when I run train(..., method='glm'), I run out of memory. Is this because train is storing a lot of data for each iteration of the cross-validation…
Yang
  • 16,037
  • 15
  • 100
  • 142
21
votes
1 answer

How to track a progress while building model with the caret package?

I am trying to build model using train function from caret package: model <- train(training$class ~ .,data=training, method = "nb") Training set contains about 20K observations, each observation has above 100 variables. I would like to know if…
mpr
  • 3,730
  • 3
  • 17
  • 22
20
votes
3 answers

Time-series - data splitting and model evaluation

I've tried to use machine learning to make prediction based on time-series data. In one of the stackoverflow question (createTimeSlices function in CARET package in R) is an example of using createTimeSlices to cross-validation for model training…
Jot eN
  • 6,120
  • 4
  • 40
  • 59
18
votes
4 answers

Difference between varImp (caret) and importance (randomForest) for Random Forest

I do not understand which is the difference between varImp function (caret package) and importance function (randomForest package) for a Random Forest model: I computed a simple RF classification model and when computing variable importance, I found…
Rafa OR
  • 339
  • 2
  • 3
  • 8
17
votes
2 answers

How to compute ROC and AUC under ROC after training using caret in R?

I have used caret package's train function with 10-fold cross validation. I also have got class probabilities for predicted classes by setting classProbs = TRUE in trControl, as follows: myTrainingControl <- trainControl(method = "cv", …
exAres
  • 4,806
  • 16
  • 53
  • 95
1
2 3
99 100