Mean Shift Clustering
A fast implementation of mean-shift clustering using dual-tree range search. Given a dataset, this uses the mean shift algorithm to produce and return a clustering of the data.
:- use_module('path/to/.../src/methods/mean_shift/mean_shift.pl').
%% usage example
TrainData = [5.1,3.5,1.4, 4.9,3.0,1.4, 4.7,3.2,1.3, 4.6,3.1,1.5],
meanShift(1, 1000, TrainData, 3, AssignList, CentroidsList, _, 0, 0).
Available Predicates
meanShift/9
Perform mean shift clustering on the data, returning a list of cluster assignments and centroids.
%% predicate definition
meanShift(Radius, MaxIterations, DataList, DataRows, AssignmentsList, CentroidsList, ZCols, ForceConvergence, UseSeeds) :-
MaxIterations >= 0,
convert_list_to_float_array(DataList, DataRows, array(Xsize, Xrownum, X)),
meanShiftI(Radius, MaxIterations, X, Xsize, Xrownum, Y, Ysize, Z, ZCols, ZRows, ForceConvergence, UseSeeds),
convert_float_array_to_list(Y, Ysize, AssignmentsList),
convert_float_array_to_2d_list(Z, ZCols, ZRows, CentroidsList).
%% foreign c++ predicate definition
foreign(meanShift, c, meanShiftI( +float32, +integer,
+pointer(float_array), +integer, +integer,
-pointer(float_array), -integer,
-pointer(float_array), -integer, -integer,
+integer, +integer)).
Parameters
Name | Type | Description | Default |
---|---|---|---|
radius | +float | If distance of two centroids is less than it, one will be removed. If this value isn't positive, an estimation will be given when clustering. | 0.0 |
maxIterations | +integer | Maximum number of iterations allowed before giving up iterations will terminate. | 1000 |
data | +matrix | Dataset to cluster. | - |
assignments | -vector | Vector to store cluster assignments in. | - |
centroids | -matrix | Matrix in which centroids are stored. | - |
foreceConvergence | +integer(bool) | Flag whether to force each centroid seed to converge regardless of maxIterations. | (1)true |
useSeeds | +integer(bool) | Set true to use seeds. | (1)true |
Connected Links/Resources
If you want a more detailed explanation, then go to the python documentation. There is most of the time a good explanation on how the methods work and what the parameters do.
added some of the links from the python documentation