Skip to main content

SVC

Kernel support-vector classifier built on a libsvm-style SMO solver, supporting linear, RBF, polynomial and sigmoid kernels.

The examples/svm/svc.cpp program fits an RBF classifier on two Gaussian classes and renders its decision regions with support vectors highlighted:

RBF SVC decision regions with support vectors highlightedRBF SVC decision regions with support vectors highlighted

Algorithm​

Sequential Minimal Optimization solves the dual quadratic program, selecting working pairs and updating their Lagrange multipliers until the KKT conditions hold. Multiclass uses one-vs-one voting. With probability=true, Platt scaling calibrates the margins into probabilities via internal cross-validation.

Constructor​

Skigen::SVC<Scalar> model(Scalar C = 1.0, Kernel = RBF, int degree = 3, Scalar gamma = scale, ...);

Parameters​

ParameterDefaultDescription
C1.0Penalty on margin violations.
kernelRBFLinear, RBF, Poly or Sigmoid.
degree3Polynomial-kernel degree.
gammascaleKernel coefficient.
probabilityfalseEnable Platt-scaled probabilities.

Methods​

MethodDescription
fit(X, y)Solve the dual via SMO.
predict(X)Class labels.
decision_function(X)Margins (OvO for multiclass).
predict_proba(X)Requires probability=true.

Fitted Attributes​

AccessorDescription
n_support()Support vectors per class.
n_classes()Number of classes.

Example​

Skigen::SVC<double> svc(1.0, Skigen::SVC<double>::Kernel::RBF);
svc.fit(X, y);
auto preds = svc.predict(X_test);
Verified against scikit-learn

This estimator is checked by the parity suite. See the generator tests/parity/generate_svm_reference.py and the reference fixtures in tests/parity/data/svc/, exercised by tests/parity/parity_svm.cpp.

API Reference

For full signatures see the SVC API Reference.