Package elki.clustering.hierarchical
Class HACAM.Instance
- java.lang.Object
-
- elki.clustering.hierarchical.AGNES.Instance
-
- elki.clustering.hierarchical.Anderberg.Instance
-
- elki.clustering.hierarchical.HACAM.Instance
-
public static class HACAM.Instance extends Anderberg.Instance
Main worker instance of AGNES.- Author:
- Erich Schubert
-
-
Field Summary
Fields Modifier and Type Field Description protected it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap<ModifiableDBIDs>
clusters
Cluster to members mapprotected DistanceQuery<?>
dq
Distance queryprotected DBIDArrayIter
ix
Iterators into the object ids.protected DBIDArrayIter
iy
Iterators into the object ids.protected DBIDArrayMIter
prots
Iterator into the prototypesprotected double[]
tds
Total deviations (for minimum sum increase only)protected HACAM.Variant
variant
Linkage variant to use-
Fields inherited from class elki.clustering.hierarchical.Anderberg.Instance
bestd, besti
-
Fields inherited from class elki.clustering.hierarchical.AGNES.Instance
builder, end, linkage, mat
-
-
Constructor Summary
Constructors Constructor Description Instance(HACAM.Variant variant)
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static double
distanceSum(DistanceQuery<?> dq, DBIDIter i, DBIDs cy, double distsum, double minDistSum)
Find the maximum distance of one object to a set.protected int
findMerge()
Perform the next merge step.private static double
findPrototype(DistanceQuery<?> dq, DBIDs cx, DBIDs cy, DBIDVar prototype, double minDistSum)
Find the prototypes.private static double
findPrototypeSingleton(DistanceQuery<?> dq, DBIDs cx, DBIDRef cy, DBIDVar prototype)
Find the prototypes.protected void
merge(int x, int y)
Execute the cluster merge.ClusterMergeHistory
run(ClusterDistanceMatrix mat, ClusterMergeHistoryBuilder builder)
Run the main algorithm.ClusterPrototypeMergeHistory
run(ArrayDBIDs ids, ClusterDistanceMatrix mat, ClusterMergeHistoryBuilder builder, DistanceQuery<?> dq, DBIDArrayMIter prots)
Run HACAM linkageprotected void
updateEntry(int x, int y)
Update entry at x,y for distance matrix distancesprivate void
updateMatrices(int x, int y)
Update the entries of the matrices that contain a distance to y, the newly merged cluster.-
Methods inherited from class elki.clustering.hierarchical.Anderberg.Instance
findBest, initializeNNCache, merge, updateCache, updateMatrix
-
Methods inherited from class elki.clustering.hierarchical.AGNES.Instance
shrinkActiveSet
-
-
-
-
Field Detail
-
variant
protected HACAM.Variant variant
Linkage variant to use
-
clusters
protected it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap<ModifiableDBIDs> clusters
Cluster to members map
-
tds
protected double[] tds
Total deviations (for minimum sum increase only)
-
dq
protected DistanceQuery<?> dq
Distance query
-
prots
protected DBIDArrayMIter prots
Iterator into the prototypes
-
ix
protected DBIDArrayIter ix
Iterators into the object ids.
-
iy
protected DBIDArrayIter iy
Iterators into the object ids.
-
-
Constructor Detail
-
Instance
public Instance(HACAM.Variant variant)
Constructor.- Parameters:
variant
- HACAM variant to use
-
-
Method Detail
-
run
public ClusterMergeHistory run(ClusterDistanceMatrix mat, ClusterMergeHistoryBuilder builder)
Description copied from class:AGNES.Instance
Run the main algorithm.- Overrides:
run
in classAnderberg.Instance
- Parameters:
mat
- Distance matrixbuilder
- Result builder- Returns:
- Cluster history
-
run
public ClusterPrototypeMergeHistory run(ArrayDBIDs ids, ClusterDistanceMatrix mat, ClusterMergeHistoryBuilder builder, DistanceQuery<?> dq, DBIDArrayMIter prots)
Run HACAM linkage- Parameters:
ids
- Object idsmat
- Distance matrixbuilder
- Result builderdq
- Distance queryprots
- Iterator into prototypes- Returns:
- Cluster merge history
-
findMerge
protected int findMerge()
Description copied from class:Anderberg.Instance
Perform the next merge step.Due to the cache, this is now O(n) each time, instead of O(n*n).
- Overrides:
findMerge
in classAnderberg.Instance
- Returns:
- x, for shrinking the working set.
-
merge
protected void merge(int x, int y)
Execute the cluster merge.- Parameters:
x
- first cluster to merge, withx > y
y
- second cluster to merge, withy < x
-
updateMatrices
private void updateMatrices(int x, int y)
Update the entries of the matrices that contain a distance to y, the newly merged cluster.- Parameters:
x
- first cluster to merge, withx > y
y
- second cluster to merge, withy < x
-
updateEntry
protected void updateEntry(int x, int y)
Update entry at x,y for distance matrix distances- Parameters:
x
- index of cluster,x > y
y
- index of cluster,y < x
-
findPrototype
private static double findPrototype(DistanceQuery<?> dq, DBIDs cx, DBIDs cy, DBIDVar prototype, double minDistSum)
Find the prototypes.- Parameters:
dq
- Distance querycx
- First setcy
- Second setprototype
- Prototype output variableminDistSum
- Previously best distance.- Returns:
- New best distance
-
findPrototypeSingleton
private static double findPrototypeSingleton(DistanceQuery<?> dq, DBIDs cx, DBIDRef cy, DBIDVar prototype)
Find the prototypes.- Parameters:
dq
- Distance querycx
- First setcy
- Singleton objectprototype
- Prototype output variable- Returns:
- New best distance
-
distanceSum
private static double distanceSum(DistanceQuery<?> dq, DBIDIter i, DBIDs cy, double distsum, double minDistSum)
Find the maximum distance of one object to a set.- Parameters:
dq
- Distance queryi
- Current objectcy
- Set of candidatesdistsum
- Current summinDistSum
- Early stopping threshold- Returns:
- Distance sum
-
-