.. index:: single: classifier_protocol
.. _classifier_protocol/0:

.. rst-class:: right

**protocol**

``classifier_protocol``
=======================

Protocol for machine learning classifiers.

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

| **Author:** Paulo Moura
| **Version:** 2:0:0
| **Date:** 2026-05-07

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


| **Dependencies:**
|   (none)


| **Remarks:**
|    (none)

| **Inherited public predicates:**
|    (none)

.. contents::
   :local:
   :backlinks: top

Public predicates
-----------------

.. index:: learn/3
.. _classifier_protocol/0::learn/3:

``learn/3``
^^^^^^^^^^^

Learns a classifier from the given dataset object using the specified options.

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

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


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

.. index:: learn/2
.. _classifier_protocol/0::learn/2:

``learn/2``
^^^^^^^^^^^

Learns a classifier from the given dataset object using default options.

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

| **Template:**
|    ``learn(Dataset,Classifier)``
| **Mode and number of proofs:**
|    ``learn(+object_identifier,-compound)`` - ``one``


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

.. index:: predict/3
.. _classifier_protocol/0::predict/3:

``predict/3``
^^^^^^^^^^^^^

Predicts the class label for a new instance using the learned classifier. The instance is a list of ``Attribute-Value`` pairs.

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

| **Template:**
|    ``predict(Classifier,Instance,Class)``
| **Mode and number of proofs:**
|    ``predict(+compound,+list,-atom)`` - ``one``


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

.. index:: check_classifier/1
.. _classifier_protocol/0::check_classifier/1:

``check_classifier/1``
^^^^^^^^^^^^^^^^^^^^^^

Checks that a learned classifier term is structurally valid for the receiving implementation. Throws an exception when the term is not a valid classifier representation.

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

| **Template:**
|    ``check_classifier(Classifier)``
| **Mode and number of proofs:**
|    ``check_classifier(@compound)`` - ``one_or_error``

| **Exceptions:**
|    ``Classifier`` is a variable:
|        ``instantiation_error``
|    ``Classifier`` is neither a variable nor a valid classifier:
|        ``domain_error(classifier,Classifier)``


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

.. index:: valid_classifier/1
.. _classifier_protocol/0::valid_classifier/1:

``valid_classifier/1``
^^^^^^^^^^^^^^^^^^^^^^

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

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

| **Template:**
|    ``valid_classifier(Classifier)``
| **Mode and number of proofs:**
|    ``valid_classifier(@compound)`` - ``zero_or_one``


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

.. index:: diagnostics/2
.. _classifier_protocol/0::diagnostics/2:

``diagnostics/2``
^^^^^^^^^^^^^^^^^

Returns diagnostics and metadata associated with a learned classifier in a representation-independent way.

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

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


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

.. index:: diagnostic/2
.. _classifier_protocol/0::diagnostic/2:

``diagnostic/2``
^^^^^^^^^^^^^^^^

Tests or enumerates individual diagnostics metadata terms for a learned classifier.

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

| **Template:**
|    ``diagnostic(Classifier,Diagnostic)``
| **Mode and number of proofs:**
|    ``diagnostic(+compound,?compound)`` - ``zero_or_more``


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

.. index:: classifier_options/2
.. _classifier_protocol/0::classifier_options/2:

``classifier_options/2``
^^^^^^^^^^^^^^^^^^^^^^^^

Returns the effective training options recorded in a learned classifier diagnostics list.

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

| **Template:**
|    ``classifier_options(Classifier,Options)``
| **Mode and number of proofs:**
|    ``classifier_options(+compound,-list(compound))`` - ``zero_or_one``


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

.. index:: export_to_clauses/4
.. _classifier_protocol/0::export_to_clauses/4:

``export_to_clauses/4``
^^^^^^^^^^^^^^^^^^^^^^^

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

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

| **Template:**
|    ``export_to_clauses(Dataset,Classifier,Functor,Clauses)``
| **Mode and number of proofs:**
|    ``export_to_clauses(+object_identifier,+compound,+callable,-list(clause))`` - ``one``


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

.. index:: export_to_file/4
.. _classifier_protocol/0::export_to_file/4:

``export_to_file/4``
^^^^^^^^^^^^^^^^^^^^

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

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

| **Template:**
|    ``export_to_file(Dataset,Classifier,Functor,File)``
| **Mode and number of proofs:**
|    ``export_to_file(+object_identifier,+compound,+callable,+atom)`` - ``one``


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

.. index:: print_classifier/1
.. _classifier_protocol/0::print_classifier/1:

``print_classifier/1``
^^^^^^^^^^^^^^^^^^^^^^

Prints a classifier to the current output stream in a human-readable format.

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

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


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

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

(none)

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

(none)

Operators
---------

(none)

.. seealso::

   :ref:`adaptive_boosting_classifier <adaptive_boosting_classifier/0>`, :ref:`c45_classifier <c45_classifier/0>`, :ref:`gradient_boosting_classifier <gradient_boosting_classifier/0>`, :ref:`isolation_forest_anomaly_detector <isolation_forest_anomaly_detector/0>`, :ref:`kernel_svm_classifier <kernel_svm_classifier/0>`, :ref:`knn_classifier <knn_classifier/0>`, :ref:`lda_classifier <lda_classifier/0>`, :ref:`linear_svm_classifier <linear_svm_classifier/0>`, :ref:`logistic_regression_classifier <logistic_regression_classifier/0>`, :ref:`naive_bayes_classifier <naive_bayes_classifier/0>`, :ref:`nearest_centroid_classifier <nearest_centroid_classifier/0>`, :ref:`qda_classifier <qda_classifier/0>`, :ref:`random_forest_classifier <random_forest_classifier/0>`, :ref:`sgd_classifier <sgd_classifier/0>`

