CKMeans类参考


详细描述

KMeans clustering, partitions the data into k (a-priori specified) clusters.

It minimizes

\[ \sum_{i=1}^k\sum_{x_j\in S_i} (x_j-\mu_i)^2 \]

where $\mu_i$ are the cluster centers and $S_i,\;i=1,\dots,k$ 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

在文件KMeans.h39行定义。

继承图,类CKMeans
Inheritance graph
[图例]

所有成员的列表。

公有成员

 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 *&centers, 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 CLabelsclassify ()
virtual CLabelsclassify (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_tR
 radi of the clusters (size k)
float64_tmus
 centers of the clusters (size dimensions x k)

构造及析构函数文档

CKMeans (  ) 

default constructor

在文件KMeans.cpp29行定义。

CKMeans ( int32_t  k,
CDistance d 
)

constructor

参数:
k parameter k
d distance

在文件KMeans.cpp35行定义。

~CKMeans (  )  [virtual]

在文件KMeans.cpp42行定义。


成员函数文档

virtual CLabels* classify ( CFeatures data  )  [protected, virtual]

classify objects

参数:
data (test)data to be classified
返回:
classified labels

实现了CClassifier

在文件KMeans.h224行定义。

virtual CLabels* classify (  )  [protected, virtual]

classify objects using the currently set features

返回:
classified labels

实现了CClassifier

在文件KMeans.h213行定义。

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.cpp177行定义。

void get_centers ( float64_t *&  centers,
int32_t &  dim,
int32_t &  num 
)

get centers

参数:
centers current centers are stored in here
dim dimensions are stored in here
num number of centers is stored in here

在文件KMeans.h138行定义。

virtual EClassifierType get_classifier_type (  )  [virtual]

get classifier type

返回:
classifier type KMEANS

重载CClassifier

在文件KMeans.h57行定义。

void get_cluster_centers ( float64_t **  centers,
int32_t *  dim,
int32_t *  num 
)

get cluster centers (swig compatible)

参数:
centers current cluster centers are stored in here
dim dimensions are stored in here
num number of centers is stored in here

在文件KMeans.h166行定义。

int32_t get_dimensions (  ) 

get dimensions

返回:
number of dimensions

在文件KMeans.h182行定义。

int32_t get_k (  ) 

get k

返回:
the parameter k

在文件KMeans.h97行定义。

float64_t get_max_iter (  ) 

get maximum number of iterations

返回:
maximum number of iterations

在文件KMeans.h116行定义。

virtual const char* get_name (  )  const [protected, virtual]
返回:
object name

实现了CSGObject

在文件KMeans.h233行定义。

void get_radi ( float64_t *&  radi,
int32_t &  num 
)

get radi

参数:
radi current radi are stored in here
num number of radi is stored in here

在文件KMeans.h126行定义。

void get_radiuses ( float64_t **  radii,
int32_t *  num 
)

get radiuses (swig compatible)

参数:
radii current radiuses are stored in here
num number of radiuses is stored in here

在文件KMeans.h150行定义。

bool load ( FILE *  srcfile  )  [virtual]

load distance machine from file

参数:
srcfile file to load from
返回:
if loading was successful

重载CClassifier

在文件KMeans.cpp72行定义。

bool save ( FILE *  dstfile  )  [virtual]

save distance machine to file

参数:
dstfile file to save to
返回:
if saving was successful

重载CClassifier

在文件KMeans.cpp77行定义。

void set_k ( int32_t  p_k  ) 

set k

参数:
p_k new k

在文件KMeans.h87行定义。

void set_max_iter ( int32_t  iter  ) 

set maximum number of iterations

参数:
iter the new maximum

在文件KMeans.h106行定义。

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]

sqdist

参数:
x x
y y
z z
n1 n1
offs offset
n2 n2
m m

在文件KMeans.cpp129行定义。

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)
返回:
whether training was successful

重载CClassifier

在文件KMeans.cpp48行定义。


成员数据文档

int32_t dimensions [protected]

number of dimensions

在文件KMeans.h243行定义。

int32_t k [protected]

the k parameter in KMeans

在文件KMeans.h240行定义。

int32_t max_iter [protected]

maximum number of iterations

在文件KMeans.h237行定义。

float64_t* mus [protected]

centers of the clusters (size dimensions x k)

在文件KMeans.h249行定义。

float64_t* R [protected]

radi of the clusters (size k)

在文件KMeans.h246行定义。


该类的文档由以下文件生成:

SHOGUN Machine Learning Toolbox - Documentation