jsat.clustering
Class MeanShift
- java.lang.Object
-
- jsat.clustering.MeanShift
-
- All Implemented Interfaces:
- java.io.Serializable, Clusterer
public class MeanShift extends java.lang.Object implements Clusterer
The MeanShift algorithms performs clustering on a data set by letting the data speak for itself and performing a mode search amongst the data set, returning a cluster for each discovered mode.
While not normally discussed in the context of Mean Shift, this implementation has rudimentary outlier-removal, outliers will not be included in the clustering.
The mean shift requires aMultivariateKDEto run. Contrary to use in density estimation, where theKernelFunctionused has only a minor impact on the results, it is highly recommended you use theGaussKFfor the MeanShift method. This is because of the large support and better behaved derivative, which adds in the avoidance of oscillating convergence.
Implementation Note: This implementation does not snap the values to a grid. This causes the prior noted oscillation in convergence.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field and Description static intDefaultMaxIterationsThe default number ofgetMaxIterations()is 1000static doubleDefaultScaleBandwidthFactorThe default value ofgetScaleBandwidthFactor()is 1.0
-
Constructor Summary
Constructors Constructor and Description MeanShift()Creates a new MeanShift clustering object using aMetricKDE, theGaussKF, and theEuclideanDistance.MeanShift(DistanceMetric dm)MeanShift(MeanShift toCopy)Copy constructorMeanShift(MultivariateKDE mkde)Creates a new MeanShift clustering object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description MeanShiftclone()int[]cluster(DataSet dataSet, boolean parallel, int[] designations)Performs clustering on the given data set.intgetMaxIterations()Returns the maximum number of iterations the algorithm will go through, terminating early if convergence has not occurred.doublegetScaleBandwidthFactor()Returns the value by which the bandwidth of theMultivariateKDEwill be scaled by.voidsetMaxIterations(int maxIterations)Sets the maximum number of iterations the algorithm will go through, terminating early if convergence has not occurred.voidsetScaleBandwidthFactor(double scaleBandwidthFactor)Sets the value by which the bandwidth of theMultivariateKDEwill be scaled by.-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface jsat.clustering.Clusterer
cluster, cluster, cluster, supportsWeightedData
-
-
-
-
Field Detail
-
DefaultMaxIterations
public static final int DefaultMaxIterations
The default number ofgetMaxIterations()is 1000- See Also:
- Constant Field Values
-
DefaultScaleBandwidthFactor
public static final double DefaultScaleBandwidthFactor
The default value ofgetScaleBandwidthFactor()is 1.0- See Also:
- Constant Field Values
-
-
Constructor Detail
-
MeanShift
public MeanShift()
Creates a new MeanShift clustering object using aMetricKDE, theGaussKF, and theEuclideanDistance.
-
MeanShift
public MeanShift(DistanceMetric dm)
- Parameters:
dm- the distance metric to use
-
MeanShift
public MeanShift(MultivariateKDE mkde)
Creates a new MeanShift clustering object.
NOTE:ProductKDEdoes not currently support the functions needed to work with MeanShift.- Parameters:
mkde- the KDE to use in the clustering process.
-
MeanShift
public MeanShift(MeanShift toCopy)
Copy constructor- Parameters:
toCopy- the object to copy
-
-
Method Detail
-
setMaxIterations
public void setMaxIterations(int maxIterations)
Sets the maximum number of iterations the algorithm will go through, terminating early if convergence has not occurred.- Parameters:
maxIterations- the maximum number of iterations- Throws:
java.lang.ArithmeticException- if a value less than 1 is given
-
getMaxIterations
public int getMaxIterations()
Returns the maximum number of iterations the algorithm will go through, terminating early if convergence has not occurred.- Returns:
- the maximum number of iterations
-
setScaleBandwidthFactor
public void setScaleBandwidthFactor(double scaleBandwidthFactor)
Sets the value by which the bandwidth of theMultivariateKDEwill be scaled by.- Parameters:
scaleBandwidthFactor- the value to scale bandwidth by- Throws:
java.lang.ArithmeticException- if the value given isNaNorinfinity
-
getScaleBandwidthFactor
public double getScaleBandwidthFactor()
Returns the value by which the bandwidth of theMultivariateKDEwill be scaled by.- Returns:
- the value to scale bandwidth by
-
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[]
-
-
DataMelt 3.0 © DataMelt by jWork.ORG