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` anomaly_detector_protocol
Extends:
`public` options
Uses:
format
list
type
Remarks:
(none)
Inherited public predicates:
anomaly_detector_options/2 check_anomaly_detector/1 check_option/1 check_options/1 default_option/1 default_options/1 diagnostic/2 diagnostics/2 export_to_clauses/4 export_to_file/4 learn/2 learn/3 option/2 option/3 predict/3 predict/4 print_anomaly_detector/1 score/3 score_all/3 valid_anomaly_detector/1 valid_option/1 valid_options/1

## Public predicates

(no local declarations; see entity ancestors if any)

## Protected predicates

### `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`

### `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`

### `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`

### `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`

### `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`

### `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`

### `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`

### `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`

### `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)