.. index:: single: anomaly_detector_common
.. _anomaly_detector_common/0:

.. rst-class:: right

**category**

``anomaly_detector_common``
===========================

Shared predicates for anomaly detector learning defaults, threshold-based prediction, baseline training-data selection, dataset helpers, and export.

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

| **Author:** Paulo Moura
| **Version:** 1:0:0
| **Date:** 2026-05-01

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


| **Implements:**
|    ``public`` :ref:`anomaly_detector_protocol <anomaly_detector_protocol/0>`
| **Extends:**
|    ``public`` :ref:`options <options/0>`
| **Uses:**
|    :ref:`format <format/0>`
|    :ref:`list <list/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::score/3`  :ref:`anomaly_detector_protocol/0::score_all/3`  :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
-----------------

(no local declarations; see entity ancestors if any)

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

.. index:: anomaly_detector_diagnostics_data/2
.. _anomaly_detector_common/0::anomaly_detector_diagnostics_data/2:

``anomaly_detector_diagnostics_data/2``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Hook predicate that importing anomaly detector implementations may override in order to expose diagnostics and metadata for learned detectors.

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

| **Template:**
|    ``anomaly_detector_diagnostics_data(AnomalyDetector,Diagnostics)``
| **Mode and number of proofs:**
|    ``anomaly_detector_diagnostics_data(+compound,-list(compound))`` - ``one``


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

.. index:: anomaly_detector_export_template/2
.. _anomaly_detector_common/0::anomaly_detector_export_template/2:

``anomaly_detector_export_template/2``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Hook predicate that importing anomaly detector implementations must define in order to expose the exported detector predicate template for a given functor.

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

| **Template:**
|    ``anomaly_detector_export_template(Functor,Template)``
| **Mode and number of proofs:**
|    ``anomaly_detector_export_template(+atom,-callable)`` - ``one``


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

.. index:: anomaly_detector_term_template/2
.. _anomaly_detector_common/0::anomaly_detector_term_template/2:

``anomaly_detector_term_template/2``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Hook predicate that importing anomaly detector implementations must define in order to expose the learned detector term template used by pretty-printing helpers.

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

| **Template:**
|    ``anomaly_detector_term_template(AnomalyDetector,Template)``
| **Mode and number of proofs:**
|    ``anomaly_detector_term_template(+compound,-compound)`` - ``one``


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

.. index:: dataset_attributes/2
.. _anomaly_detector_common/0::dataset_attributes/2:

``dataset_attributes/2``
^^^^^^^^^^^^^^^^^^^^^^^^

Collects the dataset attribute declarations as `Attribute-Values` pairs.

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

| **Template:**
|    ``dataset_attributes(Dataset,Attributes)``
| **Mode and number of proofs:**
|    ``dataset_attributes(+object_identifier,-list(pair))`` - ``one``


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

.. index:: check_examples_non_empty/2
.. _anomaly_detector_common/0::check_examples_non_empty/2:

``check_examples_non_empty/2``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Checks that a dataset contains at least one example.

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

| **Template:**
|    ``check_examples_non_empty(Dataset,Examples)``
| **Mode and number of proofs:**
|    ``check_examples_non_empty(+object_identifier,+list)`` - ``one``


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

.. index:: baseline_training_examples/3
.. _anomaly_detector_common/0::baseline_training_examples/3:

``baseline_training_examples/3``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Collects training examples selected by the ``baseline_class_values/1`` and ``baseline_selection_policy/1`` options. The ``reject`` policy throws an error when non-baseline examples are present. The ``filter`` policy removes non-baseline examples and throws an error when no baseline examples remain.

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

| **Template:**
|    ``baseline_training_examples(Dataset,Examples,Options)``
| **Mode and number of proofs:**
|    ``baseline_training_examples(+object_identifier,-list,+list(compound))`` - ``one``


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

.. index:: valid_baseline_class_values/1
.. _anomaly_detector_common/0::valid_baseline_class_values/1:

``valid_baseline_class_values/1``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Checks that a ``baseline_class_values/1`` option value is a non-empty list of distinct atoms.

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

| **Template:**
|    ``valid_baseline_class_values(BaselineClassValues)``
| **Mode and number of proofs:**
|    ``valid_baseline_class_values(+list(atom))`` - ``one``


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

.. index:: extract_scores/2
.. _anomaly_detector_common/0::extract_scores/2:

``extract_scores/2``
^^^^^^^^^^^^^^^^^^^^

Transforms `Score-Id-Class` tuples into the public `Id-Class-Score` representation.

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

| **Template:**
|    ``extract_scores(Pairs,Scores)``
| **Mode and number of proofs:**
|    ``extract_scores(+list,-list)`` - ``one``


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

.. index:: print_anomaly_detector_template/1
.. _anomaly_detector_common/0::print_anomaly_detector_template/1:

``print_anomaly_detector_template/1``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Prints the learned anomaly detector term template in a human-readable form.

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

| **Template:**
|    ``print_anomaly_detector_template(AnomalyDetector)``
| **Mode and number of proofs:**
|    ``print_anomaly_detector_template(+compound)`` - ``one``


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

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

(no local declarations; see entity ancestors if any)

Operators
---------

(none)

