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

argument prediction is not passed in %O% #23

Closed
sbrockhaus opened this issue Dec 15, 2015 · 0 comments
Closed

argument prediction is not passed in %O% #23

sbrockhaus opened this issue Dec 15, 2015 · 0 comments

Comments

@sbrockhaus
Copy link
Member

In the args of hyper_bbs() the argument prediction is used to tell the base-learner when the model is fitted and when it is just used for prediction.
I just realized that this argument is not passed when the base-learner is used in combination with %O%, as the argument is not passed in newX1 and newX2, in the code lines
https://github.com/hofnerb/mboost/blob/master/pkg/mboostPatch/R/bkronecker.R#L244
https://github.com/hofnerb/mboost/blob/master/pkg/mboostPatch/R/bkronecker.R#L254

I think the bug can be fixed by setting

X1 <- newX1(as.data.frame(mf[bl1$get_names()]), prediction = args$prediction)
X2 <- newX2(as.data.frame(mf[bl2$get_names()]), prediction = args$prediction)

respectively.

In the following, a MWE is given were the problem occurs in predict().

library(mboost)

### kronecker product for matrix-valued responses
data("volcano", package = "datasets")

## estimate mean of image treating image as matrix
x1 <- 1:nrow(volcano)
x2 <- 1:ncol(volcano)

vol <- as.vector(volcano)
mod <- mboost(vol ~ bbs(x1, df = 3, knots = 10)%O%
                bbs(x2, df = 3, knots = 10),
              control = boost_control(nu = 0.25))

## use predict() with newdata that extrapolates the original variables  
## does not work as the arument 'prediciton' is not passed in %O%
temp <- matrix(predict(mod, newdata=list(x1=x1, x2=1:62)), nrow = nrow(volcano))

I suspect, that the same issue applies for %X% and %+%, as in those functions prediction is not passed explicitly either, see e.g. ,
https://github.com/hofnerb/mboost/blob/master/pkg/mboostPatch/R/bl.R#L1088
However, I did not check in that cases.

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

1 participant