Skip to main content

LinearSVC

#include <Skigen/SVM>

template <typename Scalar = double>
class Skigen::LinearSVC(C=1.0, loss=Loss::SquaredHinge, tol=1e-4, max_iter=1000, fit_intercept=true, random_state=std::nullopt)

Linear SVC — primal sub-gradient SGD on the squared-hinge L2 regularised objective.

Mirrors the binary case of sklearn.svm.LinearSVC; multiclass uses one-vs-rest (default multi_class="ovr").

Solves minw12w2+Cimax(0,1yi(wxi+b))2\min_w \tfrac{1}{2}\|w\|^2 + C \sum_i \max(0, 1 - y_i (w \cdot x_i + b))^2 (loss="squared_hinge", the sklearn default) or the analogous hinge loss when loss="hinge".



Attributes:

  • C : Scalar

  • loss : Loss

  • classes : const Eigen::VectorXi

  • n_classes : int

  • coef : MatrixType

  • intercept : VectorType


Methods

SKIGEN_PARAMS()


fit(X, y)

Fit from a sparse design matrix (densifies internally).


predict(X)


predict(X)

Predict from a sparse design matrix (densifies internally).


decision_function(X)

Raw decision function. Shape is (n_samples,) for binary problems wrapped as a 1-column matrix; (n_samples, n_classes) for multiclass.


fit(X, y)


predict(X)