org.apache.mahout.clustering.dirichlet
Class DirichletCluster

java.lang.Object
  extended by org.apache.mahout.clustering.dirichlet.DirichletCluster
All Implemented Interfaces:
org.apache.hadoop.io.Writable, Cluster, Model<VectorWritable>, Parametered

public class DirichletCluster
extends Object
implements Cluster


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.mahout.common.parameters.Parametered
Parametered.ParameteredGeneralizations
 
Field Summary
 
Fields inherited from interface org.apache.mahout.clustering.Cluster
CLUSTERED_POINTS_DIR, CLUSTERS_DIR, FINAL_ITERATION_SUFFIX, INITIAL_CLUSTERS_DIR
 
Fields inherited from interface org.apache.mahout.common.parameters.Parametered
log
 
Constructor Summary
DirichletCluster()
           
DirichletCluster(Cluster model)
           
DirichletCluster(Cluster model, double totalCount)
           
 
Method Summary
 String asFormatString(String[] bindings)
          Produce a custom, human-friendly, printable representation of the Cluster.
 void computeParameters()
          Compute a new set of posterior parameters based upon the Observations that have been observed since my creation
 void configure(org.apache.hadoop.conf.Configuration job)
           
 long count()
          Return the number of observations that have been observed by this model
 void createParameters(String prefix, org.apache.hadoop.conf.Configuration jobConf)
          EXPERT: consumers should never have to call this method.
 Vector getCenter()
          Get the "center" of the Cluster as a Vector
 int getId()
          Get the id of the Cluster
 Cluster getModel()
           
 long getNumPoints()
          Get an integer denoting the number of points observed by this cluster
 Collection<Parameter<?>> getParameters()
           
 Vector getRadius()
          Get the "radius" of the Cluster as a Vector.
 double getTotalCount()
           
 boolean isConverged()
           
 void observe(Model<VectorWritable> x)
          Observe the given model, retaining information about its observations
 void observe(VectorWritable x)
          Observe the given observation, retaining information about it
 void observe(VectorWritable x, double weight)
          Observe the given observation, retaining information about it
 double pdf(VectorWritable x)
          Return the probability that the observation is described by this model
 void readFields(DataInput in)
           
static Cluster readModel(DataInput in)
          Reads a typed Model instance from the input stream
 Model<VectorWritable> sampleFromPosterior()
           
 void setModel(Cluster model)
           
 void write(DataOutput out)
           
static void writeModel(DataOutput out, Model<?> model)
          Writes a typed Model instance to the output stream
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DirichletCluster

public DirichletCluster(Cluster model,
                        double totalCount)

DirichletCluster

public DirichletCluster(Cluster model)

DirichletCluster

public DirichletCluster()
Method Detail

configure

public void configure(org.apache.hadoop.conf.Configuration job)
Specified by:
configure in interface Parametered

getParameters

public Collection<Parameter<?>> getParameters()
Specified by:
getParameters in interface Parametered

createParameters

public void createParameters(String prefix,
                             org.apache.hadoop.conf.Configuration jobConf)
Description copied from interface: Parametered
EXPERT: consumers should never have to call this method. It would be friendly visible to Parametered.ParameteredGeneralizations if java supported it. Calling this method should create a new list of parameters and is called

Specified by:
createParameters in interface Parametered
Parameters:
prefix - ends with a dot if not empty.
jobConf - configuration used for retrieving values
See Also:
invoking method, invoking method

getModel

public Cluster getModel()

setModel

public void setModel(Cluster model)

getTotalCount

public double getTotalCount()

readFields

public void readFields(DataInput in)
                throws IOException
Specified by:
readFields in interface org.apache.hadoop.io.Writable
Throws:
IOException

write

public void write(DataOutput out)
           throws IOException
Specified by:
write in interface org.apache.hadoop.io.Writable
Throws:
IOException

writeModel

public static void writeModel(DataOutput out,
                              Model<?> model)
                       throws IOException
Writes a typed Model instance to the output stream

Throws:
IOException

readModel

public static Cluster readModel(DataInput in)
                         throws IOException
Reads a typed Model instance from the input stream

Throws:
IOException

asFormatString

public String asFormatString(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

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

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

getNumPoints

public long 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

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

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>

count

public long 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

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

pdf

public double pdf(VectorWritable x)
Description copied from interface: Model
Return the probability that the observation is described by this model

Specified by:
pdf in interface Model<VectorWritable>
Parameters:
x - an Observation from the posterior
Returns:
the probability that x is in the receiver

sampleFromPosterior

public Model<VectorWritable> sampleFromPosterior()
Specified by:
sampleFromPosterior in interface Model<VectorWritable>
Returns:
a sample of my posterior model

observe

public void observe(VectorWritable x,
                    double weight)
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
weight - a double weighting factor

isConverged

public boolean isConverged()
Specified by:
isConverged in interface Cluster
Returns:
if the receiver has converged, or false if that has no meaning for the implementation

observe

public void observe(Model<VectorWritable> x)
Description copied from interface: Model
Observe the given model, retaining information about its observations

Specified by:
observe in interface Model<VectorWritable>
Parameters:
x - a Model<0>


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