object
knn
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.
logtalk_load(knn(loader))static, context_switching_calls
Algorithm: k-NN is a lazy learning algorithm that classifies instances based on the majority class among the k nearest training instances.
Distance metrics: Supports Euclidean, Manhattan, Chebyshev, and Minkowski distance metrics.
Weighting schemes: Supports uniform, distance-based, and Gaussian weighting of neighbors.
Feature types: Automatically handles numeric and categorical features.
Classifier representation: The learned classifier is represented (by default) as a
knn_classifier(AttributeNames, FeatureTypes, Instances)whereInstancescontains the training data.
Public predicates
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.
staticpredict(Classifier,Instance,Class,Options)predict(+compound,+list,-atom,+list(compound)) - onepredict_probabilities/3
Predicts class probabilities for a new instance using the learned classifier and default options. Returns a list of Class-Probability pairs. The instance is a list of Attribute-Value pairs.
staticpredict_probabilities(Classifier,Instance,Probabilities)predict_probabilities(+compound,+list,-list) - onepredict_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.
staticpredict_probabilities(Classifier,Instance,Probabilities,Options)predict_probabilities(+compound,+list,-list,+list(compound)) - oneProtected predicates
(no local declarations; see entity ancestors if any)
Private predicates
(no local declarations; see entity ancestors if any)
Operators
(none)
See also
dataset_protocol, c45, isolation_forest, naive_bayes, nearest_centroid, random_forest, ada_boost