|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.openimaj.ml.clustering.random.RandomDoubleCluster
public class RandomDoubleCluster
A simple (yet apparently quite effective) clustering technique trained used random data points. A configurable K number of data points are selected from the training data.
| Field Summary | |
|---|---|
protected double[][] |
clusterCenters
|
protected int |
K
|
protected DoubleNearestNeighbours |
nn
|
protected Random |
random
|
protected long |
seed
|
| Fields inherited from interface org.openimaj.ml.clustering.ReadWriteableCluster |
|---|
CLUSTER_HEADER |
| Constructor Summary | |
|---|---|
RandomDoubleCluster()
Convinence function for reading saved centroids. |
|
RandomDoubleCluster(int M)
Creates a new random byte cluster used to create centroids with data containing M elements. |
|
RandomDoubleCluster(int M,
int K)
Creates a new random byte cluster used to create K centroids with data containing M elements. |
|
| Method Summary | |
|---|---|
String |
asciiHeader()
Header for ascii input. |
byte[] |
binaryHeader()
Header for binary input. |
double[][] |
getClusters()
Utility function useful for testing. |
int |
getNDims()
Get data dimensionality |
int |
getNumberClusters()
Get the number of centers K |
void |
optimize(boolean exact)
Prepare the cluster for pushing |
int |
push_one(double[] data)
Project one datum to clusters |
int[] |
push_one(double[] data,
int numNeighbours)
Project one datum to clusters |
int[] |
push(double[][] data)
Project data to clusters. |
int[][] |
push(double[][] data,
int numNeighbours)
Project data to clusters. |
void |
readASCII(Scanner br)
Read internal state from in. |
void |
readBinary(DataInput in)
Read internal state from in. |
void |
setSeed(long seed)
|
String |
toString()
|
int |
train(DataSource<double[]> data)
Train clusters with a data source, can be more efficient |
int |
train(double[][] data)
Train clusters |
void |
writeASCII(PrintWriter writer)
Write the content of this as ascii to out. |
void |
writeBinary(DataOutput out)
Write the content of this as binary to out. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected int K
protected Random random
protected double[][] clusterCenters
protected DoubleNearestNeighbours nn
protected long seed
| Constructor Detail |
|---|
public RandomDoubleCluster(int M,
int K)
M - number of elements in each data vectorK - number of centroids to be createdpublic RandomDoubleCluster(int M)
M - public RandomDoubleCluster()
| Method Detail |
|---|
public void setSeed(long seed)
seed - the seed for the Random object used to select random data points.public int getNDims()
Cluster
getNDims in interface Cluster<RandomDoubleCluster,double[]>public int train(double[][] data)
Cluster
train in interface Cluster<RandomDoubleCluster,double[]>data - data.
public int train(DataSource<double[]> data)
Cluster
train in interface Cluster<RandomDoubleCluster,double[]>data - data.
public int getNumberClusters()
Cluster
getNumberClusters in interface Cluster<RandomDoubleCluster,double[]>public void optimize(boolean exact)
Cluster
optimize in interface Cluster<RandomDoubleCluster,double[]>exact - TODOpublic int[] push(double[][] data)
Cluster
push in interface Cluster<RandomDoubleCluster,double[]>data - data.
public int push_one(double[] data)
Cluster
push_one in interface Cluster<RandomDoubleCluster,double[]>data - datum to project.
public int[][] push(double[][] data,
int numNeighbours)
Cluster
push in interface Cluster<RandomDoubleCluster,double[]>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(double[] data,
int numNeighbours)
Cluster
push_one in interface Cluster<RandomDoubleCluster,double[]>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 double[][] getClusters()
Cluster
getClusters in interface Cluster<RandomDoubleCluster,double[]>public String toString()
toString in class Objectpublic String asciiHeader()
ReadableASCII
asciiHeader in interface ReadableASCIIasciiHeader in interface WriteableASCIIpublic byte[] binaryHeader()
ReadableBinary
binaryHeader in interface ReadableBinarybinaryHeader in interface WriteableBinary
public void readASCII(Scanner br)
throws IOException
ReadableASCII
readASCII in interface ReadableASCIIbr - source to read from.
IOException - an error reading input
public void readBinary(DataInput in)
throws IOException
ReadableBinary
readBinary in interface ReadableBinaryin - 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 out)
throws IOException
WriteableBinary
writeBinary in interface WriteableBinaryout - sink to write to
IOException - an error writing to out
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||