Closed GoogleCodeExporter closed 8 years ago
> set.seed(1) > test1 <- gbm(Species ~ ., data = iris, n.trees = 1000, verbose = FALSE) Distribution not specified, assuming multinomial ... > > predict(test1, head(iris), n.trees = 1000, type = "response") setosa versicolor virginica [1,] 0.8351586 0.1132224 0.05161896 [2,] 0.8327497 0.1157803 0.05147007 [3,] 0.8351586 0.1132224 0.05161896 [4,] 0.8344369 0.1139887 0.05157435 [5,] 0.8351586 0.1132224 0.05161896 [6,] 0.8348343 0.1135668 0.05159892 > predict(test1, head(iris), n.trees = c(500, 1000), type = "response") 500 1000 [1,] 0.6692731 0.11322242 [2,] 0.6663942 0.11578028 [3,] 0.6692731 0.11322242 [4,] 0.6685032 0.11398871 [5,] 0.6692731 0.11322242 [6,] 0.6692731 0.11356676 [7,] 0.8351586 0.13365581 [8,] 0.8327497 0.13308088 [9,] 0.8351586 0.13365581 [10,] 0.8344369 0.13350206 [11,] 0.8351586 0.13365581 [12,] 0.8348343 0.13365581 [13,] 0.1970711 0.05161896 [14,] 0.2005250 0.05147007 [15,] 0.1970711 0.05161896 [16,] 0.1979947 0.05157435 [17,] 0.1970711 0.05161896 [18,] 0.1970711 0.05159892 Looking at predict.gbm, the object predF is converted to an array of matrices, but then: if (length(n.trees) > 1) { ## the problem is here: predF <- matrix(predF, ncol = length(n.trees), byrow = FALSE) colnames(predF) <- n.trees predF[, i.ntree.order] <- predF } This worked with bernoulli since the results for the event were returned (and had one dimension). It would be helpful to keep the array structure. Thanks, Max > sessionInfo() R version 2.15.2 (2012-10-26) Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit) locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] splines stats graphics grDevices utils datasets methods [8] base other attached packages: [1] gbm_2.0-8 lattice_0.20-10 survival_2.36-14 loaded via a namespace (and not attached): [1] grid_2.15.2
Original issue reported on code.google.com by harry.southworth on 5 Feb 2013 at 5:13
harry.southworth
So far as I recall, this one is fixed in recent builds.
Original comment by harry.southworth on 8 Apr 2013 at 4:10
Original issue reported on code.google.com by
harry.southworth
on 5 Feb 2013 at 5:13