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

Return predict matrix similar to mgcv's predict(..., type="lpmatrix") #108

Open
davidruegamer opened this issue Jun 7, 2020 · 0 comments

Comments

@davidruegamer
Copy link
Member

davidruegamer commented Jun 7, 2020

In a recent project of us we were required to get the matrix of each baseleaner that is used for prediction. mgcv::gam allows this via predict(model, type="lpmatrix"). For mboost, we could construct this as follows:

mboost_lpmatrix <- function(object, newdata, which, what = c("X", "K"))
{
  
  what = match.arg(what)
  stopifnot(!is.null(which) & !is.null(newdata))
  get("newX", environment(object$baselearner[[which]]$dpp))(newdata, prediction = TRUE)[[what]]
  
}

Maybe this is also helpful for others / worth including.

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

No branches or pull requests

1 participant