public final class KNearestNeighbours extends AbstractKNearestNeighbours
k, numOutcomes| Constructor and Description |
|---|
KNearestNeighbours(int numOutcomes,
int k)
Constructs a new knn classifier.
|
| Modifier and Type | Method and Description |
|---|---|
protected List<de.jungblut.jrpt.VectorDistanceTuple<de.jungblut.math.DoubleVector>> |
getNearestNeighbours(de.jungblut.math.DoubleVector feature,
int k)
Find the k nearest neighbours for the given feature.
|
void |
train(Iterable<de.jungblut.math.DoubleVector> features,
Iterable<de.jungblut.math.DoubleVector> outcome)
Trains this classifier with the given features and the outcome.
|
predict, predictProbabilitytrainextractPredictedClass, extractPredictedClass, predictedClass, predictedClassclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitasClassifier, extractPredictedClass, extractPredictedClass, predictedClass, predictedClasspublic KNearestNeighbours(int numOutcomes,
int k)
numOutcomes - the number of different outcomes that can be predicted.k - the number of neighbours to analyse to get a prediction (it does
so by majority voting).public void train(Iterable<de.jungblut.math.DoubleVector> features, Iterable<de.jungblut.math.DoubleVector> outcome)
Classifiertrain in interface Classifiertrain in class AbstractClassifieroutcome - the outcome must have classes labeled as doubles. E.G. in
the binary case you have a single element and decide between 0d
and 1d. In higher dimensional cases you have each of these single
elements mapped to a dimension.protected List<de.jungblut.jrpt.VectorDistanceTuple<de.jungblut.math.DoubleVector>> getNearestNeighbours(de.jungblut.math.DoubleVector feature, int k)
AbstractKNearestNeighboursgetNearestNeighbours in class AbstractKNearestNeighboursfeature - the feature to find neighbours for.k - the number of neighbours to find.VectorDistanceTuple's that contain the outcome of
the retrieved vectors.Copyright © 2016. All rights reserved.