bgreenwell / pdp

A general framework for constructing partial dependence (i.e., marginal effect) plots from various types machine learning models in R.
http://bgreenwell.github.io/pdp
93 stars 12 forks source link

get_training_data.default problems #90

Closed lawremi closed 5 years ago

lawremi commented 5 years ago

The partial() function fails on ranger objects unless the data= argument is explicitly named in the call. get_training_data.default() could use match.call() to figure out the names when they are not specified. Also, it calls eval() without an environment argument. The calling environment should be passed down the stack so that the evaluation happens in the right frame, although even that is not fool-proof. Why is there a check for S4 objects? There could be a getCall() method for an S4 class just as easily as for an S3 class.

bgreenwell commented 5 years ago

Good catch! This is not specific to ranger either. Honestly this function was only meant to be helpful in very general cases as it's always better to specify the training data via the train argument in the call to pdp::partial(). I'll try to push a fix relatively soon.

bgreenwell commented 5 years ago

Improved functionality in dev version.