Public Member Functions | |
CKMeans () | |
CKMeans (int32_t k, CDistance *d) | |
virtual | ~CKMeans () |
virtual EClassifierType | get_classifier_type () |
virtual bool | train () |
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 () |
Protected Member Functions | |
void | sqdist (float64_t *x, CRealFeatures *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) |
Protected Attributes | |
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) |
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
Definition at line 36 of file KMeans.h.
CKMeans::CKMeans | ( | ) |
default constructor
Definition at line 27 of file KMeans.cpp.
CKMeans::CKMeans | ( | int32_t | k, | |
CDistance * | d | |||
) |
CKMeans::~CKMeans | ( | ) | [virtual] |
Definition at line 40 of file KMeans.cpp.
void CKMeans::clustknb | ( | bool | use_old_mus, | |
float64_t * | mus_start | |||
) | [protected] |
clustknb
use_old_mus | if old mus shall be used | |
mus_start | mus start |
Definition at line 163 of file KMeans.cpp.
void CKMeans::get_centers | ( | float64_t *& | centers, | |
int32_t & | dim, | |||
int32_t & | num | |||
) |
virtual EClassifierType CKMeans::get_classifier_type | ( | ) | [virtual] |
void CKMeans::get_cluster_centers | ( | float64_t ** | centers, | |
int32_t * | dim, | |||
int32_t * | num | |||
) |
int32_t CKMeans::get_dimensions | ( | ) |
float64_t CKMeans::get_max_iter | ( | ) |
void CKMeans::get_radi | ( | float64_t *& | radi, | |
int32_t & | num | |||
) |
void CKMeans::get_radiuses | ( | float64_t ** | radii, | |
int32_t * | num | |||
) |
bool CKMeans::load | ( | FILE * | srcfile | ) | [virtual] |
load distance machine from file
srcfile | file to load from |
Reimplemented from CClassifier.
Definition at line 66 of file KMeans.cpp.
bool CKMeans::save | ( | FILE * | dstfile | ) | [virtual] |
save distance machine to file
dstfile | file to save to |
Reimplemented from CClassifier.
Definition at line 71 of file KMeans.cpp.
void CKMeans::set_k | ( | int32_t | p_k | ) |
void CKMeans::set_max_iter | ( | int32_t | iter | ) |
void CKMeans::sqdist | ( | float64_t * | x, | |
CRealFeatures * | y, | |||
float64_t * | z, | |||
int32_t | n1, | |||
int32_t | offs, | |||
int32_t | n2, | |||
int32_t | m | |||
) | [protected] |
sqdist
x | x | |
y | y | |
z | z | |
n1 | n1 | |
offs | offset | |
n2 | n2 | |
m | m |
Definition at line 118 of file KMeans.cpp.
bool CKMeans::train | ( | ) | [virtual] |
train distance machine
Reimplemented from CClassifier.
Definition at line 46 of file KMeans.cpp.
int32_t CKMeans::dimensions [protected] |
int32_t CKMeans::k [protected] |
int32_t CKMeans::max_iter [protected] |
float64_t* CKMeans::mus [protected] |
float64_t* CKMeans::R [protected] |