## org.apache.mahout.clustering.kmeans
Class Cluster

    java.lang.Object
      org.apache.mahout.clustering.AbstractCluster
          org.apache.mahout.clustering.DistanceMeasureCluster
              org.apache.mahout.clustering.kmeans.Cluster

All Implemented Interfaces:
  org.apache.hadoop.io.Writable, Cluster, Model<VectorWritable>

Direct Known Subclasses:
  MeanShiftCanopy, SoftCluster

    public class Cluster

extends DistanceMeasureCluster

Field Summary

Fields inherited from class org.apache.mahout.clustering.DistanceMeasureCluster
`measure`

Fields inherited from interface org.apache.mahout.clustering.Cluster
`CLUSTERED_POINTS_DIR, CLUSTERS_DIR, INITIAL_CLUSTERS_DIR`

Constructor Summary
`Cluster()` For (de)serialization as a Writable
`Cluster(Vector center, int clusterId, DistanceMeasure measure)` Construct a new cluster with the given point as its center

Method Summary
`java.lang.String` `asFormatString()`
`boolean` `computeConvergence(DistanceMeasure measure, double convergenceDelta)` Return if the cluster is converged by comparing its center and centroid.
`static java.lang.String` `formatCluster(Cluster cluster)` Format the cluster for output
`java.lang.String` `getIdentifier()`
`boolean` `isConverged()`
`void` `readFields(java.io.DataInput in)`
`protected void` `setConverged(boolean converged)`
`java.lang.String` `toString()`
`void` `write(java.io.DataOutput out)`

Methods inherited from class org.apache.mahout.clustering.DistanceMeasureCluster
`getMeasure, pdf, sampleFromPosterior, setMeasure`

Methods inherited from class org.apache.mahout.clustering.AbstractCluster
`asFormatString, asJsonString, computeCentroid, computeParameters, count, formatVector, getCenter, getId, getNumPoints, getObservations, getRadius, getS0, getS1, getS2, observe, observe, observe, observe, setCenter, setId, setNumPoints, setRadius`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### Cluster

    public Cluster()

  For (de)serialization as a Writable

### Cluster

    public Cluster(Vector center,
                   int clusterId,
                   DistanceMeasure measure)

  Construct a new cluster with the given point as its center

  Parameters:
    `center` - the Vector center
    `clusterId` - the int cluster id
    `measure` - a DistanceMeasure

Method Detail

### formatCluster

    public static java.lang.String formatCluster(Cluster cluster)

  Format the cluster for output

  Parameters:
    `cluster` - the Cluster
  Returns:
    the String representation of the Cluster

### asFormatString

    public java.lang.String asFormatString()

### write

    public void write(java.io.DataOutput out)
               throws java.io.IOException

  Specified by:
    `write` in interface `org.apache.hadoop.io.Writable`
  Overrides:
    `write` in class `DistanceMeasureCluster`
  Throws:
    `java.io.IOException`

### readFields

    public void readFields(java.io.DataInput in)
                    throws java.io.IOException

  Specified by:
    `readFields` in interface `org.apache.hadoop.io.Writable`
  Overrides:
    `readFields` in class `DistanceMeasureCluster`
  Throws:
    `java.io.IOException`

### toString

    public java.lang.String toString()

  Overrides:
    `toString` in class `java.lang.Object`

### getIdentifier

    public java.lang.String getIdentifier()

  Overrides:
    `getIdentifier` in class `DistanceMeasureCluster`

### computeConvergence

    public boolean computeConvergence(DistanceMeasure measure,
                                      double convergenceDelta)

  Return if the cluster is converged by comparing its center and centroid.

  Parameters:
    `measure` - The distance measure to use for cluster-point comparisons.
    `convergenceDelta` - the convergence delta to use for stopping.
  Returns:
    if the cluster is converged

### isConverged

    public boolean isConverged()

### setConverged

    protected void setConverged(boolean converged)

Copyright © 2008-2010 The Apache Software Foundation. All Rights Reserved.