jsat.clustering.dissimilarity
Class LanceWilliamsDissimilarity
- java.lang.Object
-
- jsat.clustering.dissimilarity.AbstractClusterDissimilarity
-
- jsat.clustering.dissimilarity.DistanceMetricDissimilarity
-
- jsat.clustering.dissimilarity.LanceWilliamsDissimilarity
-
- All Implemented Interfaces:
- ClusterDissimilarity, UpdatableClusterDissimilarity
- Direct Known Subclasses:
- AverageLinkDissimilarity, CentroidDissimilarity, CompleteLinkDissimilarity, MedianDissimilarity, SingleLinkDissimilarity, WardsDissimilarity
public abstract class LanceWilliamsDissimilarity extends DistanceMetricDissimilarity implements UpdatableClusterDissimilarity
This class provides a base implementation of a Lance Williams (LW) Dissimilarity measure, which is updatable. All LW measures can be written in the form
αi dik + αj djk + β dij + γ |dik - djk|
The d's represent the distances between points, and the variables:
- α
- β
- γ
NOTE: LW is meant for algorithms that perform updates to a distance matrix. While thedissimilarity(java.util.List, java.util.List)anddissimilarity(java.util.Set, java.util.Set, double[][])methods will work and produce the correct results, their performance will likely be less than desired had they be computed directly.
-
-
Constructor Summary
Constructors Constructor and Description LanceWilliamsDissimilarity(DistanceMetric dm)Creates a new LW dissimilarity measure using the given metric as the base distance between individual points.LanceWilliamsDissimilarity(LanceWilliamsDissimilarity toCopy)Copy constructor
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method and Description abstract LanceWilliamsDissimilarityclone()doubledissimilarity(int ni, int nj, int nk, double d_ij, double d_ik, double d_jk)Provides the notion of dissimilarity between two sets of points, that may not have the same number of points.doubledissimilarity(int i, int ni, int j, int nj, double[][] distanceMatrix)Provides the notion of dissimilarity between two sets of points, that may not have the same number of points.doubledissimilarity(int i, int ni, int j, int nj, int k, int nk, double[][] distanceMatrix)Provides the notion of dissimilarity between two sets of points, that may not have the same number of points.doubledissimilarity(java.util.List<DataPoint> a, java.util.List<DataPoint> b)Provides the notion of dissimilarity between two sets of points, that may not have the same number of points.doubledissimilarity(java.util.Set<java.lang.Integer> a, java.util.Set<java.lang.Integer> b, double[][] distanceMatrix)Provides the notion of dissimilarity between two sets of points, that may not have the same number of points.-
Methods inherited from class jsat.clustering.dissimilarity.DistanceMetricDissimilarity
distance
-
Methods inherited from class jsat.clustering.dissimilarity.AbstractClusterDissimilarity
createDistanceMatrix, getDistance, setDistance
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface jsat.clustering.dissimilarity.ClusterDissimilarity
distance
-
-
-
-
Constructor Detail
-
LanceWilliamsDissimilarity
public LanceWilliamsDissimilarity(DistanceMetric dm)
Creates a new LW dissimilarity measure using the given metric as the base distance between individual points.- Parameters:
dm- the base metric to measure dissimilarity from.
-
LanceWilliamsDissimilarity
public LanceWilliamsDissimilarity(LanceWilliamsDissimilarity toCopy)
Copy constructor- Parameters:
toCopy- the object to copy
-
-
Method Detail
-
dissimilarity
public double dissimilarity(java.util.List<DataPoint> a, java.util.List<DataPoint> b)
Description copied from interface:ClusterDissimilarityProvides the notion of dissimilarity between two sets of points, that may not have the same number of points.- Specified by:
dissimilarityin interfaceClusterDissimilarity- Parameters:
a- the first cluster of pointsb- the second cluster of points- Returns:
- a value >= 0 that describes the dissimilarity of the two clusters. The larger the value, the more different the two clusterings are.
-
dissimilarity
public double dissimilarity(java.util.Set<java.lang.Integer> a, java.util.Set<java.lang.Integer> b, double[][] distanceMatrix)Description copied from interface:ClusterDissimilarityProvides the notion of dissimilarity between two sets of points, that may not have the same number of points. This is done using a matrix containing all pairwise distance computations between all points.- Specified by:
dissimilarityin interfaceClusterDissimilarity- Parameters:
a- the first set of indices of the original data set that are in a cluster, which map to distanceMatrixb- the second set of indices of the original data set that are in a cluster, which map to distanceMatrixdistanceMatrix- the upper triangual distance matrix as created byAbstractClusterDissimilarity.createDistanceMatrix(jsat.DataSet, jsat.clustering.dissimilarity.ClusterDissimilarity)- Returns:
- a value >= 0 that describes the dissimilarity of the two clusters. The larger the value, the more different the two clusterings are.
-
dissimilarity
public double dissimilarity(int i, int ni, int j, int nj, double[][] distanceMatrix)Description copied from interface:UpdatableClusterDissimilarityProvides the notion of dissimilarity between two sets of points, that may not have the same number of points. This is done using a matrix containing all pairwise distance computations between all points. This distance matrix will then be updated at each iteration and merging, leaving empty space in the matrix. The updates will be done by the clustering algorithm. Implementing this interface indicates that this dissimilarity measure can be accurately computed in an updatable manner that is compatible with a Lance–Williams update.- Specified by:
dissimilarityin interfaceUpdatableClusterDissimilarity- Parameters:
i- the index of cluster i's distance in the original data setni- the number of items in the cluster represented by ij- the index of cluster j's distance in the original data setnj- the number of items in the cluster represented by jdistanceMatrix- a distance matrix originally created byAbstractClusterDissimilarity.createDistanceMatrix(jsat.DataSet, jsat.clustering.dissimilarity.ClusterDissimilarity)- Returns:
- a value >= 0 that describes the dissimilarity of the two clusters. The larger the value, the more different the two clusterings are.
-
dissimilarity
public double dissimilarity(int i, int ni, int j, int nj, int k, int nk, double[][] distanceMatrix)Description copied from interface:UpdatableClusterDissimilarityProvides the notion of dissimilarity between two sets of points, that may not have the same number of points. This is done using a matrix containing all pairwise distance computations between all points. This distance matrix will then be updated at each iteration and merging, leaving empty space in the matrix. The updates will be done by the clustering algorithm. Implementing this interface indicates that this dissimilarity measure can be accurately computed in an updatable manner that is compatible with a Lance–Williams update.
This computes the dissimilarity of the union of clusters i and j, (Ci ∪ Cj), with the cluster k. This method is used by other algorithms to perform an update of the distance matrix in an efficient manner.- Specified by:
dissimilarityin interfaceUpdatableClusterDissimilarity- Parameters:
i- the index of cluster i's distance in the original data setni- the number of items in the cluster represented by ij- the index of cluster j's distance in the original data setnj- the number of items in the cluster represented by jk- the index of cluster k's distance in the original data setnk- the number of items in the cluster represented by k a distance matrix originally created byAbstractClusterDissimilarity.createDistanceMatrix(jsat.DataSet, jsat.clustering.dissimilarity.ClusterDissimilarity)- Returns:
- a value >= 0 that describes the dissimilarity of the union of two clusters with a third cluster. The larger the value, the more different the resulting clusterings are.
-
dissimilarity
public double dissimilarity(int ni, int nj, int nk, double d_ij, double d_ik, double d_jk)Provides the notion of dissimilarity between two sets of points, that may not have the same number of points. This is done using a matrix containing all pairwise distance computations between all points. This distance matrix will then be updated at each iteration and merging, leaving empty space in the matrix. The updates will be done by the clustering algorithm. Implementing this interface indicates that this dissimilarity measure can be accurately computed in an updatable manner that is compatible with a Lance–Williams update.
This computes the dissimilarity of the union of clusters i and j, (Ci ∪ Cj), with the cluster k. This method is used by other algorithms to perform an update of the distance matrix in an efficient manner.- Parameters:
ni- the number of items in the cluster represented by inj- the number of items in the cluster represented by jnk- the number of items in the cluster represented by kd_ij- the distance between clusters i and jd_ik- the distance between clusters i and kd_jk- the distance between clusters j and k- Returns:
- the distance between the cluster formed from i and j, to the cluster k
-
clone
public abstract LanceWilliamsDissimilarity clone()
- Specified by:
clonein interfaceClusterDissimilarity- Specified by:
clonein interfaceUpdatableClusterDissimilarity- Specified by:
clonein classDistanceMetricDissimilarity
-
-
DataMelt 3.0 © DataMelt by jWork.ORG