public class HierarchicalAlg extends Object
ClustMat is our agglomeration "engine". It looks after labeling only, and is independent of any agglomerative clustering criterion.
Other utility methods:
Dissim ... calculate dissimilarity matrix
getNNs ... get nearest neighbors and associated nearest neighbor
dissimilarities
getSpaces ... helping in output formating
printMatrix ... print matrix of doubles, or integers
printVect ... print vector of doubles, or integers
main does the following:
Step 5 here determines the agglomerative clustering criterion. We are currently using the minimum variance method. It is indicated in the code where to change to use other agglomerative criteria.
Output cluster labels using original sequence numbers. The ordering of observations is not such that a dendrogram can be directly constructed. However the cluster labels do allow selections and further inter and intra cluster processing of the input data.
Modifier and Type | Field and Description |
---|---|
static double |
MAXVAL |
Constructor and Description |
---|
HierarchicalAlg(DataHolder data)
Build a hierarchical algorithm.
|
Modifier and Type | Method and Description |
---|---|
static double[][] |
calcDissim(int nrow,
int ncol,
double[] mass,
double[][] A)
Method Dissim, calculates dissimilarity n x n array
|
static void |
calClustMat(int nrow,
int[][] clusters,
int clust1,
int clust2,
int ncl)
Method ClustMat, updates cluster structure matrix following an
agglomeration
|
DataHolder |
getCenters()
Returns cluster centers
|
int |
getClusters()
Get number of clusters
|
double |
getCompactness()
This method returns the Compactness and Separation measure of cluster
validity (see Fuzzy Algorithms With Applications to Image Processing and
Pattern Recognition, Zheru Chi, Hong Yan, Tuan Pham, World Scientific,
pp.
|
int |
getError()
Get error: 0 looks OK
|
String |
getName()
Get description
|
static void |
getNNs(int nrow,
int[] flag,
double[][] diss,
int[] nn,
double[] nndiss)
Method getNNs, determine NNs and NN dissimilarities
|
int[] |
getNumberPoints()
Returns the number of points in each cluster
|
void |
getResult()
Get cluster results (should be called after run method)
|
static String |
getSpaces(int n) |
void |
run() |
void |
runBest() |
void |
setClusters(int N)
Sets number of clusters
|
public static final double MAXVAL
public HierarchicalAlg(DataHolder data)
data
- input datapublic int getError()
public double getCompactness()
public void setClusters(int N)
N
- int - number of clusterspublic int getClusters()
public void getResult()
public DataHolder getCenters()
public int[] getNumberPoints()
public static double[][] calcDissim(int nrow, int ncol, double[] mass, double[][] A)
nrow
- integer row dimensionncol
- integer column dimensionA
- floating row/column matrixpublic static void getNNs(int nrow, int[] flag, double[][] diss, int[] nn, double[] nndiss)
nrow
- row dimension or number of observations (input)flag
- =1 for active observation, = 0 for inactive one (input)diss
- dissimilarity matrix (input)nn
- nearest neighbor sequence number (calculated)nndiss
- nearest neigbor dissimilarity (calculated)public static void calClustMat(int nrow, int[][] clusters, int clust1, int clust2, int ncl)
nrow
- row dimension or number of observations (input)clusters
- list of agglomerations, stored as array of pairs of cluster
sequence numbers (input, and updated)clust1
- first agglomerand (input)clust2
- second agglomerand (input)ncl
- number of clusters remaining (input)public static String getSpaces(int n)
public void run()
public void runBest()
public String getName()
Jas4pp 1.5 © Java Analysis Studio for Particle Physics