KMeans clustering, partitions the data into k (a-priori specified) clusters.
It minimizes
where
are the cluster centers and
are the index sets of the clusters.
Beware that this algorithm obtains only a local optimum.
cf. http://en.wikipedia.org/wiki/K-means_algorithm

公有成员 | |
| CKMeans () | |
| CKMeans (int32_t k, CDistance *d) | |
| virtual | ~CKMeans () |
| virtual EClassifierType | get_classifier_type () |
| virtual bool | train (CFeatures *data=NULL) |
| virtual bool | load (FILE *srcfile) |
| virtual bool | save (FILE *dstfile) |
| void | set_k (int32_t p_k) |
| int32_t | get_k () |
| void | set_max_iter (int32_t iter) |
| float64_t | get_max_iter () |
| void | get_radi (float64_t *&radi, int32_t &num) |
| void | get_centers (float64_t *¢ers, int32_t &dim, int32_t &num) |
| void | get_radiuses (float64_t **radii, int32_t *num) |
| void | get_cluster_centers (float64_t **centers, int32_t *dim, int32_t *num) |
| int32_t | get_dimensions () |
保护成员 | |
| void | sqdist (float64_t *x, CSimpleFeatures< float64_t > *y, float64_t *z, int32_t n1, int32_t offs, int32_t n2, int32_t m) |
| void | clustknb (bool use_old_mus, float64_t *mus_start) |
| virtual CLabels * | classify () |
| virtual CLabels * | classify (CFeatures *data) |
| virtual const char * | get_name () const |
保护属性 | |
| int32_t | max_iter |
| maximum number of iterations | |
| int32_t | k |
| the k parameter in KMeans | |
| int32_t | dimensions |
| number of dimensions | |
| float64_t * | R |
| radi of the clusters (size k) | |
| float64_t * | mus |
| centers of the clusters (size dimensions x k) | |
| CKMeans | ( | ) |
default constructor
在文件KMeans.cpp第29行定义。
| ~CKMeans | ( | ) | [virtual] |
在文件KMeans.cpp第42行定义。
| virtual CLabels* classify | ( | ) | [protected, virtual] |
| void clustknb | ( | bool | use_old_mus, | |
| float64_t * | mus_start | |||
| ) | [protected] |
clustknb
| use_old_mus | if old mus shall be used | |
| mus_start | mus start |
replace rhs feature vectors
set rhs to mus_start
update rhs
sqdist(mus, lhs, dists, k, Pat, 1, dimensions);
在文件KMeans.cpp第177行定义。
| void get_centers | ( | float64_t *& | centers, | |
| int32_t & | dim, | |||
| int32_t & | num | |||
| ) |
| virtual EClassifierType get_classifier_type | ( | ) | [virtual] |
| void get_cluster_centers | ( | float64_t ** | centers, | |
| int32_t * | dim, | |||
| int32_t * | num | |||
| ) |
| float64_t get_max_iter | ( | ) |
| virtual const char* get_name | ( | ) | const [protected, virtual] |
| void get_radi | ( | float64_t *& | radi, | |
| int32_t & | num | |||
| ) |
| void get_radiuses | ( | float64_t ** | radii, | |
| int32_t * | num | |||
| ) |
| bool load | ( | FILE * | srcfile | ) | [virtual] |
load distance machine from file
| srcfile | file to load from |
重载CClassifier。
在文件KMeans.cpp第72行定义。
| bool save | ( | FILE * | dstfile | ) | [virtual] |
save distance machine to file
| dstfile | file to save to |
重载CClassifier。
在文件KMeans.cpp第77行定义。
| void set_max_iter | ( | int32_t | iter | ) |
| void sqdist | ( | float64_t * | x, | |
| CSimpleFeatures< float64_t > * | y, | |||
| float64_t * | z, | |||
| int32_t | n1, | |||
| int32_t | offs, | |||
| int32_t | n2, | |||
| int32_t | m | |||
| ) | [protected] |
| bool train | ( | CFeatures * | data = NULL |
) | [virtual] |
train k-means
| data | training data (parameter can be avoided if distance or kernel-based classifiers are used and distance/kernels are initialized with train data) |
重载CClassifier。
在文件KMeans.cpp第48行定义。
int32_t dimensions [protected] |