.. index:: single: isolation_forest_anomaly_detector
.. _isolation_forest_anomaly_detector/0:

.. rst-class:: right

**object**

``isolation_forest_anomaly_detector``
=====================================

Extended Isolation Forest (EIF) algorithm for anomaly detection. Implements the improved version described by Hariri et al. (2019) that uses random hyperplane cuts instead of axis-aligned cuts, eliminating score bias artifacts. Builds an ensemble of isolation trees from baseline training examples selected from a dataset object implementing the ``anomaly_dataset_protocol`` protocol. Missing attribute values are represented using anonymous variables.

| **Availability:** 
|    ``logtalk_load(isolation_forest_anomaly_detector(loader))``

| **Author:** Paulo Moura
| **Version:** 2:0:0
| **Date:** 2026-05-06

| **Compilation flags:**
|    ``static, context_switching_calls``


| **Imports:**
|    ``public`` :ref:`anomaly_detector_common <anomaly_detector_common/0>`
| **Uses:**
|    :ref:`fast_random(Algorithm) <fast_random/1>`
|    :ref:`format <format/0>`
|    :ref:`integer <integer/0>`
|    :ref:`list <list/0>`
|    :ref:`numberlist <numberlist/0>`
|    :ref:`pairs <pairs/0>`
|    :ref:`type <type/0>`

| **Remarks:**
|    (none)

| **Inherited public predicates:**
|     :ref:`anomaly_detector_protocol/0::anomaly_detector_options/2`  :ref:`anomaly_detector_protocol/0::check_anomaly_detector/1`  :ref:`options_protocol/0::check_option/1`  :ref:`options_protocol/0::check_options/1`  :ref:`options_protocol/0::default_option/1`  :ref:`options_protocol/0::default_options/1`  :ref:`anomaly_detector_protocol/0::diagnostic/2`  :ref:`anomaly_detector_protocol/0::diagnostics/2`  :ref:`anomaly_detector_protocol/0::export_to_clauses/4`  :ref:`anomaly_detector_protocol/0::export_to_file/4`  :ref:`anomaly_detector_protocol/0::learn/2`  :ref:`anomaly_detector_protocol/0::learn/3`  :ref:`options_protocol/0::option/2`  :ref:`options_protocol/0::option/3`  :ref:`anomaly_detector_protocol/0::predict/3`  :ref:`anomaly_detector_protocol/0::predict/4`  :ref:`anomaly_detector_protocol/0::print_anomaly_detector/1`  :ref:`anomaly_detector_protocol/0::valid_anomaly_detector/1`  :ref:`options_protocol/0::valid_option/1`  :ref:`options_protocol/0::valid_options/1`  

.. contents::
   :local:
   :backlinks: top

Public predicates
-----------------

.. index:: score/3
.. _isolation_forest_anomaly_detector/0::score/3:

``score/3``
^^^^^^^^^^^

Computes the anomaly score for a given instance using the learned model. The instance is a list of ``Attribute-Value`` pairs where missing values are represented using anonymous variables. The score is in the range ``[0.0, 1.0]``. Scores close to ``1.0`` indicate anomalies. Scores close to ``0.5`` or below indicate normal instances.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``score(Model,Instance,Score)``
| **Mode and number of proofs:**
|    ``score(+compound,+list,-float)`` - ``one``


------------

.. index:: score_all/3
.. _isolation_forest_anomaly_detector/0::score_all/3:

``score_all/3``
^^^^^^^^^^^^^^^

Computes the anomaly scores for all instances in the dataset. Returns a list of ``Id-Class-Score`` triples sorted by descending anomaly score.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``score_all(Dataset,Model,Scores)``
| **Mode and number of proofs:**
|    ``score_all(+object_identifier,+compound,-list)`` - ``one``


------------

Protected predicates
--------------------

(no local declarations; see entity ancestors if any)

Private predicates
------------------

(no local declarations; see entity ancestors if any)

Operators
---------

(none)

.. seealso::

   :ref:`anomaly_dataset_protocol <anomaly_dataset_protocol/0>`, :ref:`anomaly_detector_protocol <anomaly_detector_protocol/0>`, :ref:`knn_distance_anomaly_detector <knn_distance_anomaly_detector/0>`, :ref:`lof_anomaly_detector <lof_anomaly_detector/0>`

