public class KNNClassifier extends Object implements TrainableClassifier
| Modifier and Type | Field and Description |
|---|---|
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 and Description |
|---|
KNNClassifier() |
KNNClassifier(int k)
Create a K nearest neighbor classifier in which K is set to
specified number.
|
| Modifier and Type | Method and Description |
|---|---|
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.
|
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
public KNNClassifier()
public KNNClassifier(int k)
public void setK(int k)
public void train(TrainingSet s) throws ClassifierException
train in interface TrainableClassifierClassifierExceptionpublic boolean isIncremental()
isIncremental in interface TrainableClassifierpublic void clear()
clear in interface TrainableClassifierpublic Classification classify(FeatureSet s) throws ClassifierException
classify in interface ClassifierClassifierExceptionpublic static void main(String[] argv)
Copyright © 2025 Central Laboratory of the Research Councils. All Rights Reserved.