Nothing
# Generated by devforge. Do not edit.
# Edit the specs under inst/params/ and run devforge::forge_params().
# parameter wrappers -----------------------------------------------------------
#' Parameters for clustered data generation
#'
#' @description For use with [manifold_synthetic_data()].
#'
#' @param n_clusters Integer. Number of clusters to generate. Defaults to `15L`.
#'
#' @returns A named list with the following elements:
#' \itemize{
#' \item n_clusters - Integer. Number of clusters to generate. Defaults to
#' `15L`.
#' }
#'
#' @export
params_clusters <- function(
n_clusters = 15L
) {
# Checks
checkmate::qassert(n_clusters, "I1(1,)")
# Return
list(
n_clusters = n_clusters
)
}
#' Wrapper function to generate densMAP parameters
#'
#' @description The density-preservation knobs on top of the usual UMAP
#' parameters. densMAP adds `-lambda * Corr(log Ro, log Re)` to the UMAP loss,
#' where `Ro` is the local radius in the input space and `Re` the matching
#' radius in the embedding. Setting `lambda` to `0` recovers plain UMAP.
#'
#' @param lambda Numeric. Weight of the density term. `0` disables it. The
#' default is the densMAP reference value. Defaults to `2.0`.
#' @param frac Numeric. Fraction of the total epochs, at the end of the run,
#' over which the density term is active. Defaults to `0.3`.
#' @param var_shift Numeric. Additive shift on the variance of the embedding
#' log-radii. Defaults to `0.1`.
#'
#' @returns A named list with the following elements:
#' \itemize{
#' \item lambda - Numeric. Weight of the density term. `0` disables it. The
#' default is the densMAP reference value. Defaults to `2.0`.
#' \item frac - Numeric. Fraction of the total epochs, at the end of the run,
#' over which the density term is active. Defaults to `0.3`.
#' \item var_shift - Numeric. Additive shift on the variance of the embedding
#' log-radii. Defaults to `0.1`.
#' }
#'
#' @references Narayan, Berger & Cho, Nat. Biotechnol., 2021
#'
#' @export
params_densmap <- function(
lambda = 2.0,
frac = 0.3,
var_shift = 0.1
) {
# Checks
checkmate::qassert(lambda, "N1[0,)")
checkmate::qassert(frac, "N1[0,1]")
checkmate::qassert(var_shift, "N1[0,)")
# Return
list(
lambda = lambda,
frac = frac,
var_shift = var_shift
)
}
#' Wrapper function to generate den-SNE parameters
#'
#' @description The density-preservation knobs on top of the usual t-SNE
#' parameters. den-SNE adds `-lambda * Corr(log Ro, log Re)` to the t-SNE loss,
#' where `Ro` is the local radius in the input space and `Re` the matching
#' radius in the embedding. Setting `lambda` to `0` recovers plain t-SNE.
#'
#' @param lambda Numeric. Weight of the density term. `0` disables it. The
#' default is higher than the den-SNE reference value (original: `0.1`).
#' Defaults to `0.5`.
#' @param frac Numeric. Fraction of the total epochs, at the end of the run,
#' over which the density term is active. Defaults to `0.3`.
#' @param var_shift Numeric. Additive shift on the variance of the embedding
#' log-radii. Defaults to `0.1`.
#'
#' @returns A named list with the following elements:
#' \itemize{
#' \item lambda - Numeric. Weight of the density term. `0` disables it. The
#' default is higher than the den-SNE reference value (original: `0.1`).
#' Defaults to `0.5`.
#' \item frac - Numeric. Fraction of the total epochs, at the end of the run,
#' over which the density term is active. Defaults to `0.3`.
#' \item var_shift - Numeric. Additive shift on the variance of the embedding
#' log-radii. Defaults to `0.1`.
#' }
#'
#' @references Narayan, Berger & Cho, Nat. Biotechnol., 2021
#'
#' @export
params_densne <- function(
lambda = 0.5,
frac = 0.3,
var_shift = 0.1
) {
# Checks
checkmate::qassert(lambda, "N1[0,)")
checkmate::qassert(frac, "N1[0,1]")
checkmate::qassert(var_shift, "N1[0,)")
# Return
list(
lambda = lambda,
frac = frac,
var_shift = var_shift
)
}
#' Wrapper function to generate diffusion maps parameters
#'
#' @param bandwidth_scale Numeric. Multiplicative factor applied to the adaptive
#' kernel bandwidth. Defaults to `1.0`.
#' @param thresh Numeric. Sparsity threshold applied to kernel entries. Defaults
#' to `1e-04`.
#' @param graph_symmetry String. Method used to symmetrise the affinity graph.
#' One of `c("additive", "multiplicative", "mnn", "none")`. Defaults to
#' `"additive"`.
#' @param alpha_norm Numeric. Anisotropic density-correction exponent. `0` gives
#' the normalised graph Laplacian, `0.5` the Fokker-Planck operator, `1` the
#' Laplace-Beltrami operator. Defaults to `1.0`.
#' @param t_max Integer. Maximum diffusion time considered during automatic
#' selection via Von Neumann entropy knee point detection. Defaults to `100L`.
#' @param t_custom Integer or `NULL`. Fixed diffusion time. If set, overrides
#' automatic time selection. Defaults to `NULL`.
#' @param n_landmarks Integer or `NULL`. Number of landmarks for compressed
#' diffusion. If `NULL`, the full N x N diffusion operator is used. Defaults to
#' `2048L`.
#' @param landmark_method String. Method used to select landmarks. One of
#' `c("spectral", "random", "density")`. Defaults to `"spectral"`.
#' @param n_svd Integer or `NULL`. Number of SVD components used in landmark
#' construction. If `NULL`, the library selects a sensible default. Defaults to
#' `NULL`.
#'
#' @returns A named list with the following elements:
#' \itemize{
#' \item bandwidth_scale - Numeric. Multiplicative factor applied to the
#' adaptive kernel bandwidth. Defaults to `1.0`.
#' \item thresh - Numeric. Sparsity threshold applied to kernel entries.
#' Defaults to `1e-04`.
#' \item graph_symmetry - String. Method used to symmetrise the affinity graph.
#' One of `c("additive", "multiplicative", "mnn", "none")`. Defaults to
#' `"additive"`.
#' \item alpha_norm - Numeric. Anisotropic density-correction exponent. `0`
#' gives the normalised graph Laplacian, `0.5` the Fokker-Planck operator, `1`
#' the Laplace-Beltrami operator. Defaults to `1.0`.
#' \item t_max - Integer. Maximum diffusion time considered during automatic
#' selection via Von Neumann entropy knee point detection. Defaults to `100L`.
#' \item t_custom - Integer or `NULL`. Fixed diffusion time. If set, overrides
#' automatic time selection. Defaults to `NULL`.
#' \item n_landmarks - Integer or `NULL`. Number of landmarks for compressed
#' diffusion. If `NULL`, the full N x N diffusion operator is used. Defaults to
#' `2048L`.
#' \item landmark_method - String. Method used to select landmarks. One of
#' `c("spectral", "random", "density")`. Defaults to `"spectral"`.
#' \item n_svd - Integer or `NULL`. Number of SVD components used in landmark
#' construction. If `NULL`, the library selects a sensible default. Defaults to
#' `NULL`.
#' }
#'
#' @export
params_diffusion_maps <- function(
bandwidth_scale = 1.0,
thresh = 1e-04,
graph_symmetry = c("additive", "multiplicative", "mnn", "none"),
alpha_norm = 1.0,
t_max = 100L,
t_custom = NULL,
n_landmarks = 2048L,
landmark_method = c("spectral", "random", "density"),
n_svd = NULL
) {
graph_symmetry <- match.arg(graph_symmetry)
landmark_method <- match.arg(landmark_method)
# Checks
checkmate::qassert(bandwidth_scale, "N1(0,)")
checkmate::qassert(thresh, "N1[0,)")
checkmate::assertChoice(
graph_symmetry,
c("additive", "multiplicative", "mnn", "none")
)
checkmate::qassert(alpha_norm, "N1[0,1]")
checkmate::qassert(t_max, "I1[1,)")
checkmate::qassert(t_custom, c("I1[1,)", "0"))
checkmate::qassert(n_landmarks, c("I1[1,)", "0"))
checkmate::assertChoice(landmark_method, c("spectral", "random", "density"))
checkmate::qassert(n_svd, c("I1[1,)", "0"))
# Return
list(
bandwidth_scale = bandwidth_scale,
thresh = thresh,
graph_symmetry = graph_symmetry,
alpha_norm = alpha_norm,
t_max = t_max,
t_custom = t_custom,
n_landmarks = n_landmarks,
landmark_method = landmark_method,
n_svd = n_svd
)
}
#' Wrapper function to generate DREAMS parameters
#'
#' @description The regularisation knob on top of the usual t-SNE parameters.
#' DREAMS pulls every t-SNE epoch towards a scaled global reference embedding
#' (PCA unless one is supplied). Setting `lambda` to `0` recovers plain t-SNE,
#' `1` the reference.
#'
#' @param lambda Numeric. Regularisation strength. Larger values pull harder
#' towards the reference layout. The default is the DREAMS reference value.
#' Defaults to `0.15`.
#'
#' @returns A named list with the following elements:
#' \itemize{
#' \item lambda - Numeric. Regularisation strength. Larger values pull harder
#' towards the reference layout. The default is the DREAMS reference value.
#' Defaults to `0.15`.
#' }
#'
#' @references Kury, Kobak & Damrich, Transactions on Machine Learning Research,
#' 2026
#'
#' @export
params_dreams <- function(
lambda = 0.15
) {
# Checks
checkmate::qassert(lambda, "N1[0,1]")
# Return
list(
lambda = lambda
)
}
#' Wrapper function to generate EVoC parameters
#'
#' @param noise_level Numeric. Noise level for the embedding gradient. `0.0` =
#' aggressive, `1.0` = conservative. Defaults to `0.5`.
#' @param n_epochs Integer. Number of embedding optimisation epochs. Defaults to
#' `50L`.
#' @param embedding_dim Integer or `NULL`. Embedding dimensionality. If `NULL`,
#' uses `min(max(n_neighbours / 4, 4), 16)`. Defaults to `NULL`.
#' @param neighbour_scale Numeric. Multiplier on effective neighbours for fuzzy
#' graph construction. Defaults to `1.0`.
#' @param symmetrise Boolean. Whether to symmetrise the fuzzy graph. Defaults to
#' `TRUE`.
#' @param min_samples Integer. Minimum samples for core distance in MST density
#' estimation. Defaults to `5L`.
#' @param base_min_cluster_size Integer. Base minimum cluster size for the
#' finest layer. Defaults to `5L`.
#' @param approx_n_clusters Integer or `NULL`. If set, binary-searches for
#' approximately this many clusters (single layer output). Defaults to `NULL`.
#' @param min_similarity_threshold Numeric. Jaccard similarity threshold for
#' filtering redundant layers. Defaults to `0.2`.
#' @param max_layers Integer. Maximum number of cluster layers to return.
#' Defaults to `10L`.
#'
#' @returns A named list with the following elements:
#' \itemize{
#' \item noise_level - Numeric. Noise level for the embedding gradient. `0.0` =
#' aggressive, `1.0` = conservative. Defaults to `0.5`.
#' \item n_epochs - Integer. Number of embedding optimisation epochs. Defaults
#' to `50L`.
#' \item embedding_dim - Integer or `NULL`. Embedding dimensionality. If
#' `NULL`, uses `min(max(n_neighbours / 4, 4), 16)`. Defaults to `NULL`.
#' \item neighbour_scale - Numeric. Multiplier on effective neighbours for
#' fuzzy graph construction. Defaults to `1.0`.
#' \item symmetrise - Boolean. Whether to symmetrise the fuzzy graph. Defaults
#' to `TRUE`.
#' \item min_samples - Integer. Minimum samples for core distance in MST
#' density estimation. Defaults to `5L`.
#' \item base_min_cluster_size - Integer. Base minimum cluster size for the
#' finest layer. Defaults to `5L`.
#' \item approx_n_clusters - Integer or `NULL`. If set, binary-searches for
#' approximately this many clusters (single layer output). Defaults to `NULL`.
#' \item min_similarity_threshold - Numeric. Jaccard similarity threshold for
#' filtering redundant layers. Defaults to `0.2`.
#' \item max_layers - Integer. Maximum number of cluster layers to return.
#' Defaults to `10L`.
#' }
#'
#' @export
params_evoc <- function(
noise_level = 0.5,
n_epochs = 50L,
embedding_dim = NULL,
neighbour_scale = 1.0,
symmetrise = TRUE,
min_samples = 5L,
base_min_cluster_size = 5L,
approx_n_clusters = NULL,
min_similarity_threshold = 0.2,
max_layers = 10L
) {
# Checks
checkmate::qassert(noise_level, "N1[0,1]")
checkmate::qassert(n_epochs, "I1[1,)")
checkmate::qassert(embedding_dim, c("I1[2,)", "0"))
checkmate::qassert(neighbour_scale, "N1(0,)")
checkmate::qassert(symmetrise, "B1")
checkmate::qassert(min_samples, "I1[1,)")
checkmate::qassert(base_min_cluster_size, "I1[2,)")
checkmate::qassert(approx_n_clusters, c("I1[2,)", "0"))
checkmate::qassert(min_similarity_threshold, "N1[0,1]")
checkmate::qassert(max_layers, "I1[1,)")
# Return
list(
noise_level = noise_level,
n_epochs = n_epochs,
embedding_dim = embedding_dim,
neighbour_scale = neighbour_scale,
symmetrise = symmetrise,
min_samples = min_samples,
base_min_cluster_size = base_min_cluster_size,
approx_n_clusters = approx_n_clusters,
min_similarity_threshold = min_similarity_threshold,
max_layers = max_layers
)
}
#' Wrapper function to generate ForceAtlas2 parameters
#'
#' @description The graph, initialisation and optimisation knobs for
#' ForceAtlas2. `local_connectivity`, `bandwidth`, `init` and `randomised` only
#' apply when the graph is built from the data via [forceatlas2()];
#' [forceatlas2_from_graph()] ignores them.
#'
#' @param local_connectivity Numeric. Number of nearest neighbours assumed to be
#' at distance zero. Defaults to `1.0`.
#' @param bandwidth Numeric. Convergence tolerance for smooth kNN distance
#' binary search. Defaults to `1e-05`.
#' @param n_epochs Integer. Number of optimisation epochs. Defaults to `500L`.
#' @param scaling_ratio Numeric. Repulsion strength. Larger values spread the
#' layout. Defaults to `2.0`.
#' @param gravity Numeric. Pull towards the origin. Keeps disconnected
#' components from drifting off. Defaults to `1.0`.
#' @param strong_gravity Boolean. Distance-independent gravity, scaled by
#' `scaling_ratio`. Defaults to `FALSE`.
#' @param lin_log Boolean. Logarithmic attraction (LinLog). Gives tighter
#' communities. Defaults to `FALSE`.
#' @param dissuade_hubs Boolean. Divide the attraction by the node mass. Pushes
#' hubs to the periphery. Defaults to `FALSE`.
#' @param edge_weight_influence Numeric. Exponent applied to the edge weights.
#' `0` ignores the weights. Defaults to `1.0`.
#' @param jitter_tolerance Numeric. Tolerated swinging. Larger is faster but
#' less precise. Defaults to `1.0`.
#' @param theta Numeric. Barnes-Hut opening parameter on Gephi's scale. `0`
#' gives the exact repulsion. Defaults to `1.2`.
#' @param init String. Embedding initialisation method. One of `c("spectral",
#' "pca", "random")`. Defaults to `"spectral"`.
#' @param randomised Boolean. Use randomised SVD for PCA initialisation.
#' Defaults to `FALSE`.
#'
#' @returns A named list with the following elements:
#' \itemize{
#' \item local_connectivity - Numeric. Number of nearest neighbours assumed to
#' be at distance zero. Defaults to `1.0`.
#' \item bandwidth - Numeric. Convergence tolerance for smooth kNN distance
#' binary search. Defaults to `1e-05`.
#' \item n_epochs - Integer. Number of optimisation epochs. Defaults to `500L`.
#' \item scaling_ratio - Numeric. Repulsion strength. Larger values spread the
#' layout. Defaults to `2.0`.
#' \item gravity - Numeric. Pull towards the origin. Keeps disconnected
#' components from drifting off. Defaults to `1.0`.
#' \item strong_gravity - Boolean. Distance-independent gravity, scaled by
#' `scaling_ratio`. Defaults to `FALSE`.
#' \item lin_log - Boolean. Logarithmic attraction (LinLog). Gives tighter
#' communities. Defaults to `FALSE`.
#' \item dissuade_hubs - Boolean. Divide the attraction by the node mass.
#' Pushes hubs to the periphery. Defaults to `FALSE`.
#' \item edge_weight_influence - Numeric. Exponent applied to the edge weights.
#' `0` ignores the weights. Defaults to `1.0`.
#' \item jitter_tolerance - Numeric. Tolerated swinging. Larger is faster but
#' less precise. Defaults to `1.0`.
#' \item theta - Numeric. Barnes-Hut opening parameter on Gephi's scale. `0`
#' gives the exact repulsion. Defaults to `1.2`.
#' \item init - String. Embedding initialisation method. One of `c("spectral",
#' "pca", "random")`. Defaults to `"spectral"`.
#' \item randomised - Boolean. Use randomised SVD for PCA initialisation.
#' Defaults to `FALSE`.
#' }
#'
#' @references Jacomy, et al., PLoS ONE, 2014
#'
#' @export
params_fa2 <- function(
local_connectivity = 1.0,
bandwidth = 1e-05,
n_epochs = 500L,
scaling_ratio = 2.0,
gravity = 1.0,
strong_gravity = FALSE,
lin_log = FALSE,
dissuade_hubs = FALSE,
edge_weight_influence = 1.0,
jitter_tolerance = 1.0,
theta = 1.2,
init = c("spectral", "pca", "random"),
randomised = FALSE
) {
init <- match.arg(init)
# Checks
checkmate::qassert(local_connectivity, "N1")
checkmate::qassert(bandwidth, "N1")
checkmate::qassert(n_epochs, "I1[1,)")
checkmate::qassert(scaling_ratio, "N1(0,)")
checkmate::qassert(gravity, "N1[0,)")
checkmate::qassert(strong_gravity, "B1")
checkmate::qassert(lin_log, "B1")
checkmate::qassert(dissuade_hubs, "B1")
checkmate::qassert(edge_weight_influence, "N1[0,)")
checkmate::qassert(jitter_tolerance, "N1(0,)")
checkmate::qassert(theta, "N1[0,)")
checkmate::assertChoice(init, c("spectral", "pca", "random"))
checkmate::qassert(randomised, "B1")
# Return
list(
local_connectivity = local_connectivity,
bandwidth = bandwidth,
n_epochs = n_epochs,
scaling_ratio = scaling_ratio,
gravity = gravity,
strong_gravity = strong_gravity,
lin_log = lin_log,
dissuade_hubs = dissuade_hubs,
edge_weight_influence = edge_weight_influence,
jitter_tolerance = jitter_tolerance,
theta = theta,
init = init,
randomised = randomised
)
}
#' Parameters for hierarchical cluster data generation
#'
#' @description For use with [manifold_synthetic_data()].
#'
#' @param n_supergroups Integer. Number of top-level groups. Defaults to `3L`.
#' @param n_subclusts Integer. Number of subclusters per supergroup. Defaults to
#' `3L`.
#' @param supergroup_spread Numeric. Spread of supergroup centres in the ambient
#' space. Defaults to `15.0`.
#' @param subcluster_spread Numeric. Spread of subcluster centres around their
#' supergroup centre. Defaults to `2.0`.
#' @param point_std Numeric. Within-subcluster Gaussian noise. Defaults to
#' `0.4`.
#'
#' @returns A named list with the following elements:
#' \itemize{
#' \item n_supergroups - Integer. Number of top-level groups. Defaults to `3L`.
#' \item n_subclusts - Integer. Number of subclusters per supergroup. Defaults
#' to `3L`.
#' \item supergroup_spread - Numeric. Spread of supergroup centres in the
#' ambient space. Defaults to `15.0`.
#' \item subcluster_spread - Numeric. Spread of subcluster centres around their
#' supergroup centre. Defaults to `2.0`.
#' \item point_std - Numeric. Within-subcluster Gaussian noise. Defaults to
#' `0.4`.
#' }
#'
#' @export
params_hierarchical <- function(
n_supergroups = 3L,
n_subclusts = 3L,
supergroup_spread = 15.0,
subcluster_spread = 2.0,
point_std = 0.4
) {
# Checks
checkmate::qassert(n_supergroups, "I1(1,)")
checkmate::qassert(n_subclusts, "I1(1,)")
checkmate::qassert(supergroup_spread, "N1(0,)")
checkmate::qassert(subcluster_spread, "N1(0,)")
checkmate::qassert(point_std, "N1(0,)")
# Return
list(
n_supergroups = n_supergroups,
n_subclusts = n_subclusts,
supergroup_spread = supergroup_spread,
subcluster_spread = subcluster_spread,
point_std = point_std
)
}
#' Wrapper function to generate k-means parameters
#'
#' @param metric String. Distance metric to use. One of `c("euclidean",
#' "cosine")`. Defaults to `"euclidean"`.
#' @param max_iters Integer. Maximum number of iterations. Defaults to `1000L`.
#' @param batch_size Integer. Mini-batch size. Only used when `method =
#' "minibatch"`. Defaults to `4096L`.
#' @param drift_threshold Numeric. Below which centroid drift the mini-batch
#' k-means is considered converged. Only used when `method = "minibatch"`.
#' Defaults to `1e-04`.
#' @param lr_alpha Numeric. Learning rate decay for the mini-batch k-means.
#' Original paper uses `1.0`. Defaults to `1.0`.
#' @param init String. The initialisation of the centroids. One of
#' `c("parallel", "random")`. Defaults to `"parallel"`.
#' @param use_hamerly Boolean or `NULL`. Shall Hamerly's method be used (only if
#' `metric == "euclidean"`). Defaults to `NULL`.
#' @param use_gemm Boolean or `NULL`. Shall the GEMM path be used. Useful on
#' high dimensional data. If `NULL`, choice will be based on heuristics.
#' Defaults to `NULL`.
#'
#' @returns A named list with the following elements:
#' \itemize{
#' \item metric - String. Distance metric to use. One of `c("euclidean",
#' "cosine")`. Defaults to `"euclidean"`.
#' \item max_iters - Integer. Maximum number of iterations. Defaults to
#' `1000L`.
#' \item batch_size - Integer. Mini-batch size. Only used when `method =
#' "minibatch"`. Defaults to `4096L`.
#' \item drift_threshold - Numeric. Below which centroid drift the mini-batch
#' k-means is considered converged. Only used when `method = "minibatch"`.
#' Defaults to `1e-04`.
#' \item lr_alpha - Numeric. Learning rate decay for the mini-batch k-means.
#' Original paper uses `1.0`. Defaults to `1.0`.
#' \item init - String. The initialisation of the centroids. One of
#' `c("parallel", "random")`. Defaults to `"parallel"`.
#' \item use_hamerly - Boolean or `NULL`. Shall Hamerly's method be used (only
#' if `metric == "euclidean"`). Defaults to `NULL`.
#' \item use_gemm - Boolean or `NULL`. Shall the GEMM path be used. Useful on
#' high dimensional data. If `NULL`, choice will be based on heuristics.
#' Defaults to `NULL`.
#' }
#'
#' @export
params_kmeans <- function(
metric = c("euclidean", "cosine"),
max_iters = 1000L,
batch_size = 4096L,
drift_threshold = 1e-04,
lr_alpha = 1.0,
init = c("parallel", "random"),
use_hamerly = NULL,
use_gemm = NULL
) {
metric <- match.arg(metric)
init <- match.arg(init)
# Checks
checkmate::assertChoice(metric, c("euclidean", "cosine"))
checkmate::qassert(max_iters, "I1[1,)")
checkmate::qassert(batch_size, "I1[1,)")
checkmate::qassert(drift_threshold, "N1")
checkmate::qassert(lr_alpha, "N1")
checkmate::assertChoice(init, c("parallel", "random"))
checkmate::qassert(use_hamerly, c("B1", "0"))
checkmate::qassert(use_gemm, c("B1", "0"))
# Return
list(
metric = metric,
max_iters = max_iters,
batch_size = batch_size,
drift_threshold = drift_threshold,
lr_alpha = lr_alpha,
init = init,
use_hamerly = use_hamerly,
use_gemm = use_gemm
)
}
#' Wrapper function to generate nearest neighbour parameters
#'
#' @param dist_metric String. The distance metric to use. One of `c("euclidean",
#' "cosine")`. Defaults to `"euclidean"`.
#' @param n_tree Integer. Number of trees for Annoy. Defaults to `50L`.
#' @param search_budget Integer or `NULL`. Search budget for Annoy. Defaults to
#' `NULL`.
#' @param m Integer. Number of bidirectional links for HNSW. Defaults to `16L`.
#' @param ef_construction Integer. Size of the dynamic candidate list during
#' HNSW construction. Defaults to `100L`.
#' @param ef_search Integer. Size of the dynamic candidate list during HNSW
#' search. Defaults to `100L`.
#' @param diversify_prob Numeric. Diversification probability for NN descent.
#' Defaults to `0.0`.
#' @param delta Numeric. Precision parameter for NN descent. Defaults to
#' `0.001`.
#' @param ef_budget Integer or `NULL`. Effort budget for NN descent. Ignored
#' when `extract_knn` is `TRUE`, as no search runs. Defaults to `NULL`.
#' @param extract_knn Boolean. Only affects the `"nndescent"` backend. If
#' `TRUE`, the descent hands back the graph it just built instead of running a
#' beam search over it. Faster, at a recall of roughly `0.98` rather than
#' `0.99`-`1.00`. Defaults to `TRUE`.
#' @param bt_budget Numeric. Budget for ball tree search. Defaults to `0.1`.
#' @param n_list Integer or `NULL`. Number of clusters to use for IVF. If
#' `NULL`, uses `sqrt(n)`. Defaults to `NULL`.
#' @param n_probes Integer or `NULL`. Number of clusters to probe for IVF. If
#' `NULL`, uses `sqrt(n_list)`. Defaults to `NULL`.
#'
#' @returns A named list with the following elements:
#' \itemize{
#' \item dist_metric - String. The distance metric to use. One of
#' `c("euclidean", "cosine")`. Defaults to `"euclidean"`.
#' \item n_tree - Integer. Number of trees for Annoy. Defaults to `50L`.
#' \item search_budget - Integer or `NULL`. Search budget for Annoy. Defaults
#' to `NULL`.
#' \item m - Integer. Number of bidirectional links for HNSW. Defaults to
#' `16L`.
#' \item ef_construction - Integer. Size of the dynamic candidate list during
#' HNSW construction. Defaults to `100L`.
#' \item ef_search - Integer. Size of the dynamic candidate list during HNSW
#' search. Defaults to `100L`.
#' \item diversify_prob - Numeric. Diversification probability for NN descent.
#' Defaults to `0.0`.
#' \item delta - Numeric. Precision parameter for NN descent. Defaults to
#' `0.001`.
#' \item ef_budget - Integer or `NULL`. Effort budget for NN descent. Ignored
#' when `extract_knn` is `TRUE`, as no search runs. Defaults to `NULL`.
#' \item extract_knn - Boolean. Only affects the `"nndescent"` backend. If
#' `TRUE`, the descent hands back the graph it just built instead of running a
#' beam search over it. Faster, at a recall of roughly `0.98` rather than
#' `0.99`-`1.00`. Defaults to `TRUE`.
#' \item bt_budget - Numeric. Budget for ball tree search. Defaults to `0.1`.
#' \item n_list - Integer or `NULL`. Number of clusters to use for IVF. If
#' `NULL`, uses `sqrt(n)`. Defaults to `NULL`.
#' \item n_probes - Integer or `NULL`. Number of clusters to probe for IVF. If
#' `NULL`, uses `sqrt(n_list)`. Defaults to `NULL`.
#' }
#'
#' @export
params_nn <- function(
dist_metric = c("euclidean", "cosine"),
n_tree = 50L,
search_budget = NULL,
m = 16L,
ef_construction = 100L,
ef_search = 100L,
diversify_prob = 0.0,
delta = 0.001,
ef_budget = NULL,
extract_knn = TRUE,
bt_budget = 0.1,
n_list = NULL,
n_probes = NULL
) {
dist_metric <- match.arg(dist_metric)
# Checks
checkmate::assertChoice(dist_metric, c("euclidean", "cosine"))
checkmate::qassert(n_tree, "I1")
checkmate::qassert(search_budget, c("I1", "0"))
checkmate::qassert(m, "I1")
checkmate::qassert(ef_construction, "I1")
checkmate::qassert(ef_search, "I1")
checkmate::qassert(diversify_prob, "N1")
checkmate::qassert(delta, "N1")
checkmate::qassert(ef_budget, c("I1", "0"))
checkmate::qassert(extract_knn, "B1")
checkmate::qassert(bt_budget, "N1")
checkmate::qassert(n_list, c("I1", "0"))
checkmate::qassert(n_probes, c("I1", "0"))
# Return
list(
dist_metric = dist_metric,
n_tree = n_tree,
search_budget = search_budget,
m = m,
ef_construction = ef_construction,
ef_search = ef_search,
diversify_prob = diversify_prob,
delta = delta,
ef_budget = ef_budget,
extract_knn = extract_knn,
bt_budget = bt_budget,
n_list = n_list,
n_probes = n_probes
)
}
#' Wrapper function to generate PaCMAP parameters
#'
#' @param n_near Integer. Near pairs per point (attractive). Defaults to `10L`.
#' @param n_mid_near Integer. Mid-near pairs per point. Defaults to `5L`.
#' @param n_further Integer. Further (random) pairs per point. Defaults to
#' `20L`.
#' @param mn_candidate_start Integer. Start index into kNN list for mid-near
#' candidate window. Defaults to `4L`.
#' @param mn_candidate_end Integer. End index into kNN list for mid-near
#' candidate window. Also determines the kNN search size. Defaults to `50L`.
#' @param init String. Embedding initialisation. One of `c("pca", "random")`.
#' Defaults to `"pca"`.
#' @param optimiser String. The optimiser. One of `c("adam_parallel", "adam")`.
#' Defaults to `"adam_parallel"`.
#' @param lr Numeric. Adam learning rate. Defaults to `1.0`.
#' @param n_epochs Integer or `NULL`. Total optimisation epochs. If `NULL`,
#' resolved downstream to `450`. Defaults to `NULL`.
#' @param beta1 Numeric. Adam first moment decay. Defaults to `0.9`.
#' @param beta2 Numeric. Adam second moment decay. Defaults to `0.999`.
#' @param eps Numeric. Adam numerical stability constant. Defaults to `1e-07`.
#' @param phase1_end Integer or `NULL`. Epoch at which phase 1 ends. If `NULL`,
#' resolved downstream to `100`. Defaults to `NULL`.
#' @param phase2_end Integer or `NULL`. Epoch at which phase 2 ends. If `NULL`,
#' resolved downstream to `200`. Defaults to `NULL`.
#'
#' @returns A named list with the following elements:
#' \itemize{
#' \item n_near - Integer. Near pairs per point (attractive). Defaults to
#' `10L`.
#' \item n_mid_near - Integer. Mid-near pairs per point. Defaults to `5L`.
#' \item n_further - Integer. Further (random) pairs per point. Defaults to
#' `20L`.
#' \item mn_candidate_start - Integer. Start index into kNN list for mid-near
#' candidate window. Defaults to `4L`.
#' \item mn_candidate_end - Integer. End index into kNN list for mid-near
#' candidate window. Also determines the kNN search size. Defaults to `50L`.
#' \item init - String. Embedding initialisation. One of `c("pca", "random")`.
#' Defaults to `"pca"`.
#' \item optimiser - String. The optimiser. One of `c("adam_parallel",
#' "adam")`. Defaults to `"adam_parallel"`.
#' \item lr - Numeric. Adam learning rate. Defaults to `1.0`.
#' \item n_epochs - Integer or `NULL`. Total optimisation epochs. If `NULL`,
#' resolved downstream to `450`. Defaults to `NULL`.
#' \item beta1 - Numeric. Adam first moment decay. Defaults to `0.9`.
#' \item beta2 - Numeric. Adam second moment decay. Defaults to `0.999`.
#' \item eps - Numeric. Adam numerical stability constant. Defaults to `1e-07`.
#' \item phase1_end - Integer or `NULL`. Epoch at which phase 1 ends. If
#' `NULL`, resolved downstream to `100`. Defaults to `NULL`.
#' \item phase2_end - Integer or `NULL`. Epoch at which phase 2 ends. If
#' `NULL`, resolved downstream to `200`. Defaults to `NULL`.
#' }
#'
#' @export
params_pacmap <- function(
n_near = 10L,
n_mid_near = 5L,
n_further = 20L,
mn_candidate_start = 4L,
mn_candidate_end = 50L,
init = c("pca", "random"),
optimiser = c("adam_parallel", "adam"),
lr = 1.0,
n_epochs = NULL,
beta1 = 0.9,
beta2 = 0.999,
eps = 1e-07,
phase1_end = NULL,
phase2_end = NULL
) {
init <- match.arg(init)
optimiser <- match.arg(optimiser)
# Checks
checkmate::qassert(n_near, "I1")
checkmate::qassert(n_mid_near, "I1")
checkmate::qassert(n_further, "I1")
checkmate::qassert(mn_candidate_start, "I1")
checkmate::qassert(mn_candidate_end, "I1")
checkmate::assertChoice(init, c("pca", "random"))
checkmate::assertChoice(optimiser, c("adam_parallel", "adam"))
checkmate::qassert(lr, "N1")
checkmate::qassert(n_epochs, c("I1[1,)", "0"))
checkmate::qassert(beta1, "N1")
checkmate::qassert(beta2, "N1")
checkmate::qassert(eps, "N1")
checkmate::qassert(phase1_end, c("I1[1,)", "0"))
checkmate::qassert(phase2_end, c("I1[1,)", "0"))
# Return
list(
n_near = n_near,
n_mid_near = n_mid_near,
n_further = n_further,
mn_candidate_start = mn_candidate_start,
mn_candidate_end = mn_candidate_end,
init = init,
optimiser = optimiser,
lr = lr,
n_epochs = n_epochs,
beta1 = beta1,
beta2 = beta2,
eps = eps,
phase1_end = phase1_end,
phase2_end = phase2_end
)
}
#' Wrapper function to generate PHATE parameters
#'
#' @param decay Numeric. Alpha decay parameter controlling the kernel bandwidth.
#' Higher values create sharper transitions. Defaults to `40.0`.
#' @param bandwidth_scale Numeric or `NULL`. Scaling factor applied to the
#' kernel bandwidth. If `NULL`, the library selects a sensible default. Defaults
#' to `NULL`.
#' @param t_max Integer. Maximum diffusion time considered during automatic
#' selection via Von Neumann entropy knee point detection. Defaults to `100L`.
#' @param t_custom Integer or `NULL`. Fixed diffusion time. If set, overrides
#' automatic time selection. Defaults to `NULL`.
#' @param gamma Numeric. Informational distance parameter for the diffusion
#' potential. Defaults to `1.0`.
#' @param n_landmarks Integer or `NULL`. Number of landmarks for compressed
#' diffusion. If `NULL`, the full N x N diffusion operator is used. Defaults to
#' `2048L`.
#' @param landmark_method String. Method used to select landmarks. One of
#' `c("spectral", "random", "density")`. Defaults to `"spectral"`.
#' @param n_svd Integer or `NULL`. Number of SVD components used in landmark
#' construction. If `NULL`, the library selects a sensible default. Defaults to
#' `NULL`.
#' @param mds_method String. MDS algorithm used for the final embedding. One of
#' `c("sgd_dense", "classic")`. Defaults to `"sgd_dense"`.
#' @param graph_symmetry String. Method used to symmetrise the affinity graph.
#' One of `c("additive", "multiplicative", "mnn", "none")`. Defaults to
#' `"additive"`.
#'
#' @returns A named list with the following elements:
#' \itemize{
#' \item decay - Numeric. Alpha decay parameter controlling the kernel
#' bandwidth. Higher values create sharper transitions. Defaults to `40.0`.
#' \item bandwidth_scale - Numeric or `NULL`. Scaling factor applied to the
#' kernel bandwidth. If `NULL`, the library selects a sensible default.
#' Defaults to `NULL`.
#' \item t_max - Integer. Maximum diffusion time considered during automatic
#' selection via Von Neumann entropy knee point detection. Defaults to `100L`.
#' \item t_custom - Integer or `NULL`. Fixed diffusion time. If set, overrides
#' automatic time selection. Defaults to `NULL`.
#' \item gamma - Numeric. Informational distance parameter for the diffusion
#' potential. Defaults to `1.0`.
#' \item n_landmarks - Integer or `NULL`. Number of landmarks for compressed
#' diffusion. If `NULL`, the full N x N diffusion operator is used. Defaults to
#' `2048L`.
#' \item landmark_method - String. Method used to select landmarks. One of
#' `c("spectral", "random", "density")`. Defaults to `"spectral"`.
#' \item n_svd - Integer or `NULL`. Number of SVD components used in landmark
#' construction. If `NULL`, the library selects a sensible default. Defaults to
#' `NULL`.
#' \item mds_method - String. MDS algorithm used for the final embedding. One
#' of `c("sgd_dense", "classic")`. Defaults to `"sgd_dense"`.
#' \item graph_symmetry - String. Method used to symmetrise the affinity graph.
#' One of `c("additive", "multiplicative", "mnn", "none")`. Defaults to
#' `"additive"`.
#' }
#'
#' @export
params_phate <- function(
decay = 40.0,
bandwidth_scale = NULL,
t_max = 100L,
t_custom = NULL,
gamma = 1.0,
n_landmarks = 2048L,
landmark_method = c("spectral", "random", "density"),
n_svd = NULL,
mds_method = c("sgd_dense", "classic"),
graph_symmetry = c("additive", "multiplicative", "mnn", "none")
) {
landmark_method <- match.arg(landmark_method)
mds_method <- match.arg(mds_method)
graph_symmetry <- match.arg(graph_symmetry)
# Checks
checkmate::qassert(decay, "N1(0,)")
checkmate::qassert(bandwidth_scale, c("N1(0,)", "0"))
checkmate::qassert(t_max, "I1[1,)")
checkmate::qassert(t_custom, c("I1[1,)", "0"))
checkmate::qassert(gamma, "N1")
checkmate::qassert(n_landmarks, c("I1[1,)", "0"))
checkmate::assertChoice(landmark_method, c("spectral", "random", "density"))
checkmate::qassert(n_svd, c("I1[1,)", "0"))
checkmate::assertChoice(mds_method, c("sgd_dense", "classic"))
checkmate::assertChoice(
graph_symmetry,
c("additive", "multiplicative", "mnn", "none")
)
# Return
list(
decay = decay,
bandwidth_scale = bandwidth_scale,
t_max = t_max,
t_custom = t_custom,
gamma = gamma,
n_landmarks = n_landmarks,
landmark_method = landmark_method,
n_svd = n_svd,
mds_method = mds_method,
graph_symmetry = graph_symmetry
)
}
#' Parameters for swiss roll data generation
#'
#' @description For use with [manifold_synthetic_data()].
#'
#' @param noise Numeric. Amount of noise to add. Defaults to `0.1`.
#'
#' @returns A named list with the following elements:
#' \itemize{
#' \item noise - Numeric. Amount of noise to add. Defaults to `0.1`.
#' }
#'
#' @export
params_swiss_roll <- function(
noise = 0.1
) {
# Checks
checkmate::qassert(noise, "N1(0,)")
# Return
list(
noise = noise
)
}
#' Parameters for biased swiss roll data generation
#'
#' @description For use with [manifold_synthetic_data()].
#'
#' @param noise Numeric. Amount of noise to add. Defaults to `0.1`.
#' @param bias Numeric. The sampling bias across the manifold. Defaults to
#' `2.5`.
#'
#' @returns A named list with the following elements:
#' \itemize{
#' \item noise - Numeric. Amount of noise to add. Defaults to `0.1`.
#' \item bias - Numeric. The sampling bias across the manifold. Defaults to
#' `2.5`.
#' }
#'
#' @export
params_swiss_roll_biased <- function(
noise = 0.1,
bias = 2.5
) {
# Checks
checkmate::qassert(noise, "N1(0,)")
checkmate::qassert(bias, "N1(0,)")
# Return
list(
noise = noise,
bias = bias
)
}
#' Parameters for trajectory data generation
#'
#' @description For use with [manifold_synthetic_data()].
#'
#' @param topology String. Ignored if `cell_trajectories` is not `NULL`. One of
#' `c("bifurcation", "linear", "combination")`. Defaults to `"bifurcation"`.
#' @param cell_trajectories Any. Optional named list with three equal-length
#' vectors: `parent` (integer, `NA` for root, zero-indexed), `split_at`
#' (numeric, fraction along parent where branch starts), and `length` (numeric,
#' length of the branch). If `NULL`, `topology` is used instead. Defaults to
#' `NULL`.
#' @param noise Numeric. Amount of noise to add. Defaults to `0.1`.
#'
#' @returns A named list with the following elements:
#' \itemize{
#' \item topology - String. Ignored if `cell_trajectories` is not `NULL`. One
#' of `c("bifurcation", "linear", "combination")`. Defaults to `"bifurcation"`.
#' \item cell_trajectories - Any. Optional named list with three equal-length
#' vectors: `parent` (integer, `NA` for root, zero-indexed), `split_at`
#' (numeric, fraction along parent where branch starts), and `length` (numeric,
#' length of the branch). If `NULL`, `topology` is used instead. Defaults to
#' `NULL`.
#' \item noise - Numeric. Amount of noise to add. Defaults to `0.1`.
#' }
#'
#' @export
params_trajectory <- function(
topology = c("bifurcation", "linear", "combination"),
cell_trajectories = NULL,
noise = 0.1
) {
topology <- match.arg(topology)
# Checks
checkmate::assertChoice(topology, c("bifurcation", "linear", "combination"))
checkmate::qassert(noise, "N1(0,)")
if (!is.null(cell_trajectories)) {
assertCellTrajectories(cell_trajectories)
}
# Return
list(
topology = topology,
cell_trajectories = cell_trajectories,
noise = noise
)
}
#' Wrapper function to generate t-SNE parameters
#'
#' @param lr Numeric or `NULL`. Learning rate. If `NULL`, the Rust backend sets
#' it to `max((n_samples / 12), 200)`, following the N-dependent heuristic of
#' Belkina et al. (2019). Defaults to `NULL`.
#' @param n_epochs Integer. Number of optimisation epochs. Defaults to `1000L`.
#' @param early_exag_iter Integer. Number of early exaggeration iterations.
#' Defaults to `250L`.
#' @param early_exag_factor Numeric. Early exaggeration factor. Defaults to
#' `12.0`.
#' @param late_exag_factor Numeric or `NULL`. Late exaggeration factor, if you
#' wish to use one. Can be useful on large data sets (set it to `2.0` to `4.0`).
#' Defaults to `NULL`.
#' @param theta Numeric. Barnes-Hut approximation angle. Lower values increase
#' accuracy at the cost of speed. Defaults to `0.5`.
#' @param n_interp_points Integer. Number of interpolation points per grid cell
#' for FFT acceleration (`"fft"` and `"fft_3k"`). Defaults to `3L`.
#' @param max_depth Integer. Maximum Barnes-Hut tree depth for the
#' quick-and-dirty optimiser (`"bh_qd"`). Smaller is faster and coarser; qdtsne
#' recommends `7` to `10`. No effect on the other optimisers. Defaults to `7L`.
#' @param init String. Embedding initialisation method. One of `c("pca",
#' "spectral", "random")`. Defaults to `"pca"`.
#' @param randomised Boolean. Use randomised SVD for PCA initialisation.
#' Defaults to `TRUE`.
#'
#' @returns A named list with the following elements:
#' \itemize{
#' \item lr - Numeric or `NULL`. Learning rate. If `NULL`, the Rust backend
#' sets it to `max((n_samples / 12), 200)`, following the N-dependent heuristic
#' of Belkina et al. (2019). Defaults to `NULL`.
#' \item n_epochs - Integer. Number of optimisation epochs. Defaults to
#' `1000L`.
#' \item early_exag_iter - Integer. Number of early exaggeration iterations.
#' Defaults to `250L`.
#' \item early_exag_factor - Numeric. Early exaggeration factor. Defaults to
#' `12.0`.
#' \item late_exag_factor - Numeric or `NULL`. Late exaggeration factor, if you
#' wish to use one. Can be useful on large data sets (set it to `2.0` to
#' `4.0`). Defaults to `NULL`.
#' \item theta - Numeric. Barnes-Hut approximation angle. Lower values increase
#' accuracy at the cost of speed. Defaults to `0.5`.
#' \item n_interp_points - Integer. Number of interpolation points per grid
#' cell for FFT acceleration (`"fft"` and `"fft_3k"`). Defaults to `3L`.
#' \item max_depth - Integer. Maximum Barnes-Hut tree depth for the
#' quick-and-dirty optimiser (`"bh_qd"`). Smaller is faster and coarser; qdtsne
#' recommends `7` to `10`. No effect on the other optimisers. Defaults to `7L`.
#' \item init - String. Embedding initialisation method. One of `c("pca",
#' "spectral", "random")`. Defaults to `"pca"`.
#' \item randomised - Boolean. Use randomised SVD for PCA initialisation.
#' Defaults to `TRUE`.
#' }
#'
#' @references Belkina, et al., Nat. Commun., 2019
#'
#' @export
params_tsne <- function(
lr = NULL,
n_epochs = 1000L,
early_exag_iter = 250L,
early_exag_factor = 12.0,
late_exag_factor = NULL,
theta = 0.5,
n_interp_points = 3L,
max_depth = 7L,
init = c("pca", "spectral", "random"),
randomised = TRUE
) {
init <- match.arg(init)
# Checks
checkmate::qassert(lr, c("N1", "0"))
checkmate::qassert(n_epochs, "I1[1,)")
checkmate::qassert(early_exag_iter, "I1[1,)")
checkmate::qassert(early_exag_factor, "N1")
checkmate::qassert(late_exag_factor, c("N1", "0"))
checkmate::qassert(theta, "N1[0,1]")
checkmate::qassert(n_interp_points, "I1[1,)")
checkmate::qassert(max_depth, "I1[1,)")
checkmate::assertChoice(init, c("pca", "spectral", "random"))
checkmate::qassert(randomised, "B1")
# Return
list(
lr = lr,
n_epochs = n_epochs,
early_exag_iter = early_exag_iter,
early_exag_factor = early_exag_factor,
late_exag_factor = late_exag_factor,
theta = theta,
n_interp_points = n_interp_points,
max_depth = max_depth,
init = init,
randomised = randomised
)
}
#' Wrapper function to generate UMAP parameters
#'
#' @param local_connectivity Numeric. Number of nearest neighbours assumed to be
#' at distance zero. Defaults to `1.0`.
#' @param bandwidth Numeric. Convergence tolerance for smooth kNN distance
#' binary search. Defaults to `1e-05`.
#' @param mix_weight Numeric. Balance between fuzzy union and directed graph
#' during symmetrisation. Defaults to `1.0`.
#' @param lr Numeric. Learning rate. Defaults to `1.0`.
#' @param n_epochs Integer or `NULL`. Number of optimisation epochs. If `NULL`,
#' resolved downstream based on data size. Defaults to `NULL`.
#' @param neg_sample_rate Integer. Number of negative samples per positive
#' sample. Defaults to `5L`.
#' @param gamma Numeric. Repulsion strength. Defaults to `1.0`.
#' @param optimiser String. The optimiser. One of `c("adam_parallel", "sgd",
#' "adam")`. Defaults to `"adam_parallel"`.
#' @param init String. Embedding initialisation method. One of `c("spectral",
#' "pca", "random")`. Defaults to `"spectral"`.
#' @param randomised Boolean. Use randomised SVD for PCA initialisation.
#' Defaults to `TRUE`.
#'
#' @returns A named list with the following elements:
#' \itemize{
#' \item local_connectivity - Numeric. Number of nearest neighbours assumed to
#' be at distance zero. Defaults to `1.0`.
#' \item bandwidth - Numeric. Convergence tolerance for smooth kNN distance
#' binary search. Defaults to `1e-05`.
#' \item mix_weight - Numeric. Balance between fuzzy union and directed graph
#' during symmetrisation. Defaults to `1.0`.
#' \item lr - Numeric. Learning rate. Defaults to `1.0`.
#' \item n_epochs - Integer or `NULL`. Number of optimisation epochs. If
#' `NULL`, resolved downstream based on data size. Defaults to `NULL`.
#' \item neg_sample_rate - Integer. Number of negative samples per positive
#' sample. Defaults to `5L`.
#' \item gamma - Numeric. Repulsion strength. Defaults to `1.0`.
#' \item optimiser - String. The optimiser. One of `c("adam_parallel", "sgd",
#' "adam")`. Defaults to `"adam_parallel"`.
#' \item init - String. Embedding initialisation method. One of `c("spectral",
#' "pca", "random")`. Defaults to `"spectral"`.
#' \item randomised - Boolean. Use randomised SVD for PCA initialisation.
#' Defaults to `TRUE`.
#' }
#'
#' @export
params_umap <- function(
local_connectivity = 1.0,
bandwidth = 1e-05,
mix_weight = 1.0,
lr = 1.0,
n_epochs = NULL,
neg_sample_rate = 5L,
gamma = 1.0,
optimiser = c("adam_parallel", "sgd", "adam"),
init = c("spectral", "pca", "random"),
randomised = TRUE
) {
optimiser <- match.arg(optimiser)
init <- match.arg(init)
# Checks
checkmate::qassert(local_connectivity, "N1")
checkmate::qassert(bandwidth, "N1")
checkmate::qassert(mix_weight, "N1")
checkmate::qassert(lr, "N1")
checkmate::qassert(n_epochs, c("I1[1,)", "0"))
checkmate::qassert(neg_sample_rate, "I1")
checkmate::qassert(gamma, "N1")
checkmate::assertChoice(optimiser, c("adam_parallel", "sgd", "adam"))
checkmate::assertChoice(init, c("spectral", "pca", "random"))
checkmate::qassert(randomised, "B1")
# Return
list(
local_connectivity = local_connectivity,
bandwidth = bandwidth,
mix_weight = mix_weight,
lr = lr,
n_epochs = n_epochs,
neg_sample_rate = neg_sample_rate,
gamma = gamma,
optimiser = optimiser,
init = init,
randomised = randomised
)
}
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.