Soft-margin linear SVC solved through its dual, with the primal weights
recovered as w = sum(alpha * y * x). Unlike the kernel form the weight
vector is explicit, so the rule is interpretable coefficient by
coefficient. The margin width 2 / ||w|| is reported, and widens as C
falls.
Usage
morie_esl_svc(
X,
y,
C = 1,
newdata = NULL,
tol = 0.001,
max_passes = 50L,
seed = 0L
)
Arguments
- X
Predictors, n by p.
- y
Labels; any two distinct values.
- C
Cost of margin violations, positive.
- newdata
Points to classify; defaults to X.
- tol, max_passes, seed
SMO controls.
Value
List with w, b, margin, alpha, support, decision,
class, accuracy, slack, n_violations.
References
Hastie, T., et al. (2009). ESL (2nd ed.), Sec 12.2. Springer.
Examples
set.seed(1)
X <- rbind(
matrix(rnorm(100, -3, 0.5), ncol = 2),
matrix(rnorm(100, 3, 0.5), ncol = 2)
)
y <- rep(c(-1, 1), each = 50)
morie_esl_svc(X, y, C = 1, seed = 1L)$accuracy
#> [1] 1