Environment for
DeveLoping
KDD-Applications
Supported by Index-Structures

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

public class PartitionClusteringResults<O extends DatabaseObject>
extends PartitionResults<O>
implements ClusteringResult<O>

A result for a partitioning clustering algorithm providing a single result for a single partition.

Author:
Arthur Zimek

Field Summary
private  Integer noise
          A partitionID that contains per definition noise - may remain null.
private  Map<Integer,ClusteringResult<O>> partitionResults
          Holds the results for the partitions.
 
Fields inherited from class de.lmu.ifi.dbs.elki.algorithm.result.PartitionResults
PARTITION_LABEL_PREFIX, PARTITION_MARKER
 
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
PartitionClusteringResults(Database<O> db, Map<Integer,ClusteringResult<O>> resultMap, Integer noise)
          A result for a partitioning algorithm providing a single result for a single partition.
 
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 database containing only non-noise objects.
<L extends ClassLabel<L>>
Map<L,Database<O>>
clustering(Class<L> classLabel)
          Returns a mapping to databases containing only non-noise objects.
 Cluster[] getClusters()
          Returns the clusters as array of arrays of object ids.
 Integer getNoiseID()
          Returns the id of the noise partition.
 ClusteringResult<O> getResult(Integer partitionID)
          Returns the result of the specified partition.
 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.
 Iterator<Integer> partitionsIterator()
          Returns an iterator over the partition IDs.
 
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

partitionResults

private Map<Integer,ClusteringResult<O extends DatabaseObject>> partitionResults
Holds the results for the partitions.


noise

private Integer noise
A partitionID that contains per definition noise - may remain null.

Constructor Detail

PartitionClusteringResults

public PartitionClusteringResults(Database<O> db,
                                  Map<Integer,ClusteringResult<O>> resultMap,
                                  Integer noise)
A result for a partitioning algorithm providing a single result for a single partition.

Parameters:
db - the database
resultMap - a map of partition IDs to results
noise - a partitionID that contains per definition noise - may remain null
Method Detail

getClusters

public Cluster[] 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

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 PartitionResults<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>
Overrides:
output in class PartitionResults<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:
PartitionResults.output(java.io.PrintStream, de.lmu.ifi.dbs.elki.normalization.Normalization,java.util.List)

partitionsIterator

public Iterator<Integer> partitionsIterator()
Returns an iterator over the partition IDs.

Returns:
an iterator over the partition IDs

getResult

public ClusteringResult<O> getResult(Integer partitionID)
Returns the result of the specified partition.

Parameters:
partitionID - the ID of the partition
Returns:
the result of the specified partition

associate

public <L extends ClassLabel<L>> Database<O> associate(Class<L> classLabel)
Returns a database containing only non-noise objects.

Specified by:
associate in interface ClusteringResult<O extends DatabaseObject>
Parameters:
classLabel - the most convenient ClassLabel is the HierarchicalClassLabel, that would have as top-level label the partition id.
Returns:
a new Database of only non-noise objects
See Also:
ClusteringResult.associate(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()

clustering

public <L extends ClassLabel<L>> Map<L,Database<O>> clustering(Class<L> classLabel)
Returns a mapping to databases containing only non-noise objects.

Specified by:
clustering in interface ClusteringResult<O extends DatabaseObject>
Parameters:
classLabel - the most convenient ClassLabel is the HierarchicalClassLabel, that would have as top-level label the partition id.
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

getNoiseID

public Integer getNoiseID()
Returns the id of the noise partition.

Returns:
the id of the noise partition

Release 0.1 (2008-07-10_1838)