Environment for
DeveLoping
KDD-Applications
Supported by Index-Structures

de.lmu.ifi.dbs.elki.algorithm.result.clustering
Class ClustersPlusNoise<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.ClustersPlusNoise<O>
Type Parameters:
O - the type of DatabaseObjects handled by this Result
All Implemented Interfaces:
ClusteringResult<O>, Result<O>, Loggable
Direct Known Subclasses:
ClustersPlusNoisePlusCorrelationAnalysis

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

Provides a result of a clustering-algorithm that computes several clusters and remaining noise.

Author:
Arthur Zimek

Field Summary
static String CLUSTER_LABEL_PREFIX
          todo comment
static String CLUSTER_MARKER
          Marker for a file name of a cluster.
(package private)  Integer[][] clustersAndNoise
          An array of clusters and noise, respectively, where each array provides the object ids of its members.
protected  Map<Integer,Result<O>> clusterToModel
          todo comment
static String NOISE_MARKER
          Marker for a file name of noise.
 
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
ClustersPlusNoise(Integer[][] clustersAndNoise, 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.
protected  String canonicalClusterLabel(int clusterID)
          todo coment
protected
<L extends ClassLabel<L>>
Integer
classLabelToClusterID(L classLabel)
          todo coment
<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.
 Integer[][] getClusterAndNoiseArray()
          Returns the array of clusters and noise, respectively, where each array provides the object ids of its members.
 Cluster<O>[] getClusters()
          Returns the clusters as array of arrays of object ids.
 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

NOISE_MARKER

public static final String NOISE_MARKER
Marker for a file name of noise.

See Also:
Constant Field Values

CLUSTER_LABEL_PREFIX

public static final String CLUSTER_LABEL_PREFIX
todo comment

See Also:
Constant Field Values

clusterToModel

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


clustersAndNoise

Integer[][] clustersAndNoise
An array of clusters and noise, respectively, where each array provides the object ids of its members. The array at the last position comprises the ids of noise objects.

Constructor Detail

ClustersPlusNoise

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

Parameters:
clustersAndNoise - an array of clusters and noise, respectively, where each array provides the object ids of its members, the last element in the array contains the noise ids
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)

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

getClusterAndNoiseArray

public Integer[][] getClusterAndNoiseArray()
Returns the array of clusters and noise, respectively, 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)

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()

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)

classLabelToClusterID

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


canonicalClusterLabel

protected String canonicalClusterLabel(int clusterID)
todo coment


Release 0.1 (2008-07-10_1838)