Package cc.mallet.cluster
Class GreedyAgglomerative
- java.lang.Object
-
- cc.mallet.cluster.Clusterer
-
- cc.mallet.cluster.KBestClusterer
-
- cc.mallet.cluster.HillClimbingClusterer
-
- cc.mallet.cluster.GreedyAgglomerative
-
- All Implemented Interfaces:
java.io.Serializable
- Direct Known Subclasses:
GreedyAgglomerativeByDensity
public class GreedyAgglomerative extends HillClimbingClusterer
Greedily merges Instances until convergence. New merges are scored usingNeighborEvaluator
.- Since:
- 1.0
- Version:
- 1.0
- Author:
- "Aron Culotta"
- See Also:
HillClimbingClusterer
, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
converged
True if should stop clustering.protected PairwiseMatrix
scoreCache
Cache for calls toNeighborhoodEvaluator
.protected double
stoppingThreshold
Converged when merge score is below this value.-
Fields inherited from class cc.mallet.cluster.HillClimbingClusterer
evaluator
-
-
Constructor Summary
Constructors Constructor Description GreedyAgglomerative(Pipe instancePipe, NeighborEvaluator evaluator, double stoppingThreshold)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
converged(Clustering clustering)
protected double
getScore(Clustering clustering, int i, int j)
Clustering
improveClustering(Clustering clustering)
For each pair of clusters, calculate the score of theNeighbor
that would result from merging the two clusters.Clustering
initializeClustering(InstanceList instances)
void
reset()
Reset convergence to false so a new round of clustering can begin.java.lang.String
toString()
protected void
updateScoreMatrix(Clustering clustering, int i, int j)
Resets the values of clusters that have been merged.-
Methods inherited from class cc.mallet.cluster.HillClimbingClusterer
cluster, cluster, clusterKBest, clusterKBest, getEvaluator
-
-
-
-
Field Detail
-
stoppingThreshold
protected double stoppingThreshold
Converged when merge score is below this value.
-
converged
protected boolean converged
True if should stop clustering.
-
scoreCache
protected PairwiseMatrix scoreCache
Cache for calls toNeighborhoodEvaluator
. In some experiments, reduced running time by nearly half.
-
-
Constructor Detail
-
GreedyAgglomerative
public GreedyAgglomerative(Pipe instancePipe, NeighborEvaluator evaluator, double stoppingThreshold)
- Parameters:
instancePipe
- Pipe for each underyingInstance
.evaluator
- To score potential merges.stoppingThreshold
- Clustering converges when the evaluator score is below this value.
-
-
Method Detail
-
initializeClustering
public Clustering initializeClustering(InstanceList instances)
- Specified by:
initializeClustering
in classHillClimbingClusterer
- Parameters:
instances
-- Returns:
- A singleton clustering (each Instance in its own cluster).
-
converged
public boolean converged(Clustering clustering)
- Specified by:
converged
in classHillClimbingClusterer
- Returns:
- True if clustering is complete.
-
reset
public void reset()
Reset convergence to false so a new round of clustering can begin.- Specified by:
reset
in classHillClimbingClusterer
-
improveClustering
public Clustering improveClustering(Clustering clustering)
For each pair of clusters, calculate the score of theNeighbor
that would result from merging the two clusters. Choose the merge that obtains the highest score. If no merge improves score, return original Clustering- Specified by:
improveClustering
in classHillClimbingClusterer
- Parameters:
clustering
-- Returns:
-
getScore
protected double getScore(Clustering clustering, int i, int j)
- Parameters:
clustering
-i
-j
-- Returns:
- The score for merging these two clusters.
-
updateScoreMatrix
protected void updateScoreMatrix(Clustering clustering, int i, int j)
Resets the values of clusters that have been merged.- Parameters:
clustering
-i
-j
-
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-