araastat / reprtree

Representative trees from ensembles
41 stars 33 forks source link

RF with one tree fails #7

Open VMJim opened 8 years ago

VMJim commented 8 years ago

Reproducible example:

library(reprtree)
library(randomForest)
data(spam, package="kernlab")

rf <- randomForest(type ~. , data = spam, ntree = 1)
reptr <- ReprTree(rf, spam, metric = "d2")

Produces:

[1] "Constructing distance matrix..."
Error in x[l, ] : subscript out of bounds

Solution: something like: if ntrees = 1, then representative tree is that tree