lorismichel / quantregForest

R package - Quantile Regression Forests, a tree-based ensemble method for estimation of conditional quantiles (Meinshausen, 2006).
25 stars 6 forks source link

Wrong number of trees when the parallel computation feature is used #15

Open rgurlek opened 1 year ago

rgurlek commented 1 year ago

There seems to be a bug with the way the parallel computation feature is implemented. The quantregForest object that is returned after training has only ntree/nthreads trees in it. Here is the code to reproduce:

library(quantregForest)

data(airquality)
set.seed(1)

## remove observations with mising values
airquality <- airquality[ !apply(is.na(airquality), 1,any), ]

## number of remining samples
n <- nrow(airquality)

## divide into training and test data
indextrain <- sample(1:n,round(0.6*n),replace=FALSE)
Xtrain     <- airquality[ indextrain,2:6]
Xtest      <- airquality[-indextrain,2:6]
Ytrain     <- airquality[ indextrain,1]
Ytest      <- airquality[-indextrain,1]

################################################
##     compute Quantile Regression Forests    ##
################################################

qrf <- quantregForest(x=Xtrain, y=Ytrain,  nthreads=4, ntree=20)

qrf$ntree