Kernel k-Means Algorithm. More...
#include <rkernelkmeans.h>
Public Member Functions | |
RKernelkMeans (const RString &n, RRandom &r, RCursor< cObj > objs, size_t maxid, double alpha, double convergence, RDebug *debug=0) | |
void | Init (void) |
RString | GetName (void) const |
size_t | GetNbIterations (void) const |
virtual void | FillSimilarities (RSparseMatrix &sims)=0 |
virtual double | Fitness (void) |
void | DokMeans (size_t max) |
void | Run (cGroups *groups, size_t max, size_t nb, bool spherical) |
virtual | ~RKernelkMeans (void) |
Protected Member Functions | |
void | InitRandom (size_t nb) |
void | UpdateBinaryH (bool center=true) |
void | UpdateH (bool center=true) |
void | NormalizeH (bool center=true) |
void | ComputeY (bool center=true) |
size_t | ReAllocate (void) |
Protected Attributes | |
RString | Name |
RDebug * | Debug |
RRandom & | Rand |
cGroups * | Groups |
size_t | MaxId |
RCursor< cObj > | Objs |
RCursor< cObj > | CopyObjs |
cObj ** | ObjsUsed |
size_t | NbIterations |
double | Alpha |
double | Convergence |
RSparseMatrix | P |
RVector | InvD |
RMatrix | H |
RMatrix | Y |
RNumContainer< size_t > | Assignments |
RVector | Temp |
bool | WasInit |
double | FitnessValue |
bool | Spherical |
RTextFile | Out |
bool | PrintOut |
RString | OutName |
Detailed Description
template<class cGroup, class cObj, class cGroups>
class R::RKernelkMeans< cGroup, cObj, cGroups >
Kernel k-Means Algorithm.
The RKernelkMeans class provides the implementation of a kernel k-Means grouping algorithm.
Constructor & Destructor Documentation
RKernelkMeans | ( | const RString & | n, |
RRandom & | r, | ||
RCursor< cObj > | objs, | ||
size_t | maxid, | ||
double | alpha, | ||
double | convergence, | ||
RDebug * | debug = 0 |
||
) |
Construct the k-Means.
- Parameters
-
n Name of the k-Means. r Random number generator to use. objs Cursor over the objects to group (ordered by identifier). maxid Maximum identifier of an object. alpha Alpha parameter. convergence Convergence when computing yk. debug Debugger.
|
virtual |
Destruct the k-Means.
Member Function Documentation
void Init | ( | void | ) |
Initialize (once) the algorithm.
RString GetName | ( | void | ) | const |
Get the name of the heuristic.
size_t GetNbIterations | ( | void | ) | const |
Get the number of iterations run.
|
protected |
Creates the initial prototypes by randomly choosing them.
- Parameters
-
nb Number of groups to create.
|
protected |
Update the H matrix when the objects are assigned. The elements of hk are set to 1 if the object is assigned to group k, otherwise 0.
- Parameters
-
center The H matrix must be centered.
|
protected |
Update the H matrix when the objects are assigned. The elements of hk are set to 1/(number of elements in group k) if the object is assigned to group k, otherwise 0.
- Parameters
-
center The H matrix must be centered.
|
protected |
Normalize the H matrix.
- Parameters
-
center The H matrix must be centered.
|
protected |
Compute re-cursively the Y matrix.
- Parameters
-
center The Y matrix must be centered.
|
protected |
Re-Allocation step where the objects are put in the group that minimize the right expression.
- Returns
- the number of object re-allocated
|
pure virtual |
Fill a sparse matrix with the similarities. It may be the full matrix or the nearest neighbors.
- Parameters
-
sims Matrix to compute.
|
virtual |
Compute the fitness of the given clustering (the higher is the fitness, the best is the clustering.
By default, it computes the ratio between the average intra-similarity and the similarity between the centroids and the meta-centroid.
void DokMeans | ( | size_t | max | ) |
Perform a kMeans.
- Parameters
-
max Maximal number of iterations.
void Run | ( | cGroups * | groups, |
size_t | max, | ||
size_t | nb, | ||
bool | spherical | ||
) |
Run the heuristic.
- Parameters
-
groups Group to initialize. max Maximal number of iterations. nb Number of groups to create. spherical Spherical Kernel k-Means.
Member Data Documentation
|
protected |
Name of the k-Means
|
protected |
Debugger.
|
protected |
Random number generator to use.
|
protected |
Groups.
|
protected |
Maximum identifier of an object.
|
protected |
Objects to be grouped.
|
protected |
Objects to be grouped.
|
protected |
Objects used to build the clusters.
|
protected |
Number of Iterations.
|
protected |
Aplha.
|
protected |
Convergence ratio used to compute yk.
|
protected |
The P matrix (D^-1*S)
|
protected |
Inverse of the D vector.
|
protected |
The H matrix (each column is a vector corresponding to hk).
|
protected |
The Y matrix (each column is a vector corresponding to hk).
|
protected |
Store the assignments of the different elements.
|
protected |
Temporary vector.
|
protected |
Algorithm initialized ?
|
protected |
Fitness of the solution.
|
protected |
Spherical k-Means;
|
protected |
Output file with information.
|
protected |
Print the information.
|
protected |
Name of the output file.