MetricKnn API
Fast Similarity Search using the Metric Space Approach
mknn_kmeans.h
1 /*
2  * Copyright (C) 2012-2015, Juan Manuel Barrios <juanmanuel@barrios.cl>
3  * All rights reserved.
4  *
5  * This file is part of MetricKnn.
6  * MetricKnn is made available under the terms of the BSD 2-Clause License.
7  */
8 
9 #ifndef MKNN_KMEANS_H_
10 #define MKNN_KMEANS_H_
11 
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15 
16 #include "../metricknn_c.h"
17 
19 
20 typedef void (*mknn_kmeans_function_callback)(MknnKmeansAlgorithm *kmeans,
21  int64_t num_iteration, bool is_last_iteration, void *state_pointer);
22 
28 MknnKmeansAlgorithm *mknn_kmeans_new();
29 
35 void mknn_kmeans_setDataset(MknnKmeansAlgorithm *kmeans, MknnDataset *dataset);
41 void mknn_kmeans_setDistance(MknnKmeansAlgorithm *kmeans,
42  MknnDistance *distance);
43 
49 void mknn_kmeans_setNumCentroids(MknnKmeansAlgorithm *kmeans,
50  int64_t num_centroids);
51 
52 MknnDataset *mknn_kmeans_getDataset(MknnKmeansAlgorithm *kmeans);
53 MknnDistance *mknn_kmeans_getDistance(MknnKmeansAlgorithm *kmeans);
54 int64_t mknn_kmeans_getNumCentroids(MknnKmeansAlgorithm *kmeans);
55 
62 void mknn_kmeans_setMaxThreads(MknnKmeansAlgorithm *kmeans,
63  int64_t max_threads);
64 
65 void mknn_kmeans_setTermitationCriteria(MknnKmeansAlgorithm *kmeans,
66  int64_t maxIteration, double maxSecondsProcess,
67  double pctOrNumberMinMovedVectors, double pctOrNumberMinMovedCentroids);
68 
69 void mknn_kmeans_addSubsetRun(MknnKmeansAlgorithm *kmeans,
70  double pctOrNumberSampleSize, int64_t terminationMaxIteration,
71  double terminationMaxSecondsProcess,
72  double terminationPctOrNumberMinMovedVectors,
73  double terminationPctOrNumberMinMovedCentroids);
74 void mknn_kmeans_addDefaultSubsetRuns(MknnKmeansAlgorithm *kmeans);
75 
76 void mknn_kmeans_setDefaultCentroidsDatatype(MknnKmeansAlgorithm *kmeans,
77  MknnDatatype datatype);
78 MknnDatatype mknn_kmeans_getDefaultCentroidsDatatype(
79  MknnKmeansAlgorithm *kmeans);
80 
81 void mknn_kmeans_initCentroidsRandom(MknnKmeansAlgorithm *kmeans);
82 void mknn_kmeans_initCentroidsSSS(MknnKmeansAlgorithm *kmeans);
83 void mknn_kmeans_setInitialCentroids(MknnKmeansAlgorithm *kmeans,
84  MknnDataset *centroids_dataset, bool release_centroids_on_release);
85 
86 void mknn_kmeans_setParametersMknnIndex(MknnKmeansAlgorithm *kmeans,
87  const char *parameters_mknn_index);
88 void mknn_kmeans_setParametersMknnResolver(MknnKmeansAlgorithm *kmeans,
89  const char *parameters_mknn_resolver);
90 
91 void mknn_kmeans_selectRandomCentroids(MknnKmeansAlgorithm *kmeans);
92 void mknn_kmeans_loadState(MknnKmeansAlgorithm *kmeans,
93  const char *filenameSavedState);
94 void mknn_kmeans_setAutoSaveState(MknnKmeansAlgorithm *kmeans,
95  const char *filenameOutput, double secondsAutoSave);
96 void mknn_kmeans_saveState(MknnKmeansAlgorithm *kmeans,
97  const char *filenameOutput);
98 void mknn_kmeans_setIterationCallBackFunction(MknnKmeansAlgorithm *kmeans,
99  mknn_kmeans_function_callback function, void *state_pointer);
100 
101 void mknn_kmeans_perform(MknnKmeansAlgorithm *kmeans);
102 
103 MknnDataset *mknn_kmeans_getCentroids(MknnKmeansAlgorithm *kmeans,
104 bool dont_release_centroids_on_kmeans_release);
105 
106 int64_t *mknn_kmeans_getAssignations(MknnKmeansAlgorithm *kmeans,
107 bool dont_release_assignations_on_kmeans_release);
108 
109 MknnDataset *mknn_kmeans_getAssignationsDataset(MknnKmeansAlgorithm *kmeans,
110  int64_t id_cluster);
111 
113  int64_t num_assignations;
114  double sum_squared_error, average_squared_error;
115  double distances_minimum, distances_maximum;
116  double distances_average, distances_variance, distances_std_dev,
117  distances_skewness, distances_kurtosis;
118  double *averages_by_dimension;
119  double *variances_by_dimension;
120 };
122  double sum_squared_error;
123  double average_squared_error;
124 };
125 
126 struct MknnKmeansStatsCluster *mknn_kmeans_getStatsCluster(
127  MknnKmeansAlgorithm *kmeans, int64_t id_cluster);
128 
129 struct MknnKmeansStatsClustering *mknn_kmeans_getStatsClustering(
130  MknnKmeansAlgorithm *kmeans);
131 
132 void mknn_kmeans_release(MknnKmeansAlgorithm *kmeans);
133 
134 #ifdef __cplusplus
135 }
136 #endif
137 
138 #endif
Definition: kmeans.c:41
Definition: distance.c:17
Definition: dataset.c:11
Definition: mknn_kmeans.h:112
Definition: mknn_kmeans.h:121
Represents a constant for a datatype, like integer 8bits, float 32 bits, etc.
Definition: metricknn_c.h:35
Powered by Download MetricKnn