frog
Class Kmeans

java.lang.Object
  extended by frog.Kmeans
All Implemented Interfaces:
Quantizer, Serializable

public class Kmeans
extends Object
implements Quantizer

Kmeans is a Quantizer implementation that utilizes the k-means algorithm (as well as k-means++ if requested) to select appropriate representatives (that is, build its codebook).

Author:
Team Better Recognize
See Also:
Serialized Form

Field Summary
protected  int k
           
protected  Accel3D[] means
           
protected  Accel3D[] oldMeans
           
protected  Vector<Accel3D> trainingSet
           
 
Fields inherited from interface frog.Quantizer
KMEANS, NUM_TYPES_SUPPORTED
 
Constructor Summary
Kmeans(KmeansParameters params, Vector<Accel3D> in)
          Constructs a Kmeans quantizer with a given set of k-means parameters and a 3D acceleration data set.
Kmeans(Vector<Accel3D> in)
          Constructs a Kmeans quantizer with a given 3D acceleration data set.
 
Method Summary
 Vector<Accel3D> getDataSet()
          Accessor for the data set utilized by this Quantizer.
 Accel3D[] getMeans()
          Returns the array of Accel3Ds making up the means for this Quantizer.
 int getNumMeans()
          Accessor for the number of means.
 int getType()
          Accessor for the Quantizer type index.
 void setDataSet(Vector<Accel3D> data)
          Sets the data set to use in this Quantizer.
 int size()
          For Kmeans, the size corresponds to the number of means (k).
 int translate(Accel3D acc)
          For Kmeans, translates to the index of the closest mean determined by the k-means algorithm.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

k

protected int k

oldMeans

protected Accel3D[] oldMeans

means

protected Accel3D[] means

trainingSet

protected Vector<Accel3D> trainingSet
Constructor Detail

Kmeans

public Kmeans(Vector<Accel3D> in)
Constructs a Kmeans quantizer with a given 3D acceleration data set.

Parameters:
in - a set of Accel3D values

Kmeans

public Kmeans(KmeansParameters params,
              Vector<Accel3D> in)
Constructs a Kmeans quantizer with a given set of k-means parameters and a 3D acceleration data set.

Parameters:
params - quantizing parameters
in - a set of Accel3D values
Method Detail

translate

public int translate(Accel3D acc)
For Kmeans, translates to the index of the closest mean determined by the k-means algorithm.

Specified by:
translate in interface Quantizer
Parameters:
acc - The acceleration vector to translate (quantize)
Returns:
the quantized value (an integer) which the Accel3D is mapped to in this Quantizer

getNumMeans

public int getNumMeans()
Accessor for the number of means.

Returns:
the number of means.

size

public int size()
For Kmeans, the size corresponds to the number of means (k).

Specified by:
size in interface Quantizer
Returns:
the size of the Quantizer.

getMeans

public Accel3D[] getMeans()
Returns the array of Accel3Ds making up the means for this Quantizer.

Returns:
the array of Accel3Ds making up the means for this Quantizer.

getDataSet

public Vector<Accel3D> getDataSet()
Description copied from interface: Quantizer
Accessor for the data set utilized by this Quantizer.

Specified by:
getDataSet in interface Quantizer
Returns:
the data set for the Quantizer

setDataSet

public void setDataSet(Vector<Accel3D> data)
Description copied from interface: Quantizer
Sets the data set to use in this Quantizer.

Specified by:
setDataSet in interface Quantizer
Parameters:
data - the data set to assign to this Quantizer

getType

public int getType()
Description copied from interface: Quantizer
Accessor for the Quantizer type index. Should return the value as specified in the Quantizer interface.

Specified by:
getType in interface Quantizer
Returns:
the Quantizer type index.