edu.stanford.nlp.cluster
Class SimilarityMatrix

java.lang.Object
  |
  +--edu.stanford.nlp.cluster.SimilarityMatrix
All Implemented Interfaces:
MatrixWrapper

public class SimilarityMatrix
extends Object
implements MatrixWrapper

Variables and methods for constructing a matrix of similarities of a data collection. The client must provide the Similarity metric.


Field Summary
protected  ArrayListMatrix similarities
           
 
Constructor Summary
SimilarityMatrix(Clusters c)
          Creates new SimilarityMatrix with default Cosine Similarity
SimilarityMatrix(Matrix m)
          Creates new SimilarityMatrix with default Cosine Similarity
SimilarityMatrix(Similarity s, Clusters c)
          Creates new SimilarityMatrix with Similarity Metric defined by client
SimilarityMatrix(Similarity s, Matrix m)
          Creates new SimilarityMatrix with Similarity Metric defined by client
 
Method Summary
 Matrix createSimilarityMatrix(Similarity s, Clusters c)
          create a full dense matrix of similarities, where similarities(i,j) gives the similarity between the probability distribution over data of clusters i and j of Clusters c as determined by the similarity metric s
 Matrix createSimilarityMatrix(Similarity s, Matrix m)
          create a full dense matrix of similarities, where similarities(i,j) gives the similarity between columns i and j of Matrix m as determined by the similarity metric s
 Matrix getMatrix()
          Returns underlying Matrix
 void initialize(int size)
          initializes similarities matrix to be a m x m square matrix, where m=size the matrix is of type ArrayListMatrix, the columns of which are of type GrowableDenseDoubleArray
 void merge(int i, int j, Double4Function csf, Clusters clusters)
          Merges columns i,j in the similarity matrix by setting the value at each entry k in the column to be csf.apply(i(k),j(k)).
 void merge(int i, int j, cern.colt.function.DoubleDoubleFunction csf)
          Merges columns i,j in the similarity matrix by setting the value at each entry k in the column to be csf.apply(i(k),j(k)).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

similarities

protected ArrayListMatrix similarities
Constructor Detail

SimilarityMatrix

public SimilarityMatrix(Similarity s,
                        Matrix m)
Creates new SimilarityMatrix with Similarity Metric defined by client


SimilarityMatrix

public SimilarityMatrix(Similarity s,
                        Clusters c)
Creates new SimilarityMatrix with Similarity Metric defined by client


SimilarityMatrix

public SimilarityMatrix(Matrix m)
Creates new SimilarityMatrix with default Cosine Similarity


SimilarityMatrix

public SimilarityMatrix(Clusters c)
Creates new SimilarityMatrix with default Cosine Similarity

Method Detail

initialize

public void initialize(int size)
initializes similarities matrix to be a m x m square matrix, where m=size the matrix is of type ArrayListMatrix, the columns of which are of type GrowableDenseDoubleArray


createSimilarityMatrix

public Matrix createSimilarityMatrix(Similarity s,
                                     Matrix m)
create a full dense matrix of similarities, where similarities(i,j) gives the similarity between columns i and j of Matrix m as determined by the similarity metric s


createSimilarityMatrix

public Matrix createSimilarityMatrix(Similarity s,
                                     Clusters c)
create a full dense matrix of similarities, where similarities(i,j) gives the similarity between the probability distribution over data of clusters i and j of Clusters c as determined by the similarity metric s


getMatrix

public Matrix getMatrix()
Description copied from interface: MatrixWrapper
Returns underlying Matrix

Specified by:
getMatrix in interface MatrixWrapper

merge

public void merge(int i,
                  int j,
                  cern.colt.function.DoubleDoubleFunction csf)
Merges columns i,j in the similarity matrix by setting the value at each entry k in the column to be csf.apply(i(k),j(k)). This corresponds to single-link or complete-link agglomerative clustering. Merged column takes the spot of the column with the lower index, and the column (and row) with the higher index is removed. DoubleDoubleFunction csf is the Cluster Similarity Function (Single-Link, Complete-Link, etc.)


merge

public void merge(int i,
                  int j,
                  Double4Function csf,
                  Clusters clusters)
Merges columns i,j in the similarity matrix by setting the value at each entry k in the column to be csf.apply(i(k),j(k)). This corresponds to group-average (or related) agglomerative clustering Merged column takes the spot of the column with the lower index, and the column (and row) with the higher index is removed. Double4Function csf is the Cluster Similarity Function (Group-Average, etc.)



Stanford NLP Group