jsat.clustering.dissimilarity
Class AbstractClusterDissimilarity
- java.lang.Object
-
- jsat.clustering.dissimilarity.AbstractClusterDissimilarity
-
- All Implemented Interfaces:
- ClusterDissimilarity
- Direct Known Subclasses:
- DistanceMetricDissimilarity
public abstract class AbstractClusterDissimilarity extends java.lang.Object implements ClusterDissimilarity
This base class does not currently provide any inheritable functionality, but stores static methods.
-
-
Constructor Summary
Constructors Constructor and Description AbstractClusterDissimilarity()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method and Description abstract ClusterDissimilarityclone()static double[][]createDistanceMatrix(DataSet dataSet, ClusterDissimilarity cd)Creates an upper triangular matrix containing the distance between all points in the data set.static doublegetDistance(double[][] distanceMatrix, int i, int j)A convenience method.static voidsetDistance(double[][] distanceMatrix, int i, int j, double dist)A convenience method.-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface jsat.clustering.dissimilarity.ClusterDissimilarity
dissimilarity, dissimilarity, distance
-
-
-
-
Method Detail
-
getDistance
public static double getDistance(double[][] distanceMatrix, int i, int j)A convenience method. If the distanceMatrix was created withcreateDistanceMatrix(jsat.DataSet, jsat.clustering.dissimilarity.ClusterDissimilarity), then this method will return the appropriate value for the desired index.- Parameters:
distanceMatrix- the distance matrix to query fromi- the first indexj- the second index- Returns:
- the correct value from the distance matrix from the index given as if the distance matrix was of full form
-
setDistance
public static void setDistance(double[][] distanceMatrix, int i, int j, double dist)A convenience method. If the distanceMatrix was created withcreateDistanceMatrix(jsat.DataSet, jsat.clustering.dissimilarity.ClusterDissimilarity), then this method will set the appropriate value for the desired index.- Parameters:
distanceMatrix- the distance matrix to query fromi- the first indexj- the second indexdist- the new distance value to store in the matrix
-
createDistanceMatrix
public static double[][] createDistanceMatrix(DataSet dataSet, ClusterDissimilarity cd)
Creates an upper triangular matrix containing the distance between all points in the data set. The main diagonal will contain all zeros, since the distance between a point and itself is always zero. This main diagonal is not stored, and is implicit
To save space, the matrix is staggered, and is of a size such that all elements to the left of the main diagonal are not present.
To compute the index into the returned array for the index [i][j], the values should be switched such that i ≥ j, and accessed as [i][j-i-1]- Parameters:
dataSet- the data set to create distance matrix forcd- the cluster dissimilarity measure to use- Returns:
- a upper triangular distance matrix
-
clone
public abstract ClusterDissimilarity clone()
- Specified by:
clonein interfaceClusterDissimilarity- Overrides:
clonein classjava.lang.Object
-
-
DataMelt 3.0 © DataMelt by jWork.ORG