jsat.clustering.kmeans
Class KernelKMeans
- java.lang.Object
-
- jsat.clustering.ClustererBase
-
- jsat.clustering.KClustererBase
-
- jsat.clustering.kmeans.KernelKMeans
-
- All Implemented Interfaces:
- java.io.Serializable, Clusterer, KClusterer, Parameterized
- Direct Known Subclasses:
- ElkanKernelKMeans, LloydKernelKMeans
public abstract class KernelKMeans extends KClustererBase implements Parameterized
Base class for various Kernel K Means implementations. Because the Kernelized version is more computationally expensive, only the clustering methods where the number of clusters is specified apriori are supported.
KernelKMeans keeps a reference to the data passed in for clustering so that queries can be conveniently answered, such as gettingthe closest clusteror finding thedistance between means- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description KernelKMeans(KernelKMeans toCopy)Copy constructorKernelKMeans(KernelTrick kernel)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method and Description abstract KernelKMeansclone()int[]cluster(DataSet dataSet, boolean parallel, 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, boolean parallel, int[] designations)int[]cluster(DataSet dataSet, int lowK, int highK, int[] designations)doubledistance(Vec x, int k)Returns the distance between the given data point and the the specified clusterdoubledistance(Vec x, java.util.List<java.lang.Double> qi, int k)Returns the distance between the given data point and the the specified clusterintfindClosestCluster(Vec x)Finds the cluster ID that is closest to the given data pointintfindClosestCluster(Vec x, java.util.List<java.lang.Double> qi)Finds the cluster ID that is closest to the given data pointintgetMaximumIterations()Returns the maximum number of iterations of the KMeans algorithm that will be performed.doublemeanToMeanDistance(int k0, int k1)Computes the distance between two of the means in the clusteringvoidsetMaximumIterations(int iterLimit)Sets the maximum number of iterations allowedbooleansupportsWeightedData()Indicates whether the model knows how to cluster using weighted data points.-
Methods inherited from class jsat.clustering.ClustererBase
createClusterListFromAssignmentArray, getDatapointsFromCluster
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface jsat.parameters.Parameterized
getParameter, getParameters
-
-
-
-
Constructor Detail
-
KernelKMeans
public KernelKMeans(KernelTrick kernel)
- Parameters:
kernel- the kernel to use
-
KernelKMeans
public KernelKMeans(KernelKMeans toCopy)
Copy constructor- Parameters:
toCopy- the object to copy
-
-
Method Detail
-
setMaximumIterations
public void setMaximumIterations(int iterLimit)
Sets the maximum number of iterations allowed- Parameters:
iterLimit- the maximum number of iterations of the KMeans algorithm
-
getMaximumIterations
public int getMaximumIterations()
Returns the maximum number of iterations of the KMeans algorithm that will be performed.- Returns:
- the maximum number of iterations of the KMeans algorithm that will be performed.
-
cluster
public int[] cluster(DataSet dataSet, int[] designations)
Description copied from interface:ClustererPerforms clustering on the given data set. Parameters may be estimated by the method, or other heuristics performed.- Specified by:
clusterin interfaceClusterer- Parameters:
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.- Returns:
- an array indicating for each value indicating the cluster designation. This is the same array as designations, or a new one if the input array was null
-
cluster
public int[] cluster(DataSet dataSet, boolean parallel, int[] designations)
Description copied from interface:ClustererPerforms clustering on the given data set. Parameters may be estimated by the method, or other heuristics performed.- Specified by:
clusterin interfaceClusterer- Parameters:
dataSet- the data set to perform clustering onparallel-trueif multiple threads should be used to perform clustering.falseif it should be done in a single threaded manner.designations- 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.- Returns:
- the int[]
-
cluster
public int[] cluster(DataSet dataSet, int lowK, int highK, boolean parallel, int[] designations)
- Specified by:
clusterin interfaceKClusterer
-
cluster
public int[] cluster(DataSet dataSet, int lowK, int highK, int[] designations)
- Specified by:
clusterin interfaceKClusterer
-
distance
public double distance(Vec x, int k)
Returns the distance between the given data point and the the specified cluster- Parameters:
x- the data point to get the distance fork- the cluster id to get the distance to- Returns:
- the distance between the given data point and the specified cluster
-
distance
public double distance(Vec x, java.util.List<java.lang.Double> qi, int k)
Returns the distance between the given data point and the the specified cluster- Parameters:
x- the data point to get the distance forqi- the query information for the given data point generated for the kernel in use. SeeKernelTrick.getQueryInfo(jsat.linear.Vec)k- the cluster id to get the distance to- Returns:
- the distance between the given data point and the specified cluster
-
findClosestCluster
public int findClosestCluster(Vec x)
Finds the cluster ID that is closest to the given data point- Parameters:
x- the data point to get the closest cluster for- Returns:
- the index of the closest cluster
-
findClosestCluster
public int findClosestCluster(Vec x, java.util.List<java.lang.Double> qi)
Finds the cluster ID that is closest to the given data point- Parameters:
x- the data point to get the closest cluster forqi- the query information for the given data point generated for the kernel in use. SeeKernelTrick.getQueryInfo(jsat.linear.Vec)- Returns:
- the index of the closest cluster
-
meanToMeanDistance
public double meanToMeanDistance(int k0, int k1)Computes the distance between two of the means in the clustering- Parameters:
k0- the index of the first meank1- the index of the second mean- Returns:
- the distance between the two
-
clone
public abstract KernelKMeans clone()
- Specified by:
clonein interfaceClusterer- Specified by:
clonein interfaceKClusterer- Specified by:
clonein classKClustererBase
-
supportsWeightedData
public boolean supportsWeightedData()
Description copied from interface:ClustererIndicates whether the model knows how to cluster using weighted data points. If it does, the model will train assuming the weights. The values returned by this method may change depending on the parameters set for the model.- Specified by:
supportsWeightedDatain interfaceClusterer- Returns:
- true if the model supports weighted data, false otherwise
-
-
DataMelt 3.0 © DataMelt by jWork.ORG