Build a family of measures that differ by one parameter
Source:R/precise_func_fact.R
precise_func_fact.RdReturns a named list of measure functions differing only in one backend
parameter, for the dist_funcs argument of precise_dist(). Each function
carries the type its backend produces, so the resulting rows are typed rather
than NA.
Value
A named list of functions to pass to the dist_funcs argument of
precise_dist().
Parameter mapping by factory
rbfandlaplacebuild kernlab kernels, andparamsis the sigma ofkernlab::rbfdot()orkernlab::laplacedot(). Both return an affinity.minkowskicallsproxy::dist(), andparamsis the power. It returns a distance.random_forestcalls randomForest withntree = 1501,nodesize = 1, andoob.prox = FALSE, andparamsismtry. It returns1 - proximityas a distance with a zero diagonal.kodamacallsKODAMA::KODAMA.matrix(), andparamsisncomp. It returns a distance and requires the optional KODAMA package.kodama_knnandkodama_plsare accepted names for the same factory.tsnerunsmmtsne::x2p()at eachparamsvalue as the perplexity and passes the result tommtsne::p2sp(). It returns an affinity, which has no automatic distance conversion.
Each element is named <func>_<param>, and those names become the display
keys of the precise_dist() result.
KODAMA control arguments
... is accepted only by the KODAMA factories, which pass M, Tcycle,
metrics, landmarks, n.cores, and seed to the backend. Any other name
is an error. metrics accepts "euclidean" or "manhattan", and seed
defaults to 1234. The adapter suppresses the backend's progress output and
restores the session random-number state on exit.
References
Karatzoglou A, Smola A, Hornik K, Zeileis A (2004). kernlab: an S4 package for kernel methods in R. Journal of Statistical Software, 11(9), 1–20. doi:10.18637/jss.v011.i09 .
Liaw A, Wiener M (2002). Classification and regression by randomForest. R News, 2(3), 18–22.
Cacciatore S, Luchinat C, Tenori L (2014). Knowledge discovery by accuracy maximization. Proceedings of the National Academy of Sciences, 111(14), 5117–5122. doi:10.1073/pnas.1220873111 .
See also
precise_dist() to run the family, and precise_dist_list() for
the measures that are already registered.
Examples
data(data_cell_cycle, package = "PreciseDist")
cells <- c(1:4, 60:63, 118:121)
cell_cycle <- as.matrix(data_cell_cycle[cells, 2:41])
rownames(cell_cycle) <- paste0(data_cell_cycle$Cell_cycle[cells], "_", cells)
minkowski_family <- precise_func_fact(
func = "minkowski",
params = c(0.5, 0.75, 1, 1.5)
)
names(minkowski_family)
#> [1] "minkowski_0.5" "minkowski_0.75" "minkowski_1" "minkowski_1.5"
# Factory names become the display keys, and the rows are typed.
swept <- precise_dist(
cell_cycle,
dist_funcs = minkowski_family,
verbose = FALSE
)
swept[, c("distance", "metric", "type")]
#> # A tibble: 4 × 3
#> distance metric type
#> <chr> <chr> <chr>
#> 1 minkowski_0.5 NA distance
#> 2 minkowski_0.75 NA distance
#> 3 minkowski_1 NA distance
#> 4 minkowski_1.5 NA distance