public class KNNClassifier extends AbstractDissimilarityClassifier
Constructor and Description |
---|
KNNClassifier(int[] trainingLabels) |
Modifier and Type | Method and Description |
---|---|
int[] |
calculateVotes(double[] distances)
Returns the number of data points within the k nearest neighbors to the
reference data point, that had some given class label.
|
int[] |
calculateVotes(int i,
double[] distances)
Returns the number of data points within the k nearest neighbors to the
reference data point, that had some given class label.
|
int |
classifyTest(double[] distances)
Returns the supposed class label for some data point, that is not
part of the training set, based on its distances to the training data
set.
|
int |
classifyTraining(int i,
double[] distances)
Returns the supposed class label for some data point in the
training set based on its distances to all training data points.
|
int |
getK()
Returns the number of nearest neighbors that is considered by this
classifier.
|
void |
setK(int K)
Sets the number of nearest neighbors that is considered by this
classifier.
|
calculateTestAccuracy, calculateTrainingAccuracy, getLabels, getTrainingLabels
public int getK()
public void setK(int K)
K
- the number of nearest neighbors that is considered by this
classifier.public int[] calculateVotes(double[] distances)
distances
- the distances of the reference data point to all
training data points considered by this classifier.public int[] calculateVotes(int i, double[] distances)
i
- the index of the reference data point itself.distances
- the distances of the reference data point to all
training data points considered by this classifier.public int classifyTest(double[] distances)
DissimilarityClassifier
classifyTest
in interface DissimilarityClassifier
classifyTest
in class AbstractDissimilarityClassifier
distances
- the distances of the data point to all
training data points.public int classifyTraining(int i, double[] distances)
DissimilarityClassifier
classifyTraining
in interface DissimilarityClassifier
classifyTraining
in class AbstractDissimilarityClassifier
i
- the index of the data point that shall be classified in
the training set.distances
- the distances of the data point to all
training data points.Copyright (C) 2016 Benjamin Paaßen, AG Theoretical Computer Science, Centre of Excellence Cognitive Interaction Technology (CITEC), University of Bielefeld, licensed under the AGPL v. 3: http://openresearch.cit-ec.de/projects/tcs . This documentation is licensed under the conditions of CC-BY-SA 4.0: https://creativecommons.org/licenses/by-sa/4.0/