Environment for
DeveLoping
KDD-Applications
Supported by Index-Structures

de.lmu.ifi.dbs.elki.algorithm.result.clustering
Class Clusters<O extends DatabaseObject>

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.logging.AbstractLoggable
      extended by de.lmu.ifi.dbs.elki.algorithm.result.AbstractResult<O>
          extended by de.lmu.ifi.dbs.elki.algorithm.result.clustering.Clusters<O>
Type Parameters:
O - the type of DatabaseObjects handled by this Result
All Implemented Interfaces:
ClusteringResult<O>, Result<O>, Loggable
Direct Known Subclasses:
EMClusters

public class Clusters<O extends DatabaseObject>
extends AbstractResult<O>
implements ClusteringResult<O>

Provides a result of a clustering-algorithm that computes several clusters. The result is not to treat noise separately. All objects are assigned to a certain cluster.

Author:
Arthur Zimek

Field Summary
static String CLUSTER_LABEL_PREFIX
          Prefix for cluster or class labels: "C".
static String CLUSTER_MARKER
          Marker for a file name of a cluster.
protected  Integer[][] clusters
          An array of clusters, respectively, where each array provides the object ids of its members
protected  Map<Integer,Result<O>> clusterToModel
          todo comment
 
Fields inherited from class de.lmu.ifi.dbs.elki.algorithm.result.AbstractResult
db, FILE_EXTENSION
 
Fields inherited from class de.lmu.ifi.dbs.elki.logging.AbstractLoggable
debug
 
Fields inherited from interface de.lmu.ifi.dbs.elki.algorithm.result.Result
SEPARATOR
 
Constructor Summary
Clusters(Integer[][] clusters, Database<O> db)
          Provides a result of a clustering-algorithm that computes several clusters and remaining noise.
 
Method Summary
<L extends ClassLabel<L>>
void
appendModel(L clusterID, Result<O> model)
          Appends a model the designated cluster.
<L extends ClassLabel<L>>
Database<O>
associate(Class<L> classLabel)
          Returns a new Database containing only non-noise Objects with a clusterID associated as AssociationID#CLASS.
 String canonicalClusterLabel(int clusterID)
          todo comment
protected
<L extends ClassLabel<L>>
Integer
classLabelToClusterID(L classLabel)
          todo comment
<L extends ClassLabel<L>>
Map<L,Database<O>>
clustering(Class<L> classLabel)
          Returns a Map of ClassLabel to Database, comprising a separate database for each cluster.
protected  String format(int input, int maximum)
          Returns an integer-string for the given input, that has as many leading zeros as to match the length of the specified maximum.
 Cluster<O>[] getClusters()
          Returns the clusters as array of arrays of object ids.
 Integer[][] getClustersArray()
          Returns the array of clusters where each array provides the object ids of its members.
 boolean isRequiredAssociation(AssociationID<?> id)
          Decides whether a given associationID is regarded as required.
 Database<O> noise()
          Returns a database containing only noise objects.
 void output(File out, Normalization<O> normalization, List<AttributeSettings> settings)
          Writes the clustering result to the given file.
 void output(PrintStream outStream, Normalization<O> normalization, List<AttributeSettings> settings)
          Writes the clustering result to the given stream.
private  void write(int clusterIndex, PrintStream out, Normalization<O> normalization, List<AttributeSettings> settings)
          Writes a cluster denoted by its cluster number to the designated print stream.
 
Methods inherited from class de.lmu.ifi.dbs.elki.algorithm.result.AbstractResult
getDatabase, writeHeader
 
Methods inherited from class de.lmu.ifi.dbs.elki.logging.AbstractLoggable
debugFine, debugFiner, debugFinest, exception, message, progress, progress, progress, verbose, verbose, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLUSTER_MARKER

public static final String CLUSTER_MARKER
Marker for a file name of a cluster.

See Also:
Constant Field Values

CLUSTER_LABEL_PREFIX

public static final String CLUSTER_LABEL_PREFIX
Prefix for cluster or class labels: "C".

See Also:
Constant Field Values

clusterToModel

protected Map<Integer,Result<O extends DatabaseObject>> clusterToModel
todo comment


clusters

protected Integer[][] clusters
An array of clusters, respectively, where each array provides the object ids of its members

Constructor Detail

Clusters

public Clusters(Integer[][] clusters,
                Database<O> db)
Provides a result of a clustering-algorithm that computes several clusters and remaining noise.

Parameters:
clusters - an array of clusters where each array provides the object ids of its members
db - the database containing the objects of clusters
Method Detail

getClusters

public Cluster<O>[] getClusters()
Description copied from interface: ClusteringResult
Returns the clusters as array of arrays of object ids. The array must not contain noise objects.

Specified by:
getClusters in interface ClusteringResult<O extends DatabaseObject>
Returns:
the clusters as defined in this result
See Also:
ClusteringResult.getClusters()

output

public void output(File out,
                   Normalization<O> normalization,
                   List<AttributeSettings> settings)
            throws UnableToComplyException
Description copied from interface: Result
Writes the clustering result to the given file. Clustering result implementations, which are likely to provide several clusters are supposed to use the filename as prefix for every file to create and to append a proper suffix. In case of occuring IOExceptions the output is expected to be given at the standard-out. Therefore this behaviour should be also achievable by giving a null-Object as parameter.

Specified by:
output in interface Result<O extends DatabaseObject>
Overrides:
output in class AbstractResult<O extends DatabaseObject>
Parameters:
out - file, which designates the location to write the results, or which's name designates the prefix of any locations to write the results, or which could remain null to designate the standard-out as location for output.
normalization - Normalization to restore original values according to, if this action is supported - may remain null.
settings - the settings to be written into the header, if this parameter is null, no header will be written
Throws:
UnableToComplyException - if any feature vector is not compatible with values initialized during normalization
See Also:
Result.output(File,Normalization,List)

output

public void output(PrintStream outStream,
                   Normalization<O> normalization,
                   List<AttributeSettings> settings)
            throws UnableToComplyException
Description copied from interface: Result
Writes the clustering result to the given stream.

Specified by:
output in interface Result<O extends DatabaseObject>
Parameters:
outStream - the stream to write to
normalization - Normalization to restore original values according to, if this action is supported - may remain null.
settings - the settings to be written into the header, if this parameter is null, no header will be written
Throws:
UnableToComplyException - if any feature vector is not compatible with values initialized during normalization
See Also:
Result.output(java.io.PrintStream, de.lmu.ifi.dbs.elki.normalization.Normalization,java.util.List)

format

protected String format(int input,
                        int maximum)
Returns an integer-string for the given input, that has as many leading zeros as to match the length of the specified maximum.

Parameters:
input - an integer to be formatted
maximum - the maximum to adapt the format to
Returns:
an integer-string for the given input, that has as many leading zeros as to match the length of the specified maximum

write

private void write(int clusterIndex,
                   PrintStream out,
                   Normalization<O> normalization,
                   List<AttributeSettings> settings)
            throws NonNumericFeaturesException
Writes a cluster denoted by its cluster number to the designated print stream.

Parameters:
clusterIndex - the number of the cluster to be written
out - the print stream where to write
normalization - a Normalization to restore original values for output - may remain null
settings - the settings to be written into the header
Throws:
NonNumericFeaturesException - if feature vector is not compatible with values initialized during normalization

isRequiredAssociation

public boolean isRequiredAssociation(AssociationID<?> id)
Decides whether a given associationID is regarded as required.

Parameters:
id - an associationID to decide whether or not it is required
Returns:
true if the associationID is AssociationID.CLASS or AssociationID.LABEL, false otherwise

getClustersArray

public Integer[][] getClustersArray()
Returns the array of clusters where each array provides the object ids of its members.

Returns:
the array of clusters and noise

associate

public <L extends ClassLabel<L>> Database<O> associate(Class<L> classLabel)
Description copied from interface: ClusteringResult
Returns a new Database containing only non-noise Objects with a clusterID associated as AssociationID#CLASS.

Specified by:
associate in interface ClusteringResult<O extends DatabaseObject>
Parameters:
classLabel - the class to be used as ClassLabel
Returns:
a new Database of only non-noise objects
See Also:
ClusteringResult.associate(Class)

clustering

public <L extends ClassLabel<L>> Map<L,Database<O>> clustering(Class<L> classLabel)
Description copied from interface: ClusteringResult
Returns a Map of ClassLabel to Database, comprising a separate database for each cluster. Note that if the clustering result contains noise, the noise-objects are not comprised in this map.

Specified by:
clustering in interface ClusteringResult<O extends DatabaseObject>
Parameters:
classLabel - the class to be used as ClassLabel
Returns:
Map of ClassLabel to Database, comprising a separate database for each cluster without noise.
See Also:
ClusteringResult.clustering(Class)

appendModel

public <L extends ClassLabel<L>> void appendModel(L clusterID,
                                                  Result<O> model)
Description copied from interface: ClusteringResult
Appends a model the designated cluster.

Specified by:
appendModel in interface ClusteringResult<O extends DatabaseObject>
Parameters:
clusterID - ClassLabel assigned to the cluster a model should be appended to
model - the model describing the designated cluster
See Also:
ClusteringResult.appendModel(ClassLabel, de.lmu.ifi.dbs.elki.algorithm.result.Result)

noise

public Database<O> noise()
Description copied from interface: ClusteringResult
Returns a database containing only noise objects.

Specified by:
noise in interface ClusteringResult<O extends DatabaseObject>
Returns:
a database containing only noise objects
See Also:
ClusteringResult.noise()

classLabelToClusterID

protected <L extends ClassLabel<L>> Integer classLabelToClusterID(L classLabel)
todo comment


canonicalClusterLabel

public String canonicalClusterLabel(int clusterID)
todo comment


Release 0.1 (2008-07-10_1838)