JWS C Library
C language utility library
|
Definition of kmeans clustering algorithm and associated functions. More...
#include <jwsc/config.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <assert.h>
#include <limits.h>
#include <inttypes.h>
#include "jwsc/vector/vector.h"
#include "jwsc/matrix/matrix.h"
#include "jwsc/prob/pdf.h"
#include "jwsc/stat/kmeans.h"
Go to the source code of this file.
Functions | |
void | kmeans_d (Matrix_d **means_out, Vector_i32 **members_out, const Matrix_d *features, uint32_t K, uint32_t N) |
K Means algorithm. | |
void | init_kmeans_randomly_d (Matrix_d **means_out, const Matrix_d *features, uint32_t K) |
Randomly chooses k feature vectors to initialize the means with. |
Definition of kmeans clustering algorithm and associated functions.
Definition in file kmeans.c.
void kmeans_d | ( | Matrix_d ** | means_out, |
Vector_i32 ** | members_out, | ||
const Matrix_d * | features, | ||
uint32_t | K, | ||
uint32_t | N | ||
) |
K Means algorithm.
Implements a fairly standard k-means algorithm.
Currently, the algorithm handles < N mean membership as follows: if a mean has n < N membership, N-n feature vectors are choosen at random to be members. Note that the random number generator is assumed to already be seeded (rand() is used).
means_out | Result parameter. If *means_out is NULL when the function is called, the means are initialized by calling init_means_randomly(). Otherwise, *means_out is assumed to contain initialized means. Contains the resulting means when the function returns. |
members_out | Result parameter. When the function returns, (*members_out)->elts[i] contains the mean number (row index into *means_out) for the ith feature vector. |
features | Feature vectors to assign membership to means. |
K | Number of means. |
N | Minimum number of records per mean. |
Randomly chooses k feature vectors to initialize the means with.
means_out | Result parameter. When the function returns, contains the initialized means. |
features | Feature vectors to randomly choose from for mean initialization. |
K | Number of means. |