gbm-developers / gbm3

Gradient boosted models
133 stars 117 forks source link

"incorrect number of dimensions" error when using the pairwise loss #163

Open wenjie2wang opened 3 months ago

wenjie2wang commented 3 months ago

Thanks for developing the package. I wonder how one should train a model with the pairwise loss. An example that reproduces the error is as follows:

## example of pairwise loss using {gbm3}
library(gbm3) # gbm-developers/gbm3@a2b258c
packageVersion("gbm3")
#> [1] '3.0'

train_x <- as.matrix(iris[, c("Sepal.Width", "Petal.Length", "Petal.Width")])
train_y <- iris$Sepal.Length

## train
model <- gbm.fit(
    x = train_x,
    y = train_y,
    group = rep(1, length(train_y)),
    distribution = list(name = "pairwise", metric = "conc"),
    n.trees = 100,
    interaction.depth = 3,
    n.minobsinnode = 10,
    shrinkage = 0.1,
    bag.fraction = 0.5
)
#> Error in gbm_data_obj$x[train_params$id_order, , drop = FALSE]: incorrect number of dimensions

Created on 2024-03-28 with reprex v2.1.0

On another note related to the pairwise loss, I found unexpected prediction results from the pairwise loss by using the {gbm} package: https://github.com/gbm-developers/gbm/issues/79. It would be great if you could provide some insights. Thanks.