CKNN类参考
详细描述
Class KNN, an implementation of the standard k-nearest neigbor classifier.
An example is classified to belong to the class of which the majority of the k closest examples belong to.
To avoid ties, k should be an odd number. To define how close examples are k-NN requires a CDistance object to work with (e.g., CEuclideanDistance ).
Note that k-NN has zero training time but classification times increase dramatically with the number of examples. Also note that k-NN is capable of multi-class-classification.
在文件KNN.h第39行定义。
所有成员的列表。
构造及析构函数文档
constructor
- 参数:
-
| k | k |
| d | distance |
| trainlab | labels for training |
在文件KNN.cpp第25行定义。
成员函数文档
classify objects
- 参数:
-
| data | (test)data to be classified |
- 返回:
- classified labels
实现了CClassifier。
在文件KNN.cpp第147行定义。
classify all examples
- 返回:
- resulting labels
histogram of classes and returned output
实现了CClassifier。
在文件KNN.cpp第78行定义。
virtual float64_t classify_example |
( |
int32_t |
vec_idx |
) |
[virtual] |
void classify_for_multiple_k |
( |
int32_t ** |
output, |
|
|
int32_t * |
num_vec, |
|
|
int32_t * |
k_out | |
|
) |
| | |
classify all examples for 1...k
- 参数:
-
| output | resulting labels for all k |
| k_out | number of columns (k) |
| num_vec | number of outputs |
histogram of classes and returned output
在文件KNN.cpp第164行定义。
virtual const char* get_name |
( |
|
) |
const [virtual] |
bool load |
( |
FILE * |
srcfile |
) |
[virtual] |
load from file
- 参数:
-
| srcfile | file to load from |
- 返回:
- if loading was successful
重载CClassifier。
在文件KNN.cpp第235行定义。
bool save |
( |
FILE * |
dstfile |
) |
[virtual] |
void set_k |
( |
int32_t |
p_k |
) |
|
bool train |
( |
CFeatures * |
data = NULL |
) |
[virtual] |
train k-NN classifier
- 参数:
-
| data | training data (parameter can be avoided if distance or kernel-based classifiers are used and distance/kernels are initialized with train data) |
- 返回:
- whether training was successful
重载CClassifier。
在文件KNN.cpp第42行定义。
成员数据文档
smallest label, i.e. -1
在文件KNN.h第143行定义。
number of classes (i.e. number of values labels can take)
在文件KNN.h第140行定义。
number of train examples
在文件KNN.h第146行定义。
该类的文档由以下文件生成: