Description Usage Arguments Details Value Examples
This is a factory function - it returns a function which can be
used to create a matrix of clustering weights. In particular, it returns a function
which takes a n-by-p data matrix X and returns an n-by-n matrix whose
(i, j)-th element is given by e^{-phi * dist(x_i, x_j)} where
x_i, x_j are the i-th and j-th row of X
respectively. The distance metric used is determined by the
dist.method
and p
arguments, which are passed to
dist
.
1 2 3 4 5 6 7 8 | dense_rbf_kernel_weights(
phi = "auto",
dist.method = c("euclidean", "maximum", "manhattan", "canberra", "binary",
"minkowski"),
p = 2
)
sparse_rbf_kernel_weights(..., k = "auto")
|
phi |
The scale factor used for the RBF kernel |
dist.method |
The type of distance used to calculate distances between
points. See the |
p |
The power of the Minkowski distance (only relevant if |
... |
Arguments passed through from |
k |
The number of neighbors to use |
The sparse weights (sparse_rbf_kernel_weights
) are calculated by
dropping all but the k
largest weights for each row of the matrix
(equivalent to taking the k
nearest neighbors to each point). The
weight matrix is symmetrized, so if a is a neighbor of b, but
not vice versa, the edge is still included. If k
is too small, resulting
in a non-fully-connected graph, an error is thrown.
If phi == "auto"
, a grid of possible phi values are used and
the phi
which maximizes the variance of the resulting weights is taken.
If k == "auto"
, the smallest k
that still yields a fully connected
graph is used.
A function which, when called, returns a matrix of clustering weights.
1 2 3 4 5 6 7 8 | weight_func <- dense_rbf_kernel_weights()
weight_func(presidential_speech)
weight_func <- dense_rbf_kernel_weights(phi=0.1, dist.method="canberra")
weight_func(presidential_speech)
weight_func <- sparse_rbf_kernel_weights()
weight_func(presidential_speech)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.