public class NearestNeighborAffinityMatrixCreator extends Object implements AffinityMatrixCreator
AffinityMatrixCreator
adds an edge added between two data
points, i and j, if j is in the k nearest neighbors of i. This
relationship is not symmetric.Constructor and Description |
---|
NearestNeighborAffinityMatrixCreator() |
Modifier and Type | Method and Description |
---|---|
MatrixFile |
calculate(Matrix input)
Computes the affinity matrix for the input matrix according to the
specified similarity metrics, returning the result as a file on disk.
|
MatrixFile |
calculate(MatrixFile input)
Computes the affinity matrix for the input matrix according to the
specified similarity metrics, returning the result as a file on disk.
|
MatrixFile |
calculate(MatrixFile input,
boolean useColumns)
Computes the affinity matrix for the input matrix according to the
specified similarity metrics, optionally treating the columns as data
points, and returning the result as a file on disk.
|
void |
setFunctions(SimilarityFunction edgeSim,
SimilarityFunction kernelSim)
Sets the
SimilarityFunction s to be used for selecting edges and
then weighting edges. |
void |
setParams(double... params)
Sets any numeric parameters, such as thresholds, for this
AffinityMatrixCreator . |
public NearestNeighborAffinityMatrixCreator()
public void setParams(double... params)
AffinityMatrixCreator
AffinityMatrixCreator
. Each AffinityMatrixCreator
should
specify how many parameters it expects and in what order.setParams
in interface AffinityMatrixCreator
public void setFunctions(SimilarityFunction edgeSim, SimilarityFunction kernelSim)
SimilarityFunction
s to be used for selecting edges and
then weighting edges. edgeSim
will be computed over every
possible edge. The returned scores will be used to filter out valid
edges in the graph. kernelSim
will be used to compute the final
edge weight between two valid edges in the graph, this is also called a
kernel function.setFunctions
in interface AffinityMatrixCreator
edgeSim
- The SimilarityFunction
used to filter edges. This
metric is assumed to be symmetric.kernelSim
- The SimilarityFunction
used to weight valid
edges. This metric may or may not be symmetric.public MatrixFile calculate(Matrix input)
MatrixFile
as input.calculate
in interface AffinityMatrixCreator
input
- The Matrix
that contains data points that are to
be formed into an affinity matrix.MatrixFile.read()
.public MatrixFile calculate(MatrixFile input)
calculate
in interface AffinityMatrixCreator
input
- The MatrixFile
that contains data points that are to
be formed into an affinity matrix.MatrixFile.read()
.public MatrixFile calculate(MatrixFile input, boolean useColumns)
SVDLIBC_SPARSE_BINARY
format which is stored in
column-major order.calculate
in interface AffinityMatrixCreator
input
- The MatrixFile
that contains data points that are to
be formed into an affinity matrix.useColumns
- true
if the affinity matrix should be
calculated for the columns of the input matrix, not the
rows.MatrixFile.read()
.Copyright © 2012. All Rights Reserved.