public abstract class AbstractKNearestNeighbours extends AbstractClassifier
| Modifier and Type | Field and Description |
|---|---|
protected int |
k |
protected int |
numOutcomes |
| Constructor and Description |
|---|
AbstractKNearestNeighbours(int numOutcomes,
int k)
Constructs a new knn classifier.
|
| Modifier and Type | Method and Description |
|---|---|
protected abstract 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.
|
de.jungblut.math.DoubleVector |
predict(de.jungblut.math.DoubleVector features)
Classifies the given features.
|
de.jungblut.math.DoubleVector |
predictProbability(de.jungblut.math.DoubleVector features)
Classifies the given features.
|
train, trainextractPredictedClass, extractPredictedClass, predictedClass, predictedClassclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitasClassifier, extractPredictedClass, extractPredictedClass, predictedClass, predictedClasspublic AbstractKNearestNeighbours(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 de.jungblut.math.DoubleVector predict(de.jungblut.math.DoubleVector features)
Predictorpublic de.jungblut.math.DoubleVector predictProbability(de.jungblut.math.DoubleVector features)
PredictorpredictProbability in interface PredictorpredictProbability in class AbstractPredictorprotected abstract List<de.jungblut.jrpt.VectorDistanceTuple<de.jungblut.math.DoubleVector>> getNearestNeighbours(de.jungblut.math.DoubleVector feature, int k)
feature - 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.