Skip to content

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

Description

@davidruegamer

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.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions