category
similarity_metric_common
Shared helper predicates for sparse-vector overlap, numeric scaling, normalization, and correlation, reused by the library similarity metric objects.
logtalk_load(recommender_protocols(loader))staticPublic predicates
(no local declarations; see entity ancestors if any)
Protected predicates
common_pairs/3
Collects the Value1-Value2 pairs for the keys present in both sparse vectors. Assumes each vector declares at most one value per key.
staticcommon_pairs(Vector1,Vector2,Pairs)common_pairs(+list(pair),+list(pair),-list(pair)) - onevector_norm/2
Computes the Euclidean norm of the values of a sparse Key-Value vector.
staticvector_norm(Vector,Norm)vector_norm(+list(pair),-float) - onescale_values/2
Scales numeric values by their maximum absolute magnitude, leaving empty and all-zero lists unchanged.
staticscale_values(Values,Scaled)scale_values(+list(number),-list(number)) - onenormalize_values/2
Unit-normalizes numeric values using bounded intermediate magnitudes, leaving empty and all-zero lists unchanged.
staticnormalize_values(Values,Normalized)normalize_values(+list(number),-list(number)) - onenormalize_vector/2
Unit-normalizes a sparse numeric vector while preserving its keys and their order.
staticnormalize_vector(Vector,Normalized)normalize_vector(+list(pair),-list(pair)) - onebounded_similarity/2
Bounds a computed cosine or correlation score to its mathematical range, removing endpoint roundoff.
staticbounded_similarity(Score,Similarity)bounded_similarity(+number,-number) - onecentered_normalized_values/2
Centers and unit-normalizes numeric values in shifted, scaled coordinates. Empty lists remain empty and exactly constant lists become zeros.
staticcentered_normalized_values(Values,Normalized)centered_normalized_values(+list(number),-list(number)) - onesplit_pairs/3
Splits a list of Value1-Value2 pairs into separate, position-aligned lists of first and second values.
staticsplit_pairs(Pairs,Values1,Values2)split_pairs(+list(pair),-list(number),-list(number)) - onedot_product/3
Computes the dot product of two position-aligned numeric lists of the same length.
staticdot_product(Values1,Values2,Dot)dot_product(+list(number),+list(number),-number) - onesum_of_squares_list/2
Computes the sum of the squares of a numeric list.
staticsum_of_squares_list(Values,SumSquares)sum_of_squares_list(+list(number),-number) - onemean_values/2
Computes the arithmetic mean of a non-empty numeric list.
staticmean_values(Values,Mean)mean_values(+list(number),-float) - one_or_errorValues is empty:evaluation_error(zero_divisor)center/3
Subtracts a value (typically the mean) from every element of a numeric list.
staticcenter(Values,Value,Centered)center(+list(number),+number,-list(number)) - onePrivate predicates
(no local declarations; see entity ancestors if any)
Operators
(none)