Package cc.mallet.cluster.util
Class ClusterUtils
- java.lang.Object
-
- 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
Constructors Constructor Description ClusterUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description 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)
-
-
-
Method Detail
-
combineLists
public static InstanceList combineLists(InstanceList li, InstanceList lj)
- Parameters:
li
-lj
-- Returns:
- A new
InstanceList
wherelj
is appended toli
.
-
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 argumentInstance
s.
-
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 labelsi
andj
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 whichInstance
si
andj
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 specifiedInstance
s have been merged together into one cluster.
-
-