cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

JMP Wish List

We want to hear your ideas for improving JMP. Share them here.
Choose Language Hide Translation Bar

Isolation forest and isolation trees

Isolation Forest has been emerging as arguably one of the most popular anomaly detectors in recent years due to its general effectiveness across different benchmarks and strong scalability. It is computationally efficient and has been proven to be very effective in anomaly detection.

 

FN_0-1678345243246.png

Isolation forest compared to others (src)


The algorithm isolates observations by randomly selecting a feature and then randomly selecting a split value between the maximum and minimum values of the selected feature. The implementation is therefore the same as partition trees and bootstrap trees with the difference that the target function should be uniform (trying to split variables with a constant Y value).

Yet, if you try this in JMP, it doesn’t work.

By including Isolation Forest in JMP, similar tu predictor screening, users would have access to a powerful tool for detecting anomalies in their data. This could help them identify unusual patterns or behaviors that may warrant further investigation.

 

This paper studies how IForest works and improves upon its few limitations (i.e., extended isolation forest)

https://hal.science/hal-03537102/document

 

Scikit-learn documentation

https://scikit-learn.org/stable/modules/outlier_detection.html

 

 

18 Comments
FN
Level VI

Great news! thanks Mia  

MathStatChem
Level VII

Add-in is available in the marketplace now!  https://marketplace.jmp.com/appdetails/Isolation+Forest

Thanks @russ_wolfinger for providing that.  

mia_stephens
Staff

Yes indeed, the add-in is now available. Thanks @MathStatChem for getting it started!

mia_stephens
Staff
Status changed to: Delivered
 
FN
Level VI

@mia_stephens, thank you for the effort put into developing this add-on!

That said, I’ve noticed that its reliance on Python libraries makes it quite challenging to use on Windows machines at least. 

If there are no plans to implement this functionality natively in JMP (which would be fantastic, in my opinion ), would you consider open-sourcing the add-on? This way, the community could help maintain and enhance it in the future.

---

For example, I am unable to install isotree:

Python Install Packages("isotree");

 In JMP 18 I get this error:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\user\AppData\Roaming\JMP\JMP\Python\Python311\site-packages\pip\__main__.py", line 22, in <module>
    from pip._internal.cli.main import main as _main
  File "C:\Users\user\AppData\Roaming\JMP\JMP\Python\Python311\site-packages\pip\_internal\cli\main.py", line 10, in <module>
    from pip._internal.cli.autocompletion import autocomplete
  File "C:\Users\user\AppData\Roaming\JMP\JMP\Python\Python311\site-packages\pip\_internal\cli\autocompletion.py", line 10, in <module>
    from pip._internal.cli.main_parser import create_main_parser
  File "C:\Users\user\AppData\Roaming\JMP\JMP\Python\Python311\site-packages\pip\_internal\cli\main_parser.py", line 9, in <module>
    from pip._internal.build_env import get_runnable_pip
  File "C:\Users\user\AppData\Roaming\JMP\JMP\Python\Python311\site-packages\pip\_internal\build_env.py", line 19, in <module>
    from pip._internal.cli.spinners import open_spinner
  File "C:\Users\user\AppData\Roaming\JMP\JMP\Python\Python311\site-packages\pip\_internal\cli\spinners.py", line 9, in <module>
    from pip._internal.utils.logging import get_indentation
  File "C:\Users\user\AppData\Roaming\JMP\JMP\Python\Python311\site-packages\pip\_internal\utils\logging.py", line 4, in <module>
    import logging.handlers
  File "logging\handlers.py", line 26, in <module>
  File "socket.py", line 51, in <module>
ModuleNotFoundError: No module named '_socket'

And in JMP 19 Pro I get a compiler error.

//:*/
import jmputils
jmputils.jpip('install', 'isotree')
/*:
Collecting isotree
  Using cached isotree-0.6.1.post8.tar.gz (300 kB)
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Getting requirements to build wheel: started
  Getting requirements to build wheel: finished with status 'done'
  Preparing metadata (pyproject.toml): started
  Preparing metadata (pyproject.toml): finished with status 'done'
Building wheels for collected packages: isotree
  Building wheel for isotree (pyproject.toml): started
  Building wheel for isotree (pyproject.toml): finished with status 'error'
  error: subprocess-exited-with-error
  
  Building wheel for isotree (pyproject.toml) did not run successfully.
  exit code: 1
  
  [14 lines of output]
  C:\Users\user\AppData\Local\Temp\pip-build-env-e669figd\overlay\Lib\site-packages\setuptools\_distutils\extension.py:150: UserWarning: Unknown Extension options: 'install_requires'
    warnings.warn(msg)
  C:\Users\user\AppData\Local\Temp\pip-build-env-e669figd\overlay\Lib\site-packages\setuptools\dist.py:332: InformationOnly: Normalizing '0.6.1-8' to '0.6.1.post8'
    self.metadata.version = self._normalize_version(self.metadata.version)
  running bdist_wheel
  running build
  running build_py
  creating build\lib.win-amd64-cpython-313\isotree
  copying isotree\__init__.py -> build\lib.win-amd64-cpython-313\isotree
  running build_ext
  Compiling isotree/cpp_interface.pyx because it changed.
  [1/1] Cythonizing isotree/cpp_interface.pyx
  building 'isotree._cpp_interface' extension
  error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
  [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for isotree
Failed to build isotree
error: failed-wheel-build-for-install

Failed to build installable wheels for some pyproject.toml based projects

isotree

0





Paul_Nelson
Staff

The _socket error, you need to uninstall 18.0, and update to a newer 18.x.  And it has to be an uninstall, not a modify/restore. The socket shared library is not in the correct install location. 

 

For both 18 and 19, isotree is one of the finicky packages.  A workaround that usually works is to have a standard install of Python.org 3.11.x for JMP 18 or 3.13.x for JMP 19 and do a regular pip install in the default environment.  This usually builds properly.  Then do the jpip install from within JMP.  JMP can then pick up the local cached packaged build and then install into the JMP private site-packages directory.

 

mia_stephens
Staff

Thank you for responding @Paul_Nelson.

Paul_Nelson
Staff
error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
  [end of output]

When Python needs to build C/C++ based packages, you do need to have a C/C++ development environment installed.  Visual Studio Code should be sufficient.  This is no different than if you just had Python installed and tried to install isotree.