supclass | R Documentation |
Experimental implementations of multi-category classifiers with sup-norm penalties proposed by Zhang, et al. (2008) and Li & Zhang (2021).
supclass( x, y, model = c("logistic", "psvm", "svm"), penalty = c("lasso", "scad"), start = NULL, control = list(), ... ) supclass.control( lambda = 0.1, adaptive_weight = NULL, scad_a = 3.7, maxit = 50, epsilon = 1e-04, shrinkage = 1e-04, warm_start = TRUE, standardize = TRUE, verbose = 0L, ... )
x |
A numeric matrix representing the design matrix. No missing valus
are allowed. The coefficient estimates for constant columns will be
zero. Thus, one should set the argument |
y |
An integer vector, a character vector, or a factor vector representing the response label. |
model |
A charactor vector specifying the classification model. The
available options are |
penalty |
A charactor vector specifying the penalty function for the
sup-norms. The available options are |
start |
A numeric matrix representing the starting values for the quadratic approximation procedure behind the scene. |
control |
A list with named elements. |
... |
Optional control parameters passed to the
|
lambda |
A numeric vector specifying the tuning parameter
lambda. The default value is |
adaptive_weight |
A numeric vector or matrix representing the adaptive
penalty weights. The default value is |
scad_a |
A positive number specifying the tuning parameter a in the SCAD penalty. |
maxit |
A positive integer specifying the maximum number of iteration.
The default value is |
epsilon |
A positive number specifying the relative tolerance that
determines convergence. The default value is |
shrinkage |
A nonnegative tolerance to shrink estimates with sup-norm
close enough to zero (within the specified tolerance) to zeros. The
default value is |
warm_start |
A logical value indicating if the estimates from last
lambda should be used as the starting values for the next lambda. If
|
standardize |
A logical value indicating if a standardization procedure should be performed so that each column of the design matrix has mean zero and standardization |
verbose |
A nonnegative integer specifying if the estimation procedure
is allowed to print out intermediate steps/results. The default value
is |
For the multinomial logistic model or the proximal SVM model, this function
utilizes the function quadprog::solve.QP()
to solve the equivalent
quadratic problem; For the multi-class SVM, this function utilizes GNU GLPK
to solve the equivalent linear programming problem via the package Rglpk.
It is recommended to use a recent version of GLPK.
Zhang, H. H., Liu, Y., Wu, Y., & Zhu, J. (2008). Variable selection for the multicategory SVM via adaptive sup-norm regularization. Electronic Journal of Statistics, 2, 149–167.
Li, N., & Zhang, H. H. (2021). Sparse learning with non-convex penalty in multi-classification. Journal of Data Science, 19(1), 56–74.
library(abclass) set.seed(123) ## toy examples for demonstration purpose ## reference: example 1 in Zhang and Liu (2014) ntrain <- 100 # size of training set ntest <- 1000 # size of testing set p0 <- 2 # number of actual predictors p1 <- 2 # number of random predictors k <- 3 # number of categories n <- ntrain + ntest; p <- p0 + p1 train_idx <- seq_len(ntrain) y <- sample(k, size = n, replace = TRUE) # response mu <- matrix(rnorm(p0 * k), nrow = k, ncol = p0) # mean vector ## normalize the mean vector so that they are distributed on the unit circle mu <- mu / apply(mu, 1, function(a) sqrt(sum(a ^ 2))) x0 <- t(sapply(y, function(i) rnorm(p0, mean = mu[i, ], sd = 0.25))) x1 <- matrix(rnorm(p1 * n, sd = 0.3), nrow = n, ncol = p1) x <- cbind(x0, x1) train_x <- x[train_idx, ] test_x <- x[- train_idx, ] y <- factor(paste0("label_", y)) train_y <- y[train_idx] test_y <- y[- train_idx] ## regularization with the supnorm lasso penalty options("mc.cores" = 1) model <- supclass(train_x, train_y, model = "psvm", penalty = "lasso") pred <- predict(model, test_x) table(test_y, pred) mean(test_y == pred) # accuracy
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.