set.seed(123)
n <- 100
n_pos <- round(0.2 * n)
n_neg <- n - n_pos
X <- rbind(
matrix(rnorm(2 * n_neg, mean = -1), ncol = 2),
matrix(rnorm(2 * n_pos, mean = 1), ncol = 2)
)
y <- c(rep(-1, n_neg), rep(1, n_pos))
cvfit <- cv.roclearn(
X, y,lambda.vec = exp(seq(log(0.01), log(5), length.out = 3)),
approx=TRUE, nfolds = 2)
plot(cvfit)
Run the code above in your browser using DataLab