SPORF
SPORF copied to clipboard
Add Cython USPORF and outlier detection example
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
: helppycy_usporf.py
do some computation part, such as Fast-BIC score. -
SPORF/Python/src/setup.py
: compile and generate module fromcy_usporf.pyx
Figures
Deploy preview for rerf ready!
Built with commit 16aaecd707c23635c6b94e1926196c8ec895eb0b
https://deploy-preview-349--rerf.netlify.app
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.
- 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.
- I can work on that.
- It seems that this pull failed
Python/tests/test_urerf.py
. However, I haven't touchUnsupervisedRandomForest.py
in this merge. Could you help me a bit with this fail test?
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).
What do you think should be the most reasonable step if my original goal is to call tree structure in python?
- Work on C++ and make a tree structure-function that python can call.
- 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?