category

feature_selector_common

Shared predicates for selector diagnostics, dataset validation, feature-matrix utilities, and selection strategies (top-k and threshold).

Availability:
logtalk_load(feature_selection_protocols(loader))
Author: Paulo Moura
Version: 1:0:0
Date: 2026-10-06
Compilation flags:
static
Implements:
Extends:
public options
Uses:
Remarks:
(none)

Public predicates

(no local declarations; see entity ancestors if any)

Protected predicates

selector_diagnostics_data/2

Hook predicate that importing selector implementations must define in order to expose diagnostics metadata. A default implementation is provided that assumes the diagnostics list is the last argument of the selector term; concrete implementations following that convention do not need to override it.

Compilation flags:
static
Template:
selector_diagnostics_data(Selector,Diagnostics)
Mode and number of proofs:
selector_diagnostics_data(+compound,-list(compound)) - one

selector_export_template/4

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

Compilation flags:
static
Template:
selector_export_template(Dataset,Selector,Functor,Template)
Mode and number of proofs:
selector_export_template(+object_identifier,+compound,+atom,-callable) - one

selector_term_template/2

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

Compilation flags:
static
Template:
selector_term_template(Selector,Template)
Mode and number of proofs:
selector_term_template(+compound,-callable) - one

dataset_examples/2

Collects and validates dataset examples. Rejects duplicate declarations, repeated features within examples, unknown features, and inconsistent example counts.

Compilation flags:
static
Template:
dataset_examples(Dataset,Examples)
Mode and number of proofs:
dataset_examples(+object_identifier,-list(compound)) - one_or_error
Exceptions:
A feature name, feature list, or declared count is a variable:
instantiation_error
The dataset contains no examples:
domain_error(non_empty_examples,Dataset)
An example names a feature not declared by attribute_values/2:
domain_error(unknown_feature,Feature)
A feature is declared or supplied more than once:
domain_error(duplicate_feature,Feature)
A feature name is not atomic:
type_error(atomic,Feature)
An example feature list is not a list:
type_error(list,Features)
An example feature entry is not a pair:
type_error(pair,Entry)
The declared count is not an integer:
type_error(integer,DeclaredCount)
The declared count is not positive:
domain_error(positive_integer,DeclaredCount)
The declared and observed example counts differ:
consistency_error(example_count,DeclaredCount,ObservedCount)

dataset_examples/3

Collects declared feature names and validated examples in one pass over the dataset predicates. Uses the same validation as dataset_examples/2.

Compilation flags:
static
Template:
dataset_examples(Dataset,Features,Examples)
Mode and number of proofs:
dataset_examples(+object_identifier,-list(atomic),-list(compound)) - one_or_error
Exceptions:
A feature name, feature list, or declared count is a variable:
instantiation_error
The dataset contains no examples:
domain_error(non_empty_examples,Dataset)
A feature is declared or supplied more than once:
domain_error(duplicate_feature,Feature)
An example names an undeclared feature:
domain_error(unknown_feature,Feature)
A feature name is not atomic:
type_error(atomic,Feature)
An example feature list is not a list:
type_error(list,Features)
An example feature entry is not a pair:
type_error(pair,Entry)
The declared count is not an integer:
type_error(integer,DeclaredCount)
The declared count is not positive:
domain_error(positive_integer,DeclaredCount)
The declared and observed example counts differ:
consistency_error(example_count,DeclaredCount,ObservedCount)

feature_names/2

Returns unique, atomic candidate features in declaration order, rejecting invalid or duplicate declarations.

Compilation flags:
static
Template:
feature_names(Dataset,FeatureNames)
Mode and number of proofs:
feature_names(+object_identifier,-list(atomic)) - one_or_error
Exceptions:
A declared feature name is a variable:
instantiation_error
A declared feature name is not atomic:
type_error(atomic,Feature)
A feature is declared more than once:
domain_error(duplicate_feature,Feature)

feature_values/3

Returns the value of one feature for every example, in example order. An example that does not mention the feature contributes an unbound variable (a missing value).

Compilation flags:
static
Template:
feature_values(Examples,Feature,Values)
Mode and number of proofs:
feature_values(+list(compound),+atomic,-list) - one

targets/2

Returns the target of every example, in example order (an unbound variable for an example with no known target).

Compilation flags:
static
Template:
targets(Examples,Targets)
Mode and number of proofs:
targets(+list(compound),-list) - one

score_features/4

Scores every feature using score/3 messages to the metric object. Returns Feature-Score pairs in decreasing score order, preserving input feature order for numeric ties.

Compilation flags:
static
Template:
score_features(Metric,Examples,FeatureNames,FeatureScores)
Mode and number of proofs:
score_features(+object_identifier,+list(compound),+list(atomic),-list(pair)) - one

sort_by_decreasing_score/2

Sorts feature scores numerically in decreasing order, preserving input order for ties.

Compilation flags:
static
Template:
sort_by_decreasing_score(FeatureScores,Sorted)
Mode and number of proofs:
sort_by_decreasing_score(+list(pair),-list(pair)) - one

select_top_k/3

Returns the feature names of the K highest-scoring features (FeatureScores already sorted by decreasing score, as returned by score_features/4), preserving that order. Returns every feature name, still in that order, when fewer than K are given.

Compilation flags:
static
Template:
select_top_k(FeatureScores,K,Selected)
Mode and number of proofs:
select_top_k(+list(pair),+positive_integer,-list(atomic)) - one

select_above_threshold/3

Returns the feature names of every feature whose score is at least Threshold (FeatureScores already sorted by decreasing score, as returned by score_features/4), preserving that order.

Compilation flags:
static
Template:
select_above_threshold(FeatureScores,Threshold,Selected)
Mode and number of proofs:
select_above_threshold(+list(pair),+number,-list(atomic)) - one

base_selector_diagnostics/5

Builds the common part of a selector diagnostics metadata list, combined with implementation-specific extra diagnostics terms.

Compilation flags:
static
Template:
base_selector_diagnostics(Model,ExampleCount,Options,ExtraDiagnostics,Diagnostics)
Mode and number of proofs:
base_selector_diagnostics(+atom,+positive_integer,+list(compound),+list(compound),-list(compound)) - one

valid_selector_metadata/2

True when ground diagnostics metadata contains the expected model, a positive example count, and a list of stored options.

Compilation flags:
static
Template:
valid_selector_metadata(Model,Diagnostics)
Mode and number of proofs:
valid_selector_metadata(+atom,+list(compound)) - zero_or_one

valid_selector_metadata/3

True when diagnostics metadata contains the expected model term and records the given effective options.

Compilation flags:
static
Template:
valid_selector_metadata(Model,Options,Diagnostics)
Mode and number of proofs:
valid_selector_metadata(+atom,+list(compound),+list(compound)) - zero_or_one

check_scoring_metric/1

Checks that a scoring metric option value names an object implementing score/3 (feature_scoring_protocol).

Compilation flags:
static
Template:
check_scoring_metric(Metric)
Mode and number of proofs:
check_scoring_metric(@callable) - one_or_error
Exceptions:
Metric is a variable:
instantiation_error
Metric is bound but does not implement score/3:
domain_error(scoring_metric,Metric)

Private predicates

compare_feature_scores/3

Compares numerically decreasing scores, breaking ties by increasing input position.

Compilation flags:
static
Template:
compare_feature_scores(Order,ScoredFeature1,ScoredFeature2)
Mode and number of proofs:
compare_feature_scores(-atom,+compound,+compound) - one

Operators

(none)