Description Usage Arguments Value Examples
View source: R/downsample_data.R
Downsample the training data.
1 | downsample_data(data_list, n0_train, n1_train, seed = NULL)
|
data_list |
data list you want to downsample(including train_x, train_y and test_x) |
n0_train |
Int, represents the absolute number of class 0 training data. |
n1_train |
Int, represents the absolute number of class 1 training data. |
the downsampled data
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | library(mvtnorm)
library(MASS)
df = 10
rho = 0.5
d = 5
delta = rep(2, d)
H <- abs(outer(1:d, 1:d, "-"))
covxx = rho^H
n1_all <- n0_all <- 800
n1_p <- n0_p <- 15
x0_all = rmvt(n = n0_all, sigma = covxx, delta = rep(0, d), df = df)
x1_all = rmvt(n = n1_all, sigma = covxx, delta = delta, df = df)
x_data = rbind(x0_all, x1_all)
y_data = c(rep(0, n0_all), rep(1, n1_all))
id0 <- which(y_data == 0)
id1 <- which(y_data == 1)
id0_p <- sample(id0, n0_p)
id1_p <- sample(id1, n1_p)
id_p <- c(id0_p, id1_p)
x_pilot <- as.matrix(x_data[id_p, ])
y_pilot <- as.matrix(y_data[id_p])
n1_train <- n0_train <- n_train <- 150
n0_test <- n1_test <- 300
data_list = pilot_tfe_mvnorm_pca2(x_pilot, y_pilot, n0_train, n1_train, n0_test,
n1_test)
data_list_ds = downsample_data(data_list, n0_train = 30, n1_train = 30, seed = 1)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.