weighted_group_means | R Documentation |
Given a data matrix X
(size n x d
) and a class-weight matrix F
(size c x n
),
this function computes the weighted means of X
for each class.
Unlike hard (0/1) assignments, each sample contributes partially to each class's mean
according to its weight.
weighted_group_means(X, F)
X |
A numeric matrix of shape |
F |
A numeric matrix of shape |
A numeric matrix of shape c x d
, where each row is the weighted mean of X
for one class.
# Suppose we have 5 samples (rows), 2 features (cols),
# and 3 classes. F has shape (3 x 5).
X <- matrix(1:10, nrow=5, ncol=2)
F <- matrix(runif(3*5, min=0, max=1), nrow=3)
# Ensure each row of F sums to something > 0
res_means <- weighted_group_means(X, F)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.