## org.apache.mahout.clustering
Class AbstractCluster

    java.lang.Object
      org.apache.mahout.clustering.AbstractCluster

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

Direct Known Subclasses:
  DistanceMeasureCluster, GaussianCluster

    public abstract class AbstractCluster

extends java.lang.Object
implements Cluster

Field Summary

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

Constructor Summary
`protected` `AbstractCluster()`
`protected` `AbstractCluster(Vector point, int id2)`
`protected` `AbstractCluster(Vector center2, Vector radius2, int id2)`

Method Summary
`java.lang.String` `asFormatString(java.lang.String[] bindings)` Produce a custom, human-friendly, printable representation of the Cluster.
`java.lang.String` `asJsonString()` Produce a textual representation of the Cluster using Json format.
`Vector` `computeCentroid()` Compute the centroid by averaging the pointTotals
`void` `computeParameters()` Compute a new set of posterior parameters based upon the Observations that have been observed since my creation
`int` `count()` Return the number of observations that have been observed by this model
`static java.lang.String` `formatVector(Vector v, java.lang.String[] bindings)` Return a human-readable formatted string representation of the vector, not intended to be complete nor usable as an input/output representation such as Json
`Vector` `getCenter()` Get the "center" of the Cluster as a Vector
`int` `getId()` Get the id of the Cluster
`abstract java.lang.String` `getIdentifier()`
`int` `getNumPoints()` Get an integer denoting the number of points observed by this cluster
`ClusterObservations` `getObservations()`
`Vector` `getRadius()` Get the "radius" of the Cluster as a Vector.
`protected double` `getS0()`
`protected Vector` `getS1()`
`protected Vector` `getS2()`
`void` `observe(ClusterObservations observations)`
`void` `observe(Vector x)`
`void` `observe(Vector x, double weight)`
`void` `observe(VectorWritable x)` Observe the given observation, retaining information about it
`void` `readFields(java.io.DataInput in)`
`protected void` `setCenter(Vector center)`
`protected void` `setId(int id)`
`protected void` `setNumPoints(int numPoints)`
`protected void` `setRadius(Vector radius)`
`void` `write(java.io.DataOutput out)`

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

Methods inherited from interface org.apache.mahout.clustering.Model
`pdf, sampleFromPosterior`

Constructor Detail

### AbstractCluster

    protected AbstractCluster()

### AbstractCluster

    protected AbstractCluster(Vector point,
                              int id2)

### AbstractCluster

    protected AbstractCluster(Vector center2,
                              Vector radius2,
                              int id2)

Method Detail

### setId

    protected void setId(int id)

  Parameters:
    `id` - the id to set

### setNumPoints

    protected void setNumPoints(int numPoints)

  Parameters:
    `numPoints` - the numPoints to set

### setCenter

    protected void setCenter(Vector center)

  Parameters:
    `center` - the center to set

### setRadius

    protected void setRadius(Vector radius)

  Parameters:
    `radius` - the radius to set

### getS0

    protected double getS0()

  Returns:
    the s0

### getS1

    protected Vector getS1()

  Returns:
    the s1

### getS2

    protected Vector getS2()

  Returns:
    the s2

### observe

    public void observe(ClusterObservations observations)

### observe

    public void observe(VectorWritable x)

  Description copied from interface: `Model`
  Observe the given observation, retaining information about it

  Specified by:
    `observe` in interface `Model<VectorWritable>`
  Parameters:
    `x` - an Observation from the posterior

### observe

    public void observe(Vector x,
                        double weight)

### observe

    public void observe(Vector x)

### getNumPoints

    public int getNumPoints()

  Description copied from interface: `Cluster`
  Get an integer denoting the number of points observed by this cluster

  Specified by:
    `getNumPoints` in interface `Cluster`
  Returns:
    an integer

### getObservations

    public ClusterObservations getObservations()

### computeParameters

    public void computeParameters()

  Description copied from interface: `Model`
  Compute a new set of posterior parameters based upon the Observations that have been observed since my creation

  Specified by:
    `computeParameters` in interface `Model<VectorWritable>`

### readFields

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

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

### write

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

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

### asFormatString

    public java.lang.String asFormatString(java.lang.String[] bindings)

  Description copied from interface: `Cluster`
  Produce a custom, human-friendly, printable representation of the Cluster.

  Specified by:
    `asFormatString` in interface `Cluster`
  Parameters:
    `bindings` - an optional String[] containing labels used to format the primary Vector/s of this implementation.
  Returns:
    a String

### getIdentifier

    public abstract java.lang.String getIdentifier()

### asJsonString

    public java.lang.String asJsonString()

  Description copied from interface: `Cluster`
  Produce a textual representation of the Cluster using Json format. (Label bindings are transient and not part of the Json representation)

  Specified by:
    `asJsonString` in interface `Cluster`
  Returns:
    a Json String

### getCenter

    public Vector getCenter()

  Description copied from interface: `Cluster`
  Get the "center" of the Cluster as a Vector

  Specified by:
    `getCenter` in interface `Cluster`
  Returns:
    a Vector

### getId

    public int getId()

  Description copied from interface: `Cluster`
  Get the id of the Cluster

  Specified by:
    `getId` in interface `Cluster`
  Returns:
    a unique integer

### getRadius

    public Vector getRadius()

  Description copied from interface: `Cluster`
  Get the "radius" of the Cluster as a Vector. Usually the radius is the standard deviation expressed as a Vector of size equal to the center. Some clusters may return zero values if not appropriate.

  Specified by:
    `getRadius` in interface `Cluster`
  Returns:
    aVector

### computeCentroid

    public Vector computeCentroid()

  Compute the centroid by averaging the pointTotals

  Returns:
    the new centroid

### formatVector

    public static java.lang.String formatVector(Vector v,
                                                java.lang.String[] bindings)

  Return a human-readable formatted string representation of the vector, not intended to be complete nor usable as an input/output representation such as Json

  Parameters:
    `v` - a Vector
  Returns:
    a String

### count

    public int count()

  Description copied from interface: `Model`
  Return the number of observations that have been observed by this model

  Specified by:
    `count` in interface `Model<VectorWritable>`
  Returns:
    an int

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