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

Add Cython USPORF and outlier detection example #349

Open
wants to merge 4 commits into
base: staging
Choose a base branch
from

Conversation

MaiRajborirug
Copy link

@MaiRajborirug MaiRajborirug commented May 14, 2020

Issues: #348

After a conversation with @MrAE, I plan to create a USPORF code that can extract a tree structure in python

Attached files
Examples:

  • SPORF/docs/demos/URerF/3d_usporf_outlier_detection.ipynb : Show the outlier detection comparison of Isolation forest (IF) and USPORF (2 methods). The first USPORF uses the affinity matrix. The second USPORF use pathlength function of IF
  • Link to example notebook preview

Modules:

  • SPORF/Python/rerf/pycy_usporf.py : main module for the second USPORF method
  • SPORF/Python/src/cy_usporf.pyx : help pycy_usporf.py do some computation part, such as Fast-BIC score.
  • SPORF/Python/src/setup.py : compile and generate module from cy_usporf.pyx

Figures
image

@netlify
Copy link

netlify bot commented May 14, 2020

Deploy preview for rerf ready!

Built with commit 16aaecd

https://deploy-preview-349--rerf.netlify.app

@MaiRajborirug MaiRajborirug changed the title Add cython USPORF and outlier detection example Add Cython USPORF and outlier detection example May 14, 2020
@megh1241
Copy link
Contributor

Thanks for the PR. A few questions from a cursory look. 1) Is there a reason you chose to go the cython route as opposed to implementing the BIC split criteria in C++ and then writing python bindings ? Similarly with the tree structures, it would be much more maintainable if a python wrapper (eg using pybind11) were used instead of a cython implementation. If you have chosen to go the python route for efficiency reasons, I would like to see a benchmark comparison. 2) Could you please write some tests for this ? 3) Please make it pass the travis build.

@MaiRajborirug
Copy link
Author

  1. I get inspiration from Scikit-learn modules. I saw that most of their algorithms implemented Cython. If possible, I would like to continue this project and write it in Scikit-learn format.
  2. I can work on that.
  3. It seems that this pull failed Python/tests/test_urerf.py. However, I haven't touch UnsupervisedRandomForest.py in this merge. Could you help me a bit with this fail test?

@megh1241
Copy link
Contributor

Our goal for this package is not sklearn compliance but scalability and efficiency. Scikit-learn's "cython only" rules are primarily for ease of maintenance. Our goal for RerF was to build a scalable random forest implementation (i.e similar to XGBoost but for random forests) especially for low latency predictions. We did try to port some of the prediction functions to cython in an attempt to make it sklearn compliant but we failed in that we weren't able to achieve low latencies because cython wasn't the appropriate programming environment for it (i.e it lacked some of the low level features we used such as prefetching).

@MaiRajborirug
Copy link
Author

What do you think should be the most reasonable step if my original goal is to call tree structure in python?

  1. Work on C++ and make a tree structure-function that python can call.
  2. Do the latency test on this Cython code and improves the code speed. If so, do you know what the test called and how to get it?

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

Successfully merging this pull request may close these issues.

None yet

2 participants