|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.openimaj.ml.clustering.kmeans.HFloatKMeans
public class HFloatKMeans
Hierarchical Float K-Means clustering (HFloatKMeans) is a simple hierarchical version of FastFloatKMeansCluster. The algorithm recursively applies FastFloatKMeansCluster to create more refined partitions of the data.
| Nested Class Summary | |
|---|---|
static class |
HFloatKMeans.Node
HFloatKMeans tree node The number of children is not bigger than the HFloatKMeans K parameter |
| Field Summary |
|---|
| Fields inherited from interface org.openimaj.ml.clustering.ReadWriteableCluster |
|---|
CLUSTER_HEADER |
| Constructor Summary | |
|---|---|
HFloatKMeans()
|
|
HFloatKMeans(HKMeansMethod method)
New HFloatKMeans tree |
|
| Method Summary | |
|---|---|
String |
asciiHeader()
Header for ascii input. |
byte[] |
binaryHeader()
Header for binary input. |
int |
countActiveLeafNodes()
Count number of active leaf nodes. |
int |
countLeafs()
Total number of leaves assuming leaves = K^depth |
boolean |
equals(Object o)
|
float[] |
getClusterCentroid(int[] path)
Given a path, get the cluster centroid associated with the cluster index of the path. |
float[][] |
getClusters()
Utility function useful for testing. |
int |
getDepth()
Get depth |
int |
getIndex(int[] path)
Translates a path down the KDTree as a cluster index. |
static int |
getIndex(int[] path,
int depth,
int K)
Translates a path down the KDTree as a cluster index. |
int |
getK()
|
int |
getMaxIterations()
Number of iterations for the underlying FastKMeans implementation |
int |
getNDims()
Get data dimensionality |
int |
getNumberClusters()
Get the number of centers K |
int[] |
getPath(int index)
Given an index, what was the path down the hierarchy that lead to it. |
static int[] |
getPath(int index,
int depth,
int K)
Given an index, what was the path down the hierarchy that lead to it. |
HFloatKMeans.Node |
getRoot()
Get maximum number of iterations |
void |
init(int M,
int K,
int depth)
Initialize HFloatKMeans tree |
void |
init(int M,
int K,
int depth,
int niters)
Initialize HFloatKMeans tree |
void |
optimize(boolean exact)
Prepare the cluster for pushing |
int[] |
push_one_path(float[] data)
Project data down HFloatKMeans tree |
int |
push_one(float[] data)
Project one datum to clusters |
int[] |
push_one(float[] data,
int numNeighbours)
Project one datum to clusters |
int[] |
push(float[][] data)
Project data to clusters. |
int[][] |
push(float[][] data,
int numNeighbours)
Project data to clusters. |
int[][] |
pushPath(float[][] data)
Project data down HFloatKMeans tree |
void |
readASCII(Scanner reader)
Read internal state from in. |
void |
readBinary(DataInput dis)
Read internal state from in. |
void |
setMaxIterations(int maxIters)
Number of iterations for the underlying FastKMeans implementation |
String |
toString()
|
int |
train(DataSource<float[]> data)
Train clusters with a data source, can be more efficient |
int |
train(float[][] data)
Train clusters |
void |
writeASCII(PrintWriter writer)
Write the content of this as ascii to out. |
void |
writeBinary(DataOutput dos)
Write the content of this as binary to out. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public HFloatKMeans(HKMeansMethod method)
method - clustering method.public HFloatKMeans()
| Method Detail |
|---|
public void init(int M,
int K,
int depth)
M - Data dimensionality.K - Number of clusters per node.depth - Tree depth.
public void init(int M,
int K,
int depth,
int niters)
M - Data dimensionality.K - Number of clusters per node.depth - Tree depth.niters - Maximum number of iterationspublic int train(float[][] data)
Cluster
train in interface Cluster<HFloatKMeans,float[]>data - data.
public int train(DataSource<float[]> data)
Cluster
train in interface Cluster<HFloatKMeans,float[]>data - data.
public int[][] pushPath(float[][] data)
data - Data to project.
public int[] push_one_path(float[] data)
data - Data to project.
public int getNDims()
Cluster
getNDims in interface Cluster<HFloatKMeans,float[]>public int getK()
public int getDepth()
public int getMaxIterations()
public HFloatKMeans.Node getRoot()
public void setMaxIterations(int maxIters)
maxIters -
public static int getIndex(int[] path,
int depth,
int K)
path - depth - K -
public int getIndex(int[] path)
path -
public static int[] getPath(int index,
int depth,
int K)
index - depth - K -
public int[] getPath(int index)
index -
public int countActiveLeafNodes()
public void optimize(boolean exact)
Cluster
optimize in interface Cluster<HFloatKMeans,float[]>exact - TODOpublic int[] push(float[][] data)
Cluster
push in interface Cluster<HFloatKMeans,float[]>data - data.
public int push_one(float[] data)
Cluster
push_one in interface Cluster<HFloatKMeans,float[]>data - datum to project.
public int[][] push(float[][] data,
int numNeighbours)
Cluster
push in interface Cluster<HFloatKMeans,float[]>data - data.numNeighbours - number of neighboring clusters to return also. When set to 1 this is equivalent to Cluster#push(DATATYPE[])
public int[] push_one(float[] data,
int numNeighbours)
Cluster
push_one in interface Cluster<HFloatKMeans,float[]>data - datum to project.numNeighbours - number of neighbouring clusters to return also. When set to 1 this is equivalent to Cluster.push_one(Object)
public String toString()
toString in class Objectpublic int countLeafs()
public int getNumberClusters()
Cluster
getNumberClusters in interface Cluster<HFloatKMeans,float[]>public boolean equals(Object o)
equals in class Objectpublic float[] getClusterCentroid(int[] path)
path -
public String asciiHeader()
ReadableASCII
asciiHeader in interface ReadableASCIIasciiHeader in interface WriteableASCIIpublic byte[] binaryHeader()
ReadableBinary
binaryHeader in interface ReadableBinarybinaryHeader in interface WriteableBinary
public void readASCII(Scanner reader)
throws IOException
ReadableASCII
readASCII in interface ReadableASCIIreader - source to read from.
IOException - an error reading input
public void readBinary(DataInput dis)
throws IOException
ReadableBinary
readBinary in interface ReadableBinarydis - source to read from.
IOException - an error reading input
public void writeASCII(PrintWriter writer)
throws IOException
WriteableASCII
writeASCII in interface WriteableASCIIwriter - sink to write to
IOException - an error writing to out
public void writeBinary(DataOutput dos)
throws IOException
WriteableBinary
writeBinary in interface WriteableBinarydos - sink to write to
IOException - an error writing to outpublic float[][] getClusters()
Cluster
getClusters in interface Cluster<HFloatKMeans,float[]>
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||