| Did you know ... | Search Documentation: |
| Pack logtalk -- logtalk-3.100.1/docs/apis/_sources/knn_classifier_0.rst.txt |
.. index:: single: knn_classifier .. _knn_classifier/0:
.. rst-class:: right
object
knn_classifier
k-Nearest Neighbors classifier with multiple distance metrics and weighting options. Learns from a dataset object implementing the dataset_protocol protocol and returns a classifier term that can be used for prediction and exported as predicate clauses.
| Availability:
| logtalk_load(knn_classifier(loader))
| Author: Paulo Moura | Version: 2:0:0 | Date: 2026-05-11
| Compilation flags:
| static, context_switching_calls
| Imports:
| public :ref:`probabilistic_classifier_common <probabilistic_classifier_common/0>`
| Uses:
| :ref:`format <format/0>`
| :ref:`list <list/0>`
| :ref:`pairs <pairs/0>`
| :ref:`type <type/0>`
| Remarks: | (none)
| Inherited public predicates: | Â :ref:`classifier_protocol/0::check_classifier/1` Â :ref:`options_protocol/0::check_option/1` Â :ref:`options_protocol/0::check_options/1` Â :ref:`classifier_protocol/0::classifier_options/2` Â :ref:`options_protocol/0::default_option/1` Â :ref:`options_protocol/0::default_options/1` Â :ref:`classifier_protocol/0::diagnostic/2` Â :ref:`classifier_protocol/0::diagnostics/2` Â :ref:`classifier_protocol/0::export_to_clauses/4` Â :ref:`classifier_protocol/0::export_to_file/4` Â :ref:`classifier_protocol/0::learn/2` Â :ref:`classifier_protocol/0::learn/3` Â :ref:`options_protocol/0::option/2` Â :ref:`options_protocol/0::option/3` Â :ref:`classifier_protocol/0::predict/3` Â :ref:`probabilistic_classifier_protocol/0::predict_probabilities/3` Â :ref:`classifier_protocol/0::print_classifier/1` Â :ref:`classifier_protocol/0::valid_classifier/1` Â :ref:`options_protocol/0::valid_option/1` Â :ref:`options_protocol/0::valid_options/1` Â
.. contents:: :local: :backlinks: top
.. index:: predict/4 .. _knn_classifier/0::predict/4:
predict/4 ^^^^^^^^^^^^^
Predicts the class label for a new instance using the learned classifier and the given options. The instance is a list of Attribute-Value pairs.
| Compilation flags:
| static
| Template:
| predict(Classifier,Instance,Class,Options)
| Mode and number of proofs:
| predict(+compound,+list,-atom,+list(compound)) - one
.. index:: predict_probabilities/4 .. _knn_classifier/0::predict_probabilities/4:
predict_probabilities/4 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
Predicts class probabilities for a new instance using the learned classifier and the given options. Returns a list of Class-Probability pairs. The instance is a list of Attribute-Value pairs.
| Compilation flags:
| static
| Template:
| predict_probabilities(Classifier,Instance,Probabilities,Options)
| Mode and number of proofs:
| predict_probabilities(+compound,+list,-list,+list(compound)) - one
(no local declarations; see entity ancestors if any)
(no local declarations; see entity ancestors if any)
(none)
.. seealso::
:ref:`dataset_protocol <dataset_protocol/0>`, :ref:`c45_classifier <c45_classifier/0>`, :ref:`isolation_forest_anomaly_detector <isolation_forest_anomaly_detector/0>`, :ref:`naive_bayes_classifier <naive_bayes_classifier/0>`, :ref:`nearest_centroid_classifier <nearest_centroid_classifier/0>`, :ref:`random_forest_classifier <random_forest_classifier/0>`, :ref:`adaptive_boosting_classifier <adaptive_boosting_classifier/0>`