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

Pryr stops on DOTSXP type #55

Open
dhuebner opened this issue Jan 16, 2017 · 1 comment
Open

Pryr stops on DOTSXP type #55

dhuebner opened this issue Jan 16, 2017 · 1 comment

Comments

@dhuebner
Copy link

dhuebner commented Jan 16, 2017

I noticed that DOTSXP is not handled in pryr::object_size

Here is an example:

library(caret)
train.flag <- createDataPartition(y=iris$Species,p=0.5,list=FALSE)
training <- iris[train.flag,]

modfit <- train(Species~.,method="rpart",data=training)
pryr::object_size(modfit$finalModel$call$formula)

type: 17
Error: Unimplemented type

See https://github.com/hadley/pryr/blob/master/src/object_size.cpp#L149

@ck37
Copy link

ck37 commented Mar 11, 2017

I am running into this also :/

Could there be an option to issue a warning and return 0 rather than stopping? Better to have a lower bound on the object size rather than no estimate.

Or could it fall back to object.size() for those elements, again with a warning?

Here is an example:

data(Boston, package = "MASS")
library(randomForest)
library(pryr)

set.seed(1)

outcome = Boston$medv
data = Boston[, -14]

# This works ok.
rf = randomForest(outcome ~ ., data = data, keep.forest = T)
object_size(rf)

# But not the SuperLearner version.
library(SuperLearner)
sl_rf = SuperLearner(outcome, data, family = "gaussian",
                  SL.library = c("SL.mean", "SL.randomForest"))
# Doesn't work due to the terms element.
object_size(sl_rf)
# object.size() works though.
object.size(sl_rf)

# Dig into the sl_rf details.
obj = sl_rf$fitLibrary$SL.randomForest_All$object

# Fails on $terms element of type "LANGSXP"
for (name in names(obj)) {
  elm = obj[[name]]
  cat("Element:", name, "Type:", pryr::sexp_type(elm), "Size:")
  try(cat(pryr::object_size(elm)))
  cat("\n")
}

# Dig into the terms attributes
terms = obj$terms

# All of these are ok.
for (attr_name in names(attributes(terms))) {
  elm = attr(obj, attr_name, exact = T)
  cat("Attribute:", attr_name, "Type:", pryr::sexp_type(elm), "Size:")
  try(cat(pryr::object_size(elm)))
  cat("\n")
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants