cc.mallet.cluster.util
Class ClusterUtils

java.lang.Object
  extended by cc.mallet.cluster.util.ClusterUtils

public class ClusterUtils
extends java.lang.Object

Utility functions for Clusterings.

Since:
1.0
Version:
1.0
Author:
"Aron Culotta"
See Also:
Clustering

Constructor Summary
ClusterUtils()
           
 
Method Summary
static InstanceList combineLists(InstanceList li, InstanceList lj)
           
static Clustering copyAndMergeClusters(Clustering clustering, int i, int j)
           
static Clustering copyAndMergeInstances(Clustering clustering, int[] instances)
           
static Clustering copyAndMergeInstances(Clustering clustering, int i, int j)
           
static Clustering copyWithNewLabels(Clustering clustering)
           
static Clustering createRandomClustering(InstanceList instances, Randoms random)
           
static Clustering createSingletonClustering(InstanceList instances)
          Initializes Clustering to one Instance per cluster.
static int[] getCombinedInstances(Clustering clustering, int i, int j)
           
static InstanceList makeList(Instance i, Instance j)
           
static Clustering mergeClusters(Clustering clustering, int labeli, int labelj)
          Relabels the clustering to reflect merging clusters i and j.
static Clustering mergeInstances(Clustering clustering, int[] instances)
          Merge clusters containing the specified instances.
static Clustering mergeInstances(Clustering clustering, int i, int j)
           
static Clustering mergeInstancesWithSameLabel(Clustering clustering)
           
static Clustering shatterInstances(Clustering clustering, int[] indices)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClusterUtils

public ClusterUtils()
Method Detail

combineLists

public static InstanceList combineLists(InstanceList li,
                                        InstanceList lj)
Parameters:
li -
lj -
Returns:
A new InstanceList where lj is appended to li.

mergeClusters

public static Clustering mergeClusters(Clustering clustering,
                                       int labeli,
                                       int labelj)
Relabels the clustering to reflect merging clusters i and j. Relabels all of Instances with label j to label i.

Parameters:
clustering -
i -
j -
Returns:
Modified Clustering.

mergeInstances

public static Clustering mergeInstances(Clustering clustering,
                                        int[] instances)
Merge clusters containing the specified instances.

Parameters:
clustering -
instances -
Returns:
Modified Clustering.

getCombinedInstances

public static int[] getCombinedInstances(Clustering clustering,
                                         int i,
                                         int j)

mergeInstances

public static Clustering mergeInstances(Clustering clustering,
                                        int i,
                                        int j)

createSingletonClustering

public static Clustering createSingletonClustering(InstanceList instances)
Initializes Clustering to one Instance per cluster.

Parameters:
instances -
Returns:
Singleton Clustering.

createRandomClustering

public static Clustering createRandomClustering(InstanceList instances,
                                                Randoms random)

shatterInstances

public static Clustering shatterInstances(Clustering clustering,
                                          int[] indices)
Parameters:
clustering -
indices -
Returns:
A Clustering where no Instances in indices are in the same cluster.

makeList

public static InstanceList makeList(Instance i,
                                    Instance j)
Parameters:
i -
j -
Returns:
A new InstanceList containing the two argument Instances.

copyWithNewLabels

public static Clustering copyWithNewLabels(Clustering clustering)
Parameters:
clustering -
Returns:
A shallow copy of the argument where new objects are only allocated for the cluster assignment.

mergeInstancesWithSameLabel

public static Clustering mergeInstancesWithSameLabel(Clustering clustering)

copyAndMergeClusters

public static Clustering copyAndMergeClusters(Clustering clustering,
                                              int i,
                                              int j)
Parameters:
clustering -
i -
j -
Returns:
A new copy of clustering in which clusters with labels i and j have been merged.

copyAndMergeInstances

public static Clustering copyAndMergeInstances(Clustering clustering,
                                               int i,
                                               int j)
Parameters:
clustering -
i -
j -
Returns:
A new copy of clustering in which Instances i and j have been put in the same cluster.

copyAndMergeInstances

public static Clustering copyAndMergeInstances(Clustering clustering,
                                               int[] instances)
Parameters:
clustering -
instances -
Returns:
A new copy of clustering in which the clusters containing the specified Instances have been merged together into one cluster.