protocol

recommender_protocol

Protocol for recommendation models and user-item relevance scoring.

Availability:
logtalk_load(recommender_protocols(loader))
Author: Paulo Moura
Version: 1:0:0
Date: 2026-10-04
Compilation flags:
static
Dependencies:
(none)
Remarks:
(none)
Inherited public predicates:
(none)

Public predicates

learn/3

Learns a recommender model from the given rating dataset object using the specified options.

Compilation flags:
static
Template:
learn(Dataset,Recommender,Options)
Mode and number of proofs:
learn(+object_identifier,-compound,+list(compound)) - one_or_error
Exceptions:
Options is a variable:
instantiation_error
Options is neither a variable nor a list:
type_error(list,Options)
An element Option of the list Options is a variable:
instantiation_error
An element Option of the list Options is neither a variable nor a compound term:
type_error(compound,Option)
An element Option of the list Options is a compound term but not a valid option:
domain_error(option,Option)
The dataset contains no ratings:
domain_error(non_empty_ratings,Dataset)
A user or item identifier is a variable:
instantiation_error
A user or item identifier is not atomic:
type_error(atomic,Identifier)
The same User-Item pair is rated more than once:
domain_error(duplicate_rating,User-Item)
The declared rating count is a variable:
instantiation_error
The declared rating count is neither a variable nor an integer:
type_error(integer,DeclaredCount)
The declared rating count is an integer but is not positive:
domain_error(positive_integer,DeclaredCount)
The declared and observed rating counts differ:
consistency_error(rating_count,DeclaredCount,ObservedCount)
A rating value is not a number:
type_error(number,Rating)
A scale bound is a variable:
instantiation_error
A scale bound is not numeric:
type_error(number,Bound)
Scale bounds are reversed:
domain_error(rating_scale,Min-Max)
A rating value falls outside the declared rating scale:
domain_error(rating_scale(Min,Max),Rating)
A content-based dataset has no catalog items:
domain_error(non_empty_catalog,Dataset)
A catalog or content item is declared more than once:
domain_error(duplicate_item,Item)
Content declarations do not cover the catalog exactly once:
domain_error(item_content_coverage,Dataset)
A rated item is absent from the content catalog:
domain_error(catalog_item,Item)
A content descriptor is invalid:
domain_error(item_content,Content)
Content representations are mixed:
domain_error(content_representation,Content)
A content list is not a proper list:
type_error(list,List)
A content descriptor, list, feature, or weight is a variable:
instantiation_error
A vector entry is not a pair:
type_error(pair,Entry)
A sparse vector repeats a feature key:
domain_error(duplicate_feature,Feature)
A sparse weight is not a number:
type_error(number,Weight)
A sparse weight is negative or nonfinite:
domain_error(non_negative_finite_weight,Weight)
A vector weight is not binary for an implementation requiring binary features:
domain_error(binary_weight,Weight)
A nonzero vector count is not an integer for an implementation requiring raw term counts:
type_error(integer,Count)
A content-based rating is not finite:
domain_error(finite_rating,Rating)
A selected rating is not positive in rating-weighted profile construction:
domain_error(positive_rating_weight,Rating)
Feature fitting produces no vocabulary:
domain_error(non_empty_vocabulary,Corpus)

learn/2

Learns a recommender model from the given rating dataset object using default options.

Compilation flags:
static
Template:
learn(Dataset,Recommender)
Mode and number of proofs:
learn(+object_identifier,-compound) - one_or_error
Exceptions:
The dataset contains no ratings:
domain_error(non_empty_ratings,Dataset)
A user or item identifier is a variable:
instantiation_error
A user or item identifier is not atomic:
type_error(atomic,Identifier)
The same User-Item pair is rated more than once:
domain_error(duplicate_rating,User-Item)
The declared rating count is a variable:
instantiation_error
The declared rating count is neither a variable nor an integer:
type_error(integer,DeclaredCount)
The declared rating count is an integer but is not positive:
domain_error(positive_integer,DeclaredCount)
The declared and observed rating counts differ:
consistency_error(rating_count,DeclaredCount,ObservedCount)
A rating value is not a number:
type_error(number,Rating)
A scale bound is a variable:
instantiation_error
A scale bound is not numeric:
type_error(number,Bound)
Scale bounds are reversed:
domain_error(rating_scale,Min-Max)
A rating value falls outside the declared rating scale:
domain_error(rating_scale(Min,Max),Rating)
A content-based dataset has no catalog items:
domain_error(non_empty_catalog,Dataset)
A catalog or content item is declared more than once:
domain_error(duplicate_item,Item)
Content declarations do not cover the catalog exactly once:
domain_error(item_content_coverage,Dataset)
A rated item is absent from the content catalog:
domain_error(catalog_item,Item)
A content descriptor is invalid:
domain_error(item_content,Content)
Content representations are mixed:
domain_error(content_representation,Content)
A content list is not a proper list:
type_error(list,List)
A content descriptor, list, feature, or weight is a variable:
instantiation_error
A vector entry is not a pair:
type_error(pair,Entry)
A sparse vector repeats a feature key:
domain_error(duplicate_feature,Feature)
A sparse weight is not a number:
type_error(number,Weight)
A sparse weight is negative or nonfinite:
domain_error(non_negative_finite_weight,Weight)
A vector weight is not binary for an implementation requiring binary features:
domain_error(binary_weight,Weight)
A nonzero vector count is not an integer for an implementation requiring raw term counts:
type_error(integer,Count)
A content-based rating is not finite:
domain_error(finite_rating,Rating)
A selected rating is not positive in rating-weighted profile construction:
domain_error(positive_rating_weight,Rating)
Feature fitting produces no vocabulary:
domain_error(non_empty_vocabulary,Corpus)

score/4

Scores the relevance of Item to User using the learned recommender. Higher scores indicate greater relevance. Scores may be predicted ratings or other relevance measures; their ranges and handling of unknown identifiers depend on the implementation.

Compilation flags:
static
Template:
score(Recommender,User,Item,Score)
Mode and number of proofs:
score(+compound,+atomic,+atomic,-number) - one_or_error
Exceptions:
Recommender is a variable:
instantiation_error
Recommender is not a valid recommender:
domain_error(recommender,Recommender)
A user or item identifier is a variable:
instantiation_error
A user or item identifier is not atomic:
type_error(atomic,Identifier)
Item is unknown to an implementation requiring catalog membership:
domain_error(catalog_item,Item)

recommend/4

Recommends up to N items to User using the learned recommender model, as a list of Item-Score pairs sorted by decreasing score. Whether items already rated by User are excluded, and how ties and an unknown User are handled, depends on the implementation.

Compilation flags:
static
Template:
recommend(Recommender,User,N,Recommendations)
Mode and number of proofs:
recommend(+compound,+atomic,+positive_integer,-list(pair)) - one_or_error
Exceptions:
Recommender is a variable:
instantiation_error
Recommender is not a valid recommender:
domain_error(recommender,Recommender)
N is a variable:
instantiation_error
N is neither a variable nor an integer:
type_error(integer,N)
N is an integer but is not positive:
domain_error(positive_integer,N)
User is a variable:
instantiation_error
User is not atomic:
type_error(atomic,User)

check_recommender/1

Checks model data and diagnostics for the receiving implementation without instantiating the recommender. Throws an exception when the term is not a valid recommender representation.

Compilation flags:
static
Template:
check_recommender(Recommender)
Mode and number of proofs:
check_recommender(@compound) - one_or_error
Exceptions:
Recommender is a variable:
instantiation_error
Recommender is neither a variable nor a valid recommender:
domain_error(recommender,Recommender)

valid_recommender/1

True when a learned recommender term is structurally valid for the receiving implementation. Succeeds iff check_recommender/1 succeeds without throwing an exception.

Compilation flags:
static
Template:
valid_recommender(Recommender)
Mode and number of proofs:
valid_recommender(@compound) - zero_or_one

diagnostics/2

Returns diagnostics metadata for a learned recommender.

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

diagnostic/2

Enumerates individual diagnostics metadata terms for a learned recommender.

Compilation flags:
static
Template:
diagnostic(Recommender,Diagnostic)
Mode and number of proofs:
diagnostic(+compound,?compound) - zero_or_more

recommender_options/2

Returns the effective training options recorded in a learned recommender diagnostics metadata.

Compilation flags:
static
Template:
recommender_options(Recommender,Options)
Mode and number of proofs:
recommender_options(+compound,-list(compound)) - one

export_to_clauses/4

Converts a recommender into a list of predicate clauses. Functor is the functor for the generated predicate clauses. When exporting a serialized recommender term, a noun such as recommender or model is usually clearer than a verb such as recommend.

Compilation flags:
static
Template:
export_to_clauses(Dataset,Recommender,Functor,Clauses)
Mode and number of proofs:
export_to_clauses(+object_identifier,+compound,+atom,-list(clause)) - one

export_to_file/4

Exports a recommender to a file. Functor is the functor for the generated predicate clauses. When exporting a serialized recommender term, a noun such as recommender or model is usually clearer than a verb such as recommend.

Compilation flags:
static
Template:
export_to_file(Dataset,Recommender,Functor,File)
Mode and number of proofs:
export_to_file(+object_identifier,+compound,+atom,+atom) - one


Protected predicates

(none)

Private predicates

(none)

Operators

(none)