SPORF icon indicating copy to clipboard operation
SPORF copied to clipboard

Add Cython USPORF and outlier detection example

Open MaiRajborirug opened this issue 4 years ago • 5 comments

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

MaiRajborirug avatar May 14 '20 19:05 MaiRajborirug

Deploy preview for rerf ready!

Built with commit 16aaecd707c23635c6b94e1926196c8ec895eb0b

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

netlify[bot] avatar May 14 '20 19:05 netlify[bot]

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.

megh1241 avatar May 14 '20 20:05 megh1241

  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?

MaiRajborirug avatar May 15 '20 00:05 MaiRajborirug

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).

megh1241 avatar May 15 '20 03:05 megh1241

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?

MaiRajborirug avatar May 15 '20 14:05 MaiRajborirug