com.sun.labs.minion.classification
Class FeatureClusterSet

java.lang.Object
  extended by com.sun.labs.minion.classification.FeatureClusterSet
All Implemented Interfaces:
java.lang.Iterable<FeatureCluster>

public class FeatureClusterSet
extends java.lang.Object
implements java.lang.Iterable<FeatureCluster>

A set of feature clusters. The set is sorted based on cluster name.


Field Summary
protected  java.util.SortedSet<FeatureCluster> contents
           
protected  HumanSelected hs
           
protected  java.util.Map<java.lang.String,FeatureCluster> quickMap
           
 
Constructor Summary
FeatureClusterSet()
           
FeatureClusterSet(java.util.Collection<FeatureCluster> clusters)
          Creates a FeatureClusterSet from the contents of a Collection.
FeatureClusterSet(FeatureClusterSet other)
          Create a copy of the provided FeatureClusterSet
 
Method Summary
 void add(FeatureCluster cluster)
          Adds a feature cluster to this set.
 FeatureCluster get(java.lang.String name)
          Gets the feature cluster with the given name.
 FeatureCluster getContaining(Feature feature)
          Gets the feature cluster that contains the given feature.
 FeatureCluster getContaining(java.lang.String name)
          Gets the feature cluster that contains the given feature.
 java.util.SortedSet<FeatureCluster> getContents()
          Gets the contents of this cluster as a SortedSet
 java.util.Iterator<FeatureCluster> iterator()
          Gets an iterator over the cluster set.
static FeatureClusterSet merge(java.util.Collection<FeatureClusterSet> clusterSets)
          Merge the contents of all the cluster sets.
 void normalize()
          Normalizes the weights of the feature clusters so that the overall set has a unit length.
 void removeZero()
          Removes feature clusters with zero weight from the set.
 void setHumanSelected(HumanSelected hs)
           
 int size()
          Gets the number of clusters in this cluster set
 FeatureClusterSet subsetFirstN(int n)
          Gets a subset of this feature cluster set consisting of the first N features in the set.
 FeatureCluster[] toArray()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

hs

protected HumanSelected hs

contents

protected java.util.SortedSet<FeatureCluster> contents

quickMap

protected java.util.Map<java.lang.String,FeatureCluster> quickMap
Constructor Detail

FeatureClusterSet

public FeatureClusterSet()

FeatureClusterSet

public FeatureClusterSet(java.util.Collection<FeatureCluster> clusters)
Creates a FeatureClusterSet from the contents of a Collection. An exception is thrown if any member of clusters is not a FeatureCluster.

Parameters:
clusters - a collection of FeatureClusters

FeatureClusterSet

public FeatureClusterSet(FeatureClusterSet other)
Create a copy of the provided FeatureClusterSet

Parameters:
other - the set to copy
Method Detail

setHumanSelected

public void setHumanSelected(HumanSelected hs)

get

public FeatureCluster get(java.lang.String name)
Gets the feature cluster with the given name.

Parameters:
name - the name of the cluster to get
Returns:
the cluster, or null if no such cluster is in the set

getContaining

public FeatureCluster getContaining(Feature feature)
Gets the feature cluster that contains the given feature.

Parameters:
feature - the feature to find in a cluster
Returns:
the cluster containing f or null if no cluster contains f

getContaining

public FeatureCluster getContaining(java.lang.String name)
Gets the feature cluster that contains the given feature.

Parameters:
name - the name of the feature to find in a cluster
Returns:
the cluster containing f or null if no cluster contains f

merge

public static FeatureClusterSet merge(java.util.Collection<FeatureClusterSet> clusterSets)
Merge the contents of all the cluster sets. Clusters with the same name are merged.

Parameters:
clusterSets - other the other FCS

add

public void add(FeatureCluster cluster)
Adds a feature cluster to this set.

Parameters:
cluster - the cluster to add

removeZero

public void removeZero()
Removes feature clusters with zero weight from the set.


normalize

public void normalize()
Normalizes the weights of the feature clusters so that the overall set has a unit length.


iterator

public java.util.Iterator<FeatureCluster> iterator()
Gets an iterator over the cluster set.

Specified by:
iterator in interface java.lang.Iterable<FeatureCluster>
Returns:
an iterator over FeatureCluster

size

public int size()
Gets the number of clusters in this cluster set

Returns:
the size of the cluster set

getContents

public java.util.SortedSet<FeatureCluster> getContents()
Gets the contents of this cluster as a SortedSet

Returns:
the FeatureClusters in this set

toArray

public FeatureCluster[] toArray()

subsetFirstN

public FeatureClusterSet subsetFirstN(int n)
Gets a subset of this feature cluster set consisting of the first N features in the set. If this is a set that just came out of feature selection, then this is the top weighted clusters. If this is a set straight from clustering, it is alphabetical.

Parameters:
n - the number of features to use in the set

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object