View source: R/generate_simulation.R
| simulate_mixsim | R Documentation |
Generates synthetic classification data using Gaussian mixture models constructed by
the MixSim package. Useful for creating controlled datasets to explore decision
boundary behavior when no real dataset is available.
simulate_mixsim(
n,
K,
p,
MaxOmega,
class_names = NULL,
seed = NULL,
noise_ratio = 0,
test_ratio = 0
)
n |
Number of training observations to generate. |
K |
Number of classes. |
p |
Number of numeric features (dimensions). |
MaxOmega |
Maximum pairwise overlap between mixture components (0 to 1). Smaller values create better-separated classes. |
class_names |
Optional character vector of class labels (length |
seed |
Optional integer for reproducibility. The global random seed is restored after the call. |
noise_ratio |
Numeric in [0, 1). Proportion of |
test_ratio |
Numeric in [0, 1). If greater than 0, generates an additional
independent test dataset of size |
Class distributions are randomly generated subject to the MaxOmega overlap
constraint. The simulation is fully reproducible when seed is supplied.
When test_ratio > 0, an additional independent dataset is generated using the
same mixture parameters but a fresh random draw. This is not a split of the
training data: the training set has n observations and the test set has
round(n * test_ratio) independently generated observations. The two sets are
statistically independent, so the test set is a fair evaluation sample.
If test_ratio == 0 (default): a data frame with a Sim class column and
p feature columns (X1, X2, ...). If test_ratio > 0: a list with $train
and $test data frames.
simu_n()
# Generate a 3-class, 2-dimensional training dataset
train_df <- simulate_mixsim(n = 200, K = 3, p = 2, MaxOmega = 0.05, seed = 42)
head(train_df)
# Generate training and independent test data
sim <- simulate_mixsim(
n = 200, K = 3, p = 2, MaxOmega = 0.05,
seed = 42, test_ratio = 0.3
)
nrow(sim$train) # 200
nrow(sim$test) # 60 (independently generated, not split from train)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.