public class KMeansPDN extends KMeans
KMeans
clustering when the
value of K
is not known. It works by incrementing the value
of k
up to some specified maximum, and running a full KMeans for each
value. K
that is capped at 100 when using the
ClustererBase.cluster(jsat.DataSet)
type methods. K
is specified, the implementation will simply call
the regular KMeans object it was constructed with.
See: Pham, D. T., Dimov, S. S.,&Nguyen, C. D. (2005). Selection of K in
K-means clustering. Proceedings of the Institution of Mechanical
Engineers, Part C: Journal of Mechanical Engineering Science, 219(1),
103–119. doi:10.1243/095440605X8298DEFAULT_SEED_SELECTION, dm, MaxIterLimit, means, nearestCentroidDist, rand, saveCentroidDistance, seedSelection, storeMeans
Constructor and Description |
---|
KMeansPDN()
Creates a new clusterer.
|
KMeansPDN(KMeans kmeans)
Creates a new clustered that uses the specified object to perform clustering for all
k . |
KMeansPDN(KMeansPDN toCopy)
Copy constructor
|
Modifier and Type | Method and Description |
---|---|
KMeansPDN |
clone() |
int[] |
cluster(DataSet dataSet,
ExecutorService threadpool,
int[] designations)
Performs clustering on the given data set.
|
int[] |
cluster(DataSet dataSet,
int[] designations)
Performs clustering on the given data set.
|
int[] |
cluster(DataSet dataSet,
int lowK,
int highK,
ExecutorService threadpool,
int[] designations) |
int[] |
cluster(DataSet dataSet,
int lowK,
int highK,
int[] designations) |
protected double |
cluster(DataSet dataSet,
List<Double> accelCache,
int k,
List<Vec> means,
int[] assignment,
boolean exactTotal,
ExecutorService threadpool,
boolean returnError,
Vec dataPointWeights)
This is a helper method where the actual cluster is performed.
|
double[] |
getfKs()
Returns the array of
f(K) values generated for the last data set. |
cluster, cluster, getDistanceMetric, getIterationLimit, getListOfLists, getMeans, getParameter, getParameters, getSeedSelection, setIterationLimit, setSeedSelection, setStoreMeans, supportsWeightedData
cluster, cluster, cluster, cluster
cluster, cluster, createClusterListFromAssignmentArray, getDatapointsFromCluster
public KMeansPDN()
public KMeansPDN(KMeans kmeans)
k
.kmeans
- the k-means object to use for clusteringpublic KMeansPDN(KMeansPDN toCopy)
toCopy
- the object to copypublic double[] getfKs()
f(K)
values generated for the last data set.
The value at index i
is the score for cluster i+1
.
Smaller values indicate better clusterings.f(K)
values, or null
if no data set
has been clusteredpublic int[] cluster(DataSet dataSet, int[] designations)
Clusterer
cluster
in interface Clusterer
cluster
in class KMeans
dataSet
- the data set to perform clustering ondesignations
- the array which will contain the designated values. The array will be altered and returned by
the function. If null is given, a new array will be created and returned.public int[] cluster(DataSet dataSet, ExecutorService threadpool, int[] designations)
Clusterer
cluster
in interface Clusterer
cluster
in class KMeans
dataSet
- the data set to perform clustering onthreadpool
- a source of threads to run tasksdesignations
- the array which will contain the designated values. The array will be altered and returned by
the function. If null is given, a new array will be created and returned.public int[] cluster(DataSet dataSet, int lowK, int highK, ExecutorService threadpool, int[] designations)
cluster
in interface KClusterer
cluster
in class KMeans
public int[] cluster(DataSet dataSet, int lowK, int highK, int[] designations)
cluster
in interface KClusterer
cluster
in class KMeans
protected double cluster(DataSet dataSet, List<Double> accelCache, int k, List<Vec> means, int[] assignment, boolean exactTotal, ExecutorService threadpool, boolean returnError, Vec dataPointWeights)
KMeans
cluster
in class KMeans
dataSet
- The set of data points to perform clustering onaccelCache
- acceleration cache to use, or null
. If
null
, the kmeans code will attempt to create onek
- the number of clustersmeans
- the initial points to use as the means. Its length is the
number of means that will be searched for. These means will be altered,
and should contain deep copies of the points they were drawn from. May be
empty, in which case the list will be filled with some selected meansassignment
- an empty temp space to store the clustering
classifications. Should be the same length as the number of data pointsexactTotal
- determines how the objective function (return value)
will be computed. If true, extra work will be done to compute the exact
distance from each data point to its cluster. If false, an upper bound
approximation will be used. This also impacts the value stored in
KMeans.nearestCentroidDist
threadpool
- the source of threads for parallel computation. If
null, single threaded execution will occurreturnError
- true
is the sum of squared distances should be
returned. false
means any value can be returned.
KMeans.saveCentroidDistance
only applies if this is true
dataPointWeights
- the weight value to use for each data point. If
null, assume each point has equal weight.Copyright © 2017. All rights reserved.