Description Usage Arguments Value Examples
View source: R/pilot_tfe_smote.R
Use SMOTE to generate data.
1 | pilot_tfe_smote(x_pilot, y_pilot, n0_train, n1_train, n0_test, n1_test)
|
x_pilot |
input variables of pilot data |
y_pilot |
labels of pilot data |
n0_train |
the number of training data of class 0 |
n1_train |
the number of training data of class 1 |
n0_test |
the number of test data of class 0 |
n1_test |
the number of test data of class 1 |
the generated data list including train_x, train_y and test_x
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 | 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 <- 60
n0_test <- n1_test <- 300
data_list = pilot_tfe_smote(x_pilot, y_pilot, n0_train, n1_train, n0_test, n1_test)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.