| Title: | ROC-Optimizing Binary Classifiers |
|---|---|
| Description: | Implements ROC (Receiver Operating Characteristic)–Optimizing Binary Classifiers, supporting both linear and kernel models. Both model types provide a variety of surrogate loss functions. In addition, linear models offer multiple regularization penalties, whereas kernel models support a range of kernel functions. Scalability for large datasets is achieved through approximation-based options, which accelerate training and make fitting feasible on large data. Utilities are provided for model training, prediction, and cross-validation. The implementation builds on the ROC-Optimizing Support Vector Machines. For more information, see Hernàndez-Orallo, José, et al. (2004) <doi:10.1145/1046456.1046489>, presented in the ROC Analysis in AI Workshop (ROCAI-2004). |
| Authors: | Gimun Bae [aut, cre], Seung Jun Shin [aut] |
| Maintainer: | Gimun Bae <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.4 |
| Built: | 2026-06-02 09:20:06 UTC |
| Source: | https://github.com/gimunbae/roclab |
Compute AUC (Area Under the ROC Curve) for a fitted model.
Dispatches to class-specific methods such as auc.roclearn.
auc(object, ...)auc(object, ...)
object |
A fitted model object. |
... |
Additional arguments passed to methods. |
Numeric scalar: estimated AUC.
Estimate the AUC (Area Under the ROC Curve) for a fitted kernel model on new data.
## S3 method for class 'kroclearn' auc(object, newdata, y, ...)## S3 method for class 'kroclearn' auc(object, newdata, y, ...)
object |
A fitted model object of class |
newdata |
A matrix or data.frame of test predictors. Must have the same structure as the training data (categorical variables are dummy-aligned automatically). |
y |
Response vector of test labels ({-1, 1} or convertible). |
... |
Not used. |
A numeric scalar giving the estimated AUC.
set.seed(123) n_train <- 100 r_train <- sqrt(runif(n_train, 0.05, 1)) theta_train <- runif(n_train, 0, 2*pi) X_train <- cbind(r_train * cos(theta_train), r_train * sin(theta_train)) y_train <- ifelse(r_train < 0.5, 1, -1) n_test <- 10 r_test <- sqrt(runif(n_test, 0.05, 1)) theta_test <- runif(n_test, 0, 2*pi) X_test <- cbind(r_test * cos(theta_test), r_test * sin(theta_test)) y_test <- ifelse(r_test < 0.5, 1, -1) fit <- kroclearn(X_train, y_train, lambda = 0.1, kernel = "radial", approx=TRUE) auc(fit, X_test, y_test)set.seed(123) n_train <- 100 r_train <- sqrt(runif(n_train, 0.05, 1)) theta_train <- runif(n_train, 0, 2*pi) X_train <- cbind(r_train * cos(theta_train), r_train * sin(theta_train)) y_train <- ifelse(r_train < 0.5, 1, -1) n_test <- 10 r_test <- sqrt(runif(n_test, 0.05, 1)) theta_test <- runif(n_test, 0, 2*pi) X_test <- cbind(r_test * cos(theta_test), r_test * sin(theta_test)) y_test <- ifelse(r_test < 0.5, 1, -1) fit <- kroclearn(X_train, y_train, lambda = 0.1, kernel = "radial", approx=TRUE) auc(fit, X_test, y_test)
Estimate the AUC (Area Under the ROC Curve) for a fitted linear model on new data.
## S3 method for class 'roclearn' auc(object, newdata, y, ...)## S3 method for class 'roclearn' auc(object, newdata, y, ...)
object |
A fitted model object of class |
newdata |
A matrix or data.frame of test predictors. Must have the same structure as the training data (categorical variables are dummy-aligned automatically). |
y |
Response vector of test labels ({-1, 1} or convertible). |
... |
Not used. |
A numeric scalar giving the estimated AUC.
set.seed(123) n_train <- 100 n_pos <- round(0.2 * n_train) n_neg <- n_train - n_pos X_train <- rbind( matrix(rnorm(2 * n_neg, mean = -1), ncol = 2), matrix(rnorm(2 * n_pos, mean = 1), ncol = 2) ) y_train <- c(rep(-1, n_neg), rep(1, n_pos)) n_test <- 10 n_pos_test <- round(0.2 * n_test) n_neg_test <- n_test - n_pos_test X_test <- rbind( matrix(rnorm(2 * n_neg_test, mean = -1), ncol = 2), matrix(rnorm(2 * n_pos_test, mean = 1), ncol = 2) ) y_test <- c(rep(-1, n_neg_test), rep(1, n_pos_test)) fit <- roclearn(X_train, y_train, lambda = 0.1, approx=TRUE) auc(fit, X_test, y_test)set.seed(123) n_train <- 100 n_pos <- round(0.2 * n_train) n_neg <- n_train - n_pos X_train <- rbind( matrix(rnorm(2 * n_neg, mean = -1), ncol = 2), matrix(rnorm(2 * n_pos, mean = 1), ncol = 2) ) y_train <- c(rep(-1, n_neg), rep(1, n_pos)) n_test <- 10 n_pos_test <- round(0.2 * n_test) n_neg_test <- n_test - n_pos_test X_test <- rbind( matrix(rnorm(2 * n_neg_test, mean = -1), ncol = 2), matrix(rnorm(2 * n_pos_test, mean = 1), ncol = 2) ) y_test <- c(rep(-1, n_neg_test), rep(1, n_pos_test)) fit <- roclearn(X_train, y_train, lambda = 0.1, approx=TRUE) auc(fit, X_test, y_test)
Perform k-fold cross-validation over a sequence of values and
select the optimal model based on AUC.
cv.kroclearn( X, y, lambda.vec = NULL, lambda.length = 30, kernel = "radial", param.kernel = NULL, loss = "hinge", approx = NULL, intercept = TRUE, nfolds = 10, target.perf = list(), param.convergence = list() )cv.kroclearn( X, y, lambda.vec = NULL, lambda.length = 30, kernel = "radial", param.kernel = NULL, loss = "hinge", approx = NULL, intercept = TRUE, nfolds = 10, target.perf = list(), param.convergence = list() )
X |
Predictor matrix or data.frame (categorical variables are automatically one-hot encoded). |
y |
Response vector with class labels in {-1, 1}. Labels given as {0, 1} or as a two-level factor/character are automatically converted to this format. |
lambda.vec |
Optional numeric vector of regularization parameters (lambda values).
If |
lambda.length |
Number of |
kernel |
Kernel type: |
param.kernel |
Kernel-specific parameter:
|
loss |
Surrogate loss function type. One of:
|
approx |
Logical; enables a scalable approximation to accelerate training.
The default is |
intercept |
Logical; include an intercept in the model (default |
nfolds |
Number of cross-validation folds (default 10). |
target.perf |
List with target sensitivity and specificity used when estimating the intercept (defaults to 0.9 each). |
param.convergence |
List of convergence controls (e.g., |
An object of class "cv.kroclearn" with:
optimal.lambda — selected .
optimal.fit — model trained at optimal.lambda.
lambda.vec — grid of penalty values considered.
auc.mean, auc.sd — mean and sd of cross-validated AUC.
auc.result — fold-by-lambda AUC matrix.
time.mean, time.sd — mean and sd of training time.
time.result — fold-by-lambda training time matrix.
nfolds, loss, kernel — settings.
set.seed(123) n <- 100 r <- sqrt(runif(n, 0.05, 1)) theta <- runif(n, 0, 2*pi) X <- cbind(r * cos(theta), r * sin(theta)) y <- ifelse(r < 0.5, 1, -1) cvfit <- cv.kroclearn( X, y, lambda.vec = exp(seq(log(0.01), log(5), length.out = 3)), kernel = "radial", approx=TRUE, nfolds = 2 ) cvfit$optimal.lambdaset.seed(123) n <- 100 r <- sqrt(runif(n, 0.05, 1)) theta <- runif(n, 0, 2*pi) X <- cbind(r * cos(theta), r * sin(theta)) y <- ifelse(r < 0.5, 1, -1) cvfit <- cv.kroclearn( X, y, lambda.vec = exp(seq(log(0.01), log(5), length.out = 3)), kernel = "radial", approx=TRUE, nfolds = 2 ) cvfit$optimal.lambda
Perform k-fold cross-validation over a sequence of values and
select the optimal model based on AUC.
cv.roclearn( X, y, lambda.vec = NULL, lambda.length = 30, penalty = "ridge", param.penalty = NULL, loss = "hinge", approx = NULL, intercept = TRUE, nfolds = 10, target.perf = list(), param.convergence = list() )cv.roclearn( X, y, lambda.vec = NULL, lambda.length = 30, penalty = "ridge", param.penalty = NULL, loss = "hinge", approx = NULL, intercept = TRUE, nfolds = 10, target.perf = list(), param.convergence = list() )
X |
Predictor matrix or data.frame (categorical variables are automatically one-hot encoded). |
y |
Response vector with class labels in {-1, 1}. Labels given as {0, 1} or as a two-level factor/character are automatically converted to this format. |
lambda.vec |
Optional numeric vector of regularization parameters (lambda values).
If |
lambda.length |
Number of |
penalty |
Regularization penalty type: |
param.penalty |
Penalty-specific parameter:
|
loss |
Surrogate loss function type. One of:
|
approx |
Logical; enables a scalable approximation to accelerate training.
The default is |
intercept |
Logical; include an intercept in the model (default |
nfolds |
Number of cross-validation folds (default 10). |
target.perf |
List with target sensitivity and specificity used when estimating the intercept (defaults to 0.9 each). |
param.convergence |
List of convergence controls (e.g., |
An object of class "cv.roclearn" with:
optimal.lambda — selected .
optimal.fit — model refit on the full data at
optimal.lambda.
lambda.vec — grid of penalty values considered.
auc.mean, auc.sd — mean and sd of cross-validated AUC.
auc.result — fold-by-lambda AUC matrix.
time.mean, time.sd — mean and sd of training time.
time.result — fold-by-lambda training time matrix.
nfolds, loss, penalty — settings.
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 ) cvfit$optimal.lambdaset.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 ) cvfit$optimal.lambda
Fit a kernel model
kroclearn( X, y, lambda, kernel = "radial", param.kernel = NULL, loss = "hinge", approx = NULL, intercept = TRUE, target.perf = list(), param.convergence = list() )kroclearn( X, y, lambda, kernel = "radial", param.kernel = NULL, loss = "hinge", approx = NULL, intercept = TRUE, target.perf = list(), param.convergence = list() )
X |
Predictor matrix or data.frame (categorical variables are automatically one-hot encoded). |
y |
Response vector with class labels in {-1, 1}. Labels given as {0, 1} or as a two-level factor/character are automatically converted to this format. |
lambda |
Positive scalar regularization parameter. |
kernel |
Kernel type: |
param.kernel |
Kernel-specific parameter:
|
loss |
Surrogate loss function type. One of:
|
approx |
Logical; enables a scalable approximation to accelerate training.
The default is |
intercept |
Logical; include an intercept in the model (default |
target.perf |
List with target sensitivity and specificity used when estimating the intercept (defaults to 0.9 each). |
param.convergence |
List of convergence controls (e.g., |
For large-scale data, the model is computationally prohibitive because its
loss is a U-statistic involving a double summation. To reduce this burden,
the package adopts an efficient algorithm based on an incomplete U-statistic,
which approximates the loss with a single summation. In kernel models,
a Nyström low-rank approximation is further applied to efficiently compute
the kernel matrix. These approximations substantially reduce computational
cost and accelerate training, while maintaining accuracy, making the model
feasible for large-scale datasets. This option is available when
@param approx = TRUE.
An object of class "kroclearn", a list containing:
theta.hat — estimated dual coefficient vector.
intercept — fitted intercept (if applicable).
lambda, kernel, param.kernel, loss.
approx, B (number of sampled pairs if approximation used).
time — training time (seconds).
nobs, p — number of observations and predictors.
converged, n.iter — convergence information.
kfunc — kernel function object.
nystrom — low rank kernel approximation details (if used).
X — training data (post-preprocessing).
preprocessing — details on categorical variables,
removed columns, and column names.
call — the function call.
set.seed(123) n <- 100 r <- sqrt(runif(n, 0.05, 1)) theta <- runif(n, 0, 2*pi) X <- cbind(r * cos(theta), r * sin(theta)) y <- ifelse(r < 0.5, 1, -1) fit <- kroclearn(X, y, lambda = 0.1, kernel = "radial", approx=TRUE)set.seed(123) n <- 100 r <- sqrt(runif(n, 0.05, 1)) theta <- runif(n, 0, 2*pi) X <- cbind(r * cos(theta), r * sin(theta)) y <- ifelse(r < 0.5, 1, -1) fit <- kroclearn(X, y, lambda = 0.1, kernel = "radial", approx=TRUE)
Draws an ROC curve based on decision values. There is an option to display the AUC in the plot title and to print the ROC summary object.
plot_roc( y_true, y_score, col = "blue", size = 1.2, title = TRUE, summary = FALSE, ... )plot_roc( y_true, y_score, col = "blue", size = 1.2, title = TRUE, summary = FALSE, ... )
y_true |
Response vector with class labels in {-1, 1}. Labels given as {0, 1} or as a two-level factor/character are automatically converted to this format. |
y_score |
Numeric vector of predicted scores or decision values. |
col |
Line color. |
size |
Line width. |
title |
Logical; if TRUE, displays AUC in the plot title. |
summary |
Logical; if TRUE, prints the ROC object summary. |
... |
Additional arguments passed to pROC::ggroc(). |
A ggplot object of the ROC curve.
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)) fit <- roclearn(X, y, lambda = 0.1, approx=TRUE) y_score <- predict(fit, X, type = "response") plot_roc(y, y_score)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)) fit <- roclearn(X, y, lambda = 0.1, approx=TRUE) y_score <- predict(fit, X, type = "response") plot_roc(y, y_score)
Produce a visualization of cross-validation results from a fitted
cv.kroclearn object. The plot shows the mean AUC across
regularization parameters , with error bars reflecting
the cross-validation standard deviation. Optionally, the selected
optimal is highlighted with a dashed line and marker.
## S3 method for class 'cv.kroclearn' plot(x, highlight = TRUE, ...)## S3 method for class 'cv.kroclearn' plot(x, highlight = TRUE, ...)
x |
A cross-validation object of class |
highlight |
Logical; if |
... |
Additional arguments passed to underlying ggplot2 functions. |
This function is a method for the generic plot() function,
designed specifically for cross-validation objects from
cv.kroclearn. The x-axis is displayed on a log scale for
, and the y-axis represents AUC values. Error bars show
variability across folds. This is the kernel counterpart of
plot.cv.roclearn.
A ggplot2 object is returned and drawn to the current device.
set.seed(123) n <- 100 r <- sqrt(runif(n, 0.05, 1)) theta <- runif(n, 0, 2*pi) X <- cbind(r * cos(theta), r * sin(theta)) y <- ifelse(r < 0.5, 1, -1) cvfit <- cv.kroclearn( X, y, lambda.vec = exp(seq(log(0.01), log(5), length.out = 3)), kernel = "radial", approx=TRUE, nfolds = 2 ) plot(cvfit)set.seed(123) n <- 100 r <- sqrt(runif(n, 0.05, 1)) theta <- runif(n, 0, 2*pi) X <- cbind(r * cos(theta), r * sin(theta)) y <- ifelse(r < 0.5, 1, -1) cvfit <- cv.kroclearn( X, y, lambda.vec = exp(seq(log(0.01), log(5), length.out = 3)), kernel = "radial", approx=TRUE, nfolds = 2 ) plot(cvfit)
Produce a visualization of cross-validation results from a fitted
cv.roclearn object. The plot shows the mean AUC across
regularization parameters , with error bars reflecting
the cross-validation standard deviation. Optionally, the selected
optimal is highlighted with a dashed line and marker.
## S3 method for class 'cv.roclearn' plot(x, highlight = TRUE, ...)## S3 method for class 'cv.roclearn' plot(x, highlight = TRUE, ...)
x |
A cross-validation object of class |
highlight |
Logical; if |
... |
Additional arguments passed to underlying ggplot2 functions. |
This function is a method for the generic plot() function,
designed specifically for cross-validation objects from
cv.roclearn. The x-axis is displayed on a log scale for
, and the y-axis represents AUC values. Error bars
show variability across folds.
A ggplot2 object is returned and drawn to the current device.
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)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)
Generate predictions from a fitted kernel model.
## S3 method for class 'kroclearn' predict(object, newdata, type = c("class", "response"), ...)## S3 method for class 'kroclearn' predict(object, newdata, type = c("class", "response"), ...)
object |
A fitted model object of class |
newdata |
A data frame or matrix of predictors for which predictions are desired. Categorical variables are automatically dummy-encoded and aligned to the training structure. |
type |
Prediction type: |
... |
Not used. |
A numeric vector of predictions ({-1, 1}) if type = "class",
or raw decision scores if type = "response".
set.seed(123) n <- 100 r <- sqrt(runif(n, 0.05, 1)) theta <- runif(n, 0, 2*pi) X <- cbind(r * cos(theta), r * sin(theta)) y <- ifelse(r < 0.5, 1, -1) fit <- kroclearn(X, y, lambda = 0.1, kernel = "radial", approx=TRUE) # Predict classes {-1, 1} predict(fit, X, type = "class") # Predict decision scores predict(fit, X, type = "response")set.seed(123) n <- 100 r <- sqrt(runif(n, 0.05, 1)) theta <- runif(n, 0, 2*pi) X <- cbind(r * cos(theta), r * sin(theta)) y <- ifelse(r < 0.5, 1, -1) fit <- kroclearn(X, y, lambda = 0.1, kernel = "radial", approx=TRUE) # Predict classes {-1, 1} predict(fit, X, type = "class") # Predict decision scores predict(fit, X, type = "response")
Generate predictions from a fitted linear model.
## S3 method for class 'roclearn' predict(object, newdata, type = c("class", "response"), ...)## S3 method for class 'roclearn' predict(object, newdata, type = c("class", "response"), ...)
object |
A fitted model object of class |
newdata |
A data frame or matrix of predictors for which predictions are desired. Categorical variables are automatically dummy-encoded and aligned to the training structure. |
type |
Prediction type: |
... |
Not used. |
A numeric vector of predictions ({-1, 1}) if type = "class",
or raw decision scores if type = "response".
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)) fit <- roclearn(X, y, lambda = 0.1, approx=TRUE) # Predict classes {-1, 1} predict(fit, X, type = "class") # Predict decision scores predict(fit, X, type = "response")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)) fit <- roclearn(X, y, lambda = 0.1, approx=TRUE) # Predict classes {-1, 1} predict(fit, X, type = "class") # Predict decision scores predict(fit, X, type = "response")
Fit a linear model
roclearn( X, y, lambda, penalty = "ridge", param.penalty = NULL, loss = "hinge", approx = NULL, intercept = TRUE, target.perf = list(), param.convergence = list() )roclearn( X, y, lambda, penalty = "ridge", param.penalty = NULL, loss = "hinge", approx = NULL, intercept = TRUE, target.perf = list(), param.convergence = list() )
X |
Predictor matrix or data.frame (categorical variables are automatically one-hot encoded). |
y |
Response vector with class labels in {-1, 1}. Labels given as {0, 1} or as a two-level factor/character are automatically converted to this format. |
lambda |
Positive scalar regularization parameter. |
penalty |
Regularization penalty type:
|
param.penalty |
Penalty-specific parameter:
|
loss |
Surrogate loss function type. One of:
|
approx |
Logical; enables a scalable approximation to accelerate training.
The default is |
intercept |
Logical; include an intercept in the model (default |
target.perf |
List with target sensitivity and specificity used when estimating the intercept (defaults to 0.9 each). |
param.convergence |
List of convergence controls (e.g., |
For large-scale data, the model is computationally prohibitive because its
loss is a U-statistic involving a double summation. To reduce this burden,
the package adopts an efficient algorithm based on an incomplete U-statistic,
which approximates the loss with a single summation. These approximations
substantially reduce computational cost and accelerate training, while
maintaining accuracy, making the model feasible for large-scale datasets.
This option is available when approx = TRUE.
An object of class "roclearn", a list containing:
beta.hat — estimated coefficient vector.
intercept — fitted intercept (if applicable).
lambda, penalty, param.penalty, loss.
approx, B (number of sampled pairs if approximation used).
time — training time (seconds).
nobs, p — number of observations and predictors.
converged, n.iter — convergence information.
preprocessing — details on categorical variables,
removed columns, and column names.
call — the function call.
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)) fit <- roclearn(X, y, lambda = 0.1, penalty = "ridge", approx=TRUE)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)) fit <- roclearn(X, y, lambda = 0.1, penalty = "ridge", approx=TRUE)
Print a concise summary of cross-validation results for a kernel model.
## S3 method for class 'cv.kroclearn' summary(object, ...)## S3 method for class 'cv.kroclearn' summary(object, ...)
object |
A fitted cross-validation object of class
|
... |
Not used. |
This is a method for the generic summary() function, applied to
objects of class "cv.kroclearn". It prints training settings
(loss, kernel type, number of folds, the set of candidate ),
the selected optimal , the corresponding mean and standard
deviation of cross-validated AUC, and a truncated table of AUC results
across candidate values.
Invisibly returns the input object, after printing a summary
to the console.
set.seed(123) n <- 100 r <- sqrt(runif(n, 0.05, 1)) theta <- runif(n, 0, 2*pi) X <- cbind(r * cos(theta), r * sin(theta)) y <- ifelse(r < 0.5, 1, -1) cvfit <- cv.kroclearn( X, y, lambda.vec = exp(seq(log(0.01), log(5), length.out = 3)), kernel = "radial", approx=TRUE, nfolds = 2 ) summary(cvfit)set.seed(123) n <- 100 r <- sqrt(runif(n, 0.05, 1)) theta <- runif(n, 0, 2*pi) X <- cbind(r * cos(theta), r * sin(theta)) y <- ifelse(r < 0.5, 1, -1) cvfit <- cv.kroclearn( X, y, lambda.vec = exp(seq(log(0.01), log(5), length.out = 3)), kernel = "radial", approx=TRUE, nfolds = 2 ) summary(cvfit)
Print a concise summary of cross-validation results for a linear model.
## S3 method for class 'cv.roclearn' summary(object, ...)## S3 method for class 'cv.roclearn' summary(object, ...)
object |
A fitted cross-validation object of class
|
... |
Not used. |
This is a method for the generic summary() function, applied to
objects of class "cv.roclearn". It prints training settings
(loss, penalty, number of folds, the set of candidate ),
the selected optimal , the corresponding mean and standard
deviation of cross-validated AUC, and a truncated table of AUC results
across candidate values.
Invisibly returns the input object, after printing a summary
to the console.
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 ) summary(cvfit)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 ) summary(cvfit)
Display key information from a fitted "kroclearn" object, including:
data dimensions, kernel specification, convergence status, training time,
and leading coefficient estimates.
## S3 method for class 'kroclearn' summary(object, ...)## S3 method for class 'kroclearn' summary(object, ...)
object |
A fitted model of class |
... |
Unused. |
Invisibly returns object after printing a formatted summary.
kroclearn, summary.roclearn,
cv.kroclearn, cv.roclearn
set.seed(123) n <- 100 r <- sqrt(runif(n, 0.05, 1)) theta <- runif(n, 0, 2*pi) X <- cbind(r * cos(theta), r * sin(theta)) y <- ifelse(r < 0.5, 1, -1) fit <- kroclearn(X, y, lambda = 0.1, kernel = "radial", approx=TRUE) summary(fit)set.seed(123) n <- 100 r <- sqrt(runif(n, 0.05, 1)) theta <- runif(n, 0, 2*pi) X <- cbind(r * cos(theta), r * sin(theta)) y <- ifelse(r < 0.5, 1, -1) fit <- kroclearn(X, y, lambda = 0.1, kernel = "radial", approx=TRUE) summary(fit)
Display key information from a fitted "roclearn" object, including:
data dimensions, model specification, convergence status, training time,
and leading coefficient estimates.
## S3 method for class 'roclearn' summary(object, ...)## S3 method for class 'roclearn' summary(object, ...)
object |
A fitted model of class |
... |
Unused. |
Invisibly returns object after printing a formatted summary.
roclearn, summary.kroclearn,
cv.roclearn, cv.kroclearn
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)) fit <- roclearn(X, y, lambda = 0.1, approx=TRUE) summary(fit)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)) fit <- roclearn(X, y, lambda = 0.1, approx=TRUE) summary(fit)