jsat.clustering
Class PAM
- java.lang.Object
-
- jsat.clustering.PAM
-
- All Implemented Interfaces:
- java.io.Serializable, Clusterer, KClusterer
public class PAM extends java.lang.Object implements KClusterer
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description PAM()PAM(DistanceMetric dm)PAM(DistanceMetric dm, java.util.Random rand)PAM(DistanceMetric dm, java.util.Random rand, SeedSelectionMethods.SeedSelection seedSelection)PAM(PAM toCopy)Copy constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description PAMclone()int[]cluster(DataSet dataSet, boolean parallel, int[] designations)Performs clustering on the given data set.int[]cluster(DataSet dataSet, int clusters, boolean parallel, int[] designations)int[]cluster(DataSet dataSet, int lowK, int highK, boolean parallel, int[] designations)DistanceMetricgetDistanceMetric()intgetMaxIterations()int[]getMedoids()Returns the raw array of indices that indicate which data point acted as the center for each cluster.SeedSelectionMethods.SeedSelectiongetSeedSelection()static intmedoid(boolean parallel, java.util.Collection<java.lang.Integer> indecies, java.util.List<? extends Vec> X, DistanceMetric dm, java.util.List<java.lang.Double> accel)Computes the medoid of a sub-set of datastatic intmedoid(boolean parallel, java.util.List<? extends Vec> X, DistanceMetric dm)Computes the medoid of the datavoidsetDistanceMetric(DistanceMetric dm)Sets the distance metric used by this clustering algorithmvoidsetMaxIterations(int iterLimit)voidsetSeedSelection(SeedSelectionMethods.SeedSelection seedSelection)Sets the method of seed selection used by this algorithmvoidsetStoreMedoids(boolean storeMedoids)If set totruethe computed medoids will be stored after clustering is completed, and can then be retrieved usinggetMedoids().-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface jsat.clustering.KClusterer
cluster, cluster, cluster, cluster, cluster, cluster
-
Methods inherited from interface jsat.clustering.Clusterer
cluster, cluster, cluster, supportsWeightedData
-
-
-
-
Constructor Detail
-
PAM
public PAM(DistanceMetric dm, java.util.Random rand, SeedSelectionMethods.SeedSelection seedSelection)
-
PAM
public PAM(DistanceMetric dm, java.util.Random rand)
-
PAM
public PAM(DistanceMetric dm)
-
PAM
public PAM()
-
PAM
public PAM(PAM toCopy)
Copy constructor- Parameters:
toCopy- the object to copy
-
-
Method Detail
-
setMaxIterations
public void setMaxIterations(int iterLimit)
- Parameters:
iterLimit- the maximum number of iterations of the algorithm to perform
-
getMaxIterations
public int getMaxIterations()
- Returns:
- the maximum number of iterations of the algorithm to perform
-
setDistanceMetric
public void setDistanceMetric(DistanceMetric dm)
Sets the distance metric used by this clustering algorithm- Parameters:
dm- the distance metric to use
-
getDistanceMetric
public DistanceMetric getDistanceMetric()
- Returns:
- the distance metric to be used by this algorithm
-
setStoreMedoids
public void setStoreMedoids(boolean storeMedoids)
If set totruethe computed medoids will be stored after clustering is completed, and can then be retrieved usinggetMedoids().- Parameters:
storeMedoids-trueif the medoids should be stored for later,falseto discard them once clustering is complete.
-
getMedoids
public int[] getMedoids()
Returns the raw array of indices that indicate which data point acted as the center for each cluster.- Returns:
- the array of medeoid indices
-
setSeedSelection
public void setSeedSelection(SeedSelectionMethods.SeedSelection seedSelection)
Sets the method of seed selection used by this algorithm- Parameters:
seedSelection- the method of seed selection to used
-
getSeedSelection
public SeedSelectionMethods.SeedSelection getSeedSelection()
- Returns:
- the method of seed selection used by this algorithm
-
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 clusters, boolean parallel, int[] designations)
- Specified by:
clusterin interfaceKClusterer
-
clone
public PAM clone()
- Specified by:
clonein interfaceClusterer- Specified by:
clonein interfaceKClusterer- Overrides:
clonein classjava.lang.Object
-
cluster
public int[] cluster(DataSet dataSet, int lowK, int highK, boolean parallel, int[] designations)
- Specified by:
clusterin interfaceKClusterer
-
medoid
public static int medoid(boolean parallel, java.util.List<? extends Vec> X, DistanceMetric dm)Computes the medoid of the data- Parameters:
parallel- whether or not the computation should be done using multiple coresX- the list of all datadm- the distance metric to get the medoid with respect to- Returns:
- the index of the point in X that is the medoid
-
medoid
public static int medoid(boolean parallel, java.util.Collection<java.lang.Integer> indecies, java.util.List<? extends Vec> X, DistanceMetric dm, java.util.List<java.lang.Double> accel)Computes the medoid of a sub-set of data- Parameters:
parallel- whether or not the computation should be done using multiple coresindecies- the indexes of the points to get the medoid ofX- the list of all datadm- the distance metric to get the medoid with respect toaccel- the acceleration cache for the distance metric- Returns:
- the index value contained within indecies that is the medoid
-
-
DataMelt 3.0 © DataMelt by jWork.ORG