|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectdiva.sketch.classification.KNNClassifier
public class KNNClassifier
A K Nearest Neighbor classifier compares a given example (feature set) to the training set and make its prediction based on the majority match in the top K candidates.
Field Summary | |
---|---|
static double[] |
f1
|
static double[] |
f2
|
static double[] |
f3
|
static double[] |
f4
|
static double[] |
f5
|
static double[] |
f6
|
static double[] |
f7
|
static double[] |
f8
|
static double[] |
f9
|
Constructor Summary | |
---|---|
KNNClassifier()
|
|
KNNClassifier(int k)
Create a K nearest neighbor classifier in which K is set to specified number. |
Method Summary | |
---|---|
Classification |
classify(FeatureSet s)
Compare the given example (features) to the examples in the training set and save the top K closest matches in ascending distance values. |
void |
clear()
Clear all results of previous trainings (presumably so that this classifier can be trained again from scratch). |
boolean |
isIncremental()
Return true. |
static void |
main(String[] argv)
|
void |
setK(int k)
Set the value of K. |
void |
train(TrainingSet s)
Store the given training set which will be used during classification. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static double[] f1
public static double[] f2
public static double[] f3
public static double[] f4
public static double[] f5
public static double[] f6
public static double[] f7
public static double[] f8
public static double[] f9
Constructor Detail |
---|
public KNNClassifier()
public KNNClassifier(int k)
Method Detail |
---|
public void setK(int k)
public void train(TrainingSet s) throws ClassifierException
train
in interface TrainableClassifier
ClassifierException
public boolean isIncremental()
isIncremental
in interface TrainableClassifier
public void clear()
clear
in interface TrainableClassifier
public Classification classify(FeatureSet s) throws ClassifierException
classify
in interface Classifier
ClassifierException
public static void main(String[] argv)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |