| create_data_nuggets | R Documentation |
create_data_nuggets compresses n observations into
M <= n representative "nuggets". Each nugget stores a centre
(location), a weight (the number of member observations) and a scale
(within-nugget variability). Data nuggets preserve the covariance structure
of the data - including the periphery - far better than a random sub-sample,
which makes them a robust, memory-light surrogate for the full data set when
clustering or computing feature weights.
create_data_nuggets(
x,
max_nuggets = NULL,
min_size = 1L,
engine = c("native", "datanugget"),
scale_features = TRUE,
seed = NULL,
...
)
x |
A numeric matrix or data frame with observations in the rows and variables in the columns. |
max_nuggets |
Target (maximum) number of nuggets |
min_size |
Minimum number of observations per nugget (native engine
only). Defaults to |
engine |
Either |
scale_features |
Logical; if |
seed |
Optional integer seed for reproducible partitioning. |
... |
Additional arguments forwarded to
|
With the native engine the number of nuggets defaults to
min(nrow(x), max(2, floor(nrow(x) / 10))) when n > 50, and to
n otherwise (in which case every observation is its own nugget and the
nugget-weighted variance reduces to the ordinary variance - a safe fallback
for small samples). The partition is obtained with stats::kmeans;
missing values are mean-imputed for the partition step only.
An object of class "data_nugget": a list with elements
centers |
|
weights |
Length- |
scales |
|
membership |
Length- |
x_scale |
Length- |
engine |
The engine used. |
Cherasia2023MosaiClusteR
\insertRefWCluster2025MosaiClusteR
nugget_feature_weights, M_ABC
set.seed(1)
x <- rbind(matrix(rnorm(200 * 5, 0), ncol = 5),
matrix(rnorm(200 * 5, 4), ncol = 5))
dn <- create_data_nuggets(x, max_nuggets = 40)
dn
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.