sramsvm: Structured angle-based multicategory support vector machine...

Description Usage Arguments Value Examples

View source: R/sramsvm.R

Description

Fit a structured angle-based multicategory support vector machine with reinforced multicategory loss.

Usage

1
2
3
4
5
6
7
sramsvm(x = NULL, y, gamma = 0.5, valid_x = NULL, valid_y = NULL, nfolds = 5,
	 lambda_seq = 2^{seq(-10, 10, length.out = 100)},
	 lambda_theta_seq = 2^{seq(-10, 10, length.out = 100)},
	 kernel = c("linear", "gaussian", "gaussian2", "poly", "spline", "spline2", "spline-t"), kparam = 1,
	 scale = FALSE, criterion = c("0-1", "loss"),
	 isCombined = FALSE, cv_type = c("original", "osr"), type = c("type1", "type2"), 
	 optModel = FALSE, nCores = 1, verbose = 1, ...)

Arguments

x

A n x p data matrix, where n is the number of observations and p is the number of variables.

y

A response variable with three and more labels.

gamma

The convex combination parameter of the loss function.

valid_x

A validation data matrix for selecting lambda and threshold parameter v (optional). If valid_x=NULL, nfolds-fold cross-validation is performed.

valid_y

A validation response vector (optional).

nfolds

The number of folds for cross-validation.

lambda_seq

A sequence of regularization parameter to control a level of l_2-penalty.

lambda_theta_seq

A sequence of regularization parameter on theta's, which are weights for kernels.

kernel

A character string representing one of type of kernel.

kparam

A parameter needed for kernel.

scale

A logical indicating the variables to be scaled.

criterion

A type of criterion evaluating prediction performance of cross-validation.

isCombined

A logical. If isCombined = TRUE, the theta-step is combined with the following c-step.

cv_type

A rule of selecting lambda_theta parameter. If cv_type="osr", one standard error rule is adopted.

type

A type of optimization method for ramsvm. If type = "type1", intercepts are included in a regularization term. If type = "type2", intercepts are omitted in the regularization term and estimated by a linear programming

optModel

A logical. Whether to obtain the optimal classification model.

nCores

The number of cores to use for parallel computing.

verbose

A integer value. If verbose = 1, the minimum values of cross-validation error for each step are printed.

...

Other arguments that can be passed to ramsvm core function.

Value

An S3 object of class "sramsvm" containing the following slots

opt_theta

The theta vector at the optimal lambda_theta value.

cstep_inform

Information of c-step including cross-validation errors and optimal lambda value.

theta_step_inform

Information of theta-step including cross-validation errors and optimal lambda_theta value.

opt_model

If optModel=TRUE, classification model with the optimal lambda and lambda_theta is returned.

opt_valid_err

If optModel=TRUE, a minimum value of cross-validation errors based on the optimal lambda_theta is returned.

valid_err

If optModel=TRUE, cross-validation errors based on the optimal lambda_theta is returned.

cv_type

A rule of selecting lambda_theta.

call

The call of sramsvm.

Examples

 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
require(dbvsmsvm)
n = 100; p = 10;
data = dbvsmsvm:::sim_gen(n = n, p = p, type = "linear")
x = scale(data$x)
y = data$y
sigma = kernlab::sigest(y ~ x, scaled = FALSE)[3]

# Fit the SRAMSVM with the linear kernel
sram_linear = sramsvm(x = x, y = y, gamma = 0.5, nfolds = 5,
                      lambda_seq = 2^{seq(-20, 0, length.out = 100)},
                      lambda_theta_seq = 2^{seq(-20, 0, length.out = 100)},
                      kernel = "linear", scale = FALSE, criterion = "0-1",
                      isCombined = TRUE, cv_type = "osr", nCores = 1)

# Fit the SRAMSVM with the Gaussian kernel
sram_radial = sramsvm(x = x, y = y, gamma = 0.5, nfolds = 5,
                      lambda_seq = 2^{seq(-20, 0, length.out = 100)},
                      lambda_theta_seq = 2^{seq(-20, 0, length.out = 100)},
                      kernel = "gaussian", kparam = sigma, scale = FALSE, criterion = "0-1",
                      isCombined = TRUE, cv_type = "osr", nCores = 1)

# Fit the SRAMSVM with the Gaussian kernel with second-order interaction
sram_radial_interaction = sramsvm(x = x, y = y, gamma = 0.5, nfolds = 5,
                      lambda_seq = 2^{seq(-20, 0, length.out = 100)},
                      lambda_theta_seq = 2^{seq(-20, 0, length.out = 100)},
                      kernel = "gaussian2", kparam = sigma, scale = FALSE, criterion = "0-1",
                      isCombined = TRUE, cv_type = "osr", nCores = 1)

bbeomjin/GBFSMSVM documentation built on Nov. 7, 2021, 10:20 p.m.