Skip to main content

LinearSVC

Linear support-vector classifier trained with coordinate-descent / sub-gradient updates on the (squared) hinge loss. Scales to many samples and is sparse-aware.

Algorithm

Minimises a regularised hinge objective directly in the primal. Multiclass uses one-vs-rest. Unlike kernel SVC, no support-vector set is materialised — only the weight vector and intercept.

Constructor

Skigen::LinearSVC<Scalar> model(Scalar C = 1.0, Loss = SquaredHinge, Penalty = L2, ...);

Parameters

ParameterDefaultDescription
C1.0Inverse regularisation strength.
lossSquaredHingeHinge or SquaredHinge.
max_iter1000Optimiser iterations.
fit_intercepttrueLearn a bias term.
random_statenulloptSeed.

Methods

MethodDescription
fit(X, y)Optimise the primal objective.
predict(X)Class labels.
decision_function(X)Signed margins.

Fitted Attributes

AccessorDescription
coef()Weight vector(s).
intercept()Bias term(s).

Example

Skigen::LinearSVC<double> svc(1.0);
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/linear_svc/, exercised by tests/parity/parity_svm.cpp.

API Reference

For full signatures see the LinearSVC API Reference.