aboutsummaryrefslogtreecommitdiff
path: root/km.h
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2019-02-03 18:36:52 -0500
committerPaul Duncan <pabs@pablotron.org>2019-02-03 18:36:52 -0500
commit33a722132491ebdd31722f0cada0f81f6b082282 (patch)
tree389ae93db5d0a1ff8085ea5f38026d5e060deea1 /km.h
parentaa74bd04f66217ff4d617924630b13d721578159 (diff)
downloadkmeans-33a722132491ebdd31722f0cada0f81f6b082282.tar.bz2
kmeans-33a722132491ebdd31722f0cada0f81f6b082282.zip
cluster init refactoring, fix best sort, add km_score()
Diffstat (limited to 'km.h')
-rw-r--r--km.h22
1 files changed, 14 insertions, 8 deletions
diff --git a/km.h b/km.h
index c70e13e..6f09009 100644
--- a/km.h
+++ b/km.h
@@ -5,6 +5,14 @@
#include <stdint.h> // uint8_t
#include <stdio.h> // FILE
+typedef enum {
+ KM_INIT_TYPE_RAND,
+ KM_INIT_TYPE_FORGY,
+ KM_INIT_TYPE_LAST,
+} km_init_type_t;
+
+km_init_type_t km_get_init_type(const char * const);
+
// forward typedef for callbacks
typedef struct km_rand_t_ km_rand_t;
@@ -77,21 +85,19 @@ _Bool km_set_normalize(km_set_t * const);
// get pointer to data set row
float *km_set_get_row(const km_set_t *, const size_t);
-// init a set with num_clusters clusters of shape num_floats by picking
-// random cluster centers
-_Bool km_set_init_rand_clusters(
+// init cluster set by picking random centroids
+_Bool km_init_rand(
km_set_t *,
const size_t,
const size_t,
km_rand_t *
);
-// init a set with num_clusters clusters of random points from the
-// given set
-_Bool km_set_init_rand_points(
+// init cluster set by picking random rows from set
+_Bool km_init_forgy(
km_set_t * const,
- const km_set_t * const,
const size_t,
+ const km_set_t * const,
km_rand_t *
);
@@ -134,8 +140,8 @@ typedef struct {
typedef _Bool (*km_find_init_cb_t)(
km_set_t * const cluster_set,
- const size_t num_floats,
const size_t num_clusters,
+ const km_set_t * const data_set,
void *cb_data
);