Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extractProb Incorrect dimensions when X Has One Column #849

Closed
ray-p144 opened this issue Mar 1, 2018 · 1 comment
Closed

extractProb Incorrect dimensions when X Has One Column #849

ray-p144 opened this issue Mar 1, 2018 · 1 comment

Comments

@ray-p144
Copy link

@ray-p144 ray-p144 commented Mar 1, 2018

When using the extractProb function on a model that was trained with only one column in X, the following error is thrown:

Error in newdata[, object$method$center, drop = FALSE] : 
  incorrect number of dimensions

The problem seems to be caused by this line when the data.frame is turned into a vector.

Minimum reproducible example:

library(caret)
TrainData <- data.frame(x = runif(100))
TrainClasses <- sample(c("Y", "N"), 100, TRUE)
fit <- train(TrainData, TrainClasses,
             method = "glm",
             preProcess = c("center", "scale"),
             trControl = trainControl(method = "cv", classProbs = TRUE))
extractProb(list(fit))

I would suggest adding the argument drop = FALSE like the extractPrediction function has in this line

topepo added a commit that referenced this issue Mar 1, 2018
@topepo
Copy link
Owner

@topepo topepo commented Mar 1, 2018

Yep! That bug has been around for _more+ than

> difftime(now(), ymd_hm("2007-10-05 12:21"), units = "weeks")
Time difference of 542.9203 weeks
@topepo topepo closed this Mar 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.