Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in env$X[idx, ] : incorrect number of dimensions #19

Open
mkoohafkan opened this issue Oct 10, 2018 · 5 comments
Open

Error in env$X[idx, ] : incorrect number of dimensions #19

mkoohafkan opened this issue Oct 10, 2018 · 5 comments

Comments

@mkoohafkan
Copy link

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?

@gravesee
Copy link
Owner

gravesee commented Oct 10, 2018 via email

@mkoohafkan
Copy link
Author

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.

@gravesee
Copy link
Owner

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.

@gravesee
Copy link
Owner

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.

@mkoohafkan
Copy link
Author

@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')"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants