Error in env$X[idx, ] : incorrect number of dimensions
I'm getting an error with iForest that I don't understand:
# test dataset
test = data.frame(VALUE = rlnorm(200))
iForest(test, 100, 50)
## Error in env$X[idx, ] : incorrect number of dimensions
iForest(as.matrix(test), 100, 50)
## Error in env$X[idx, ] : incorrect number of dimensions
iForest(as_tibble(test), 100, 50)
## Isolation Forest with 100 Trees and Max Depth of 6
Why does iForest work with a tibble, but not with a regular data.frame or list?
Try it with more than one column. It's probably dropping to a vector when it indices the data frame rows.
On Wed, Oct 10, 2018, 3:44 PM Michael [email protected] wrote:
I'm getting an error with iForest that I don't understand:
test dataset
test = data.frame(VALUE = rlnorm(200)) iForest(test, 100, 50)
Error in env$X[idx, ] : incorrect number of dimensions
iForest(as.matrix(test), 100, 50)
Error in env$X[idx, ] : incorrect number of dimensions
iForest(as_tibble(test), 100, 50)
Isolation Forest with 100 Trees and Max Depth of 6
Why does iForest work with a tibble, but not with a regular data.frame or list?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Zelazny7/isofor/issues/19, or mute the thread https://github.com/notifications/unsubscribe-auth/ABmRXbpux2S6hitZ0rm_cTLtsqf3iWF4ks5ujlw-gaJpZM4XWSuj .
Yes, the function works when there is more than one column, but my data is univariate. Do isolation forests not work on univariate data? I am new to this method.
It's an issue of dropping dimensions when indexing a data.frame with one column. The second dimension gets dropped. I'll try to patch it tomorrow. It's an easy fix.
I pushed a fix to this branch: https://github.com/Zelazny7/isofor/tree/fix-single-column-data-frame
Can you test it and let me know if it solves your problem? I was able to train an isolation forest on a data.frame with one column.
@Zelazny7 it now works with vectors, data.frames, and matrices, but fails on tibbles:
Error in UseMethod("split_on_var") : no applicable method for 'split_on_var' applied to an object of class "c('tbl_df', 'tbl', 'data.frame')"