Support Vector Classifier (SVC)
Learn what Support Vector Classifier (SVC) does, when to use it, and how to run SVC in JavaScript or TypeScript with @kanaries/ml for browser and Node.js applications.
Algorithm overview
C-Support Vector Classification. SVC solves the SVM dual problem with an SMO solver (libsvm-style maximal-violating-pair working-set selection), the same formulation scikit-learn's SVC uses. It supports the full sklearn kernel set (linear, rbf, poly, sigmoid), handles multiclass problems one-vs-one, and exposes the fitted support vectors and a binary decisionFunction whose values line up numerically with scikit-learn's decision_function.
Not included yet: probability estimates (predict_proba / Platt scaling) are on the roadmap and not part of this release.
This algorithm is especially useful when:
- Linear models underfit complex class separation patterns.
- You can afford kernel-based training for improved boundary flexibility.
- You need strong classification performance on medium-sized datasets.
JavaScript implementation
@kanaries/ml exposes SVC in JavaScript for teams that need non-linear decision boundaries inside browser apps or Node.js services. This is useful when a linear classifier is not expressive enough but you still want a familiar estimator API and controllable kernel settings in TypeScript.
For product teams, this means kernel-based classification can live in the same JS codebase that already handles feature construction, request handling, and user-facing logic.
Quick start
SVC in Python vs JavaScript / TypeScript
If you searched for "SVC in JavaScript" or "SVC in TypeScript", this section maps the familiar scikit-learn call to the equivalent @kanaries/ml usage for browser and Node.js runtimes.
from sklearn.svm import SVC
X = [[0, 0], [1, 1], [1, 0], [0, 1]]
y = [0, 1, 1, 0]
clf = SVC(C=1.0, kernel='rbf', gamma='scale')
clf.fit(X, y)
pred = clf.predict([[0.9, 0.8], [0.1, 0.2]])import { SVM } from '@kanaries/ml';
const X = [[0, 0], [1, 1], [1, 0], [0, 1]];
const y = [0, 1, 1, 0];
const clf = new SVM.SVC({ C: 1, kernel: 'rbf', gamma: 'scale' });
clf.fit(X, y);
const pred = clf.predict([[0.9, 0.8], [0.1, 0.2]]);Quick JavaScript example
import { SVM } from '@kanaries/ml';
const X = [[0, 0], [1, 1], [1, 0], [0, 1]];
const y = [0, 1, 1, 0];
const clf = new SVM.SVC({ C: 1, kernel: 'rbf', gamma: 'scale' });
clf.fit(X, y);
const pred = clf.predict([[0.9, 0.8], [0.1, 0.2]]);Detailed API reference
interface SVCProps {
C?: number;
kernel?: 'linear' | 'rbf' | 'poly' | 'sigmoid';
gamma?: number | 'scale' | 'auto';
degree?: number;
coef0?: number;
tol?: number;
maxIter?: number;
}
constructor(props: SVCProps = {})Parameters
C(number, default1): regularization strength, inversely proportional to the margin softnesskernel('linear' | 'rbf' | 'poly' | 'sigmoid', default'rbf'): kernel typegamma(number | 'scale' | 'auto', default'scale'): kernel coefficient forrbf,poly, andsigmoid;'scale'= 1 / (n_features x Var(X)),'auto'= 1 / n_featuresdegree(number, default3): degree of the polynomial kernelcoef0(number, default0): independent term of thepolyandsigmoidkernelstol(number, default1e-3): KKT-violation tolerance for SMO convergencemaxIter(number, default-1): hard limit on SMO pair updates;-1runs until convergence
Methods
fit(trainX, trainY): train the classifier; multiclass data is handled one-vs-onepredict(testX): predicted class labels (one-vs-one voting)decisionFunction(testX): signed margins for binary problems; positive values meanclasses[1], matching sklearn's conventiongetSupportVectors(): sorted training-set indices of the support vectorsgetNSupport(): number of support vectors per class, like sklearn'sn_support_
Implementation workflow
- Scale features and pick a kernel (RBF is a common starting point).
- Fit with baseline hyperparameters and assess validation metrics.
- Tune
C, kernel settings, and class weights for task-specific goals.
JavaScript deployment notes
- Use SVC when linear models underfit but the dataset is still small or medium enough for kernel methods.
- Scale features before fitting, especially with RBF kernels.
- Treat kernel choice,
C, andgammaas a joint tuning problem rather than optimizing them one at a time.
Support Vector Machines
Explore SVC, NuSVC, LinearSVC, and LinearSVR in JavaScript and TypeScript with @kanaries/ml for margin-based classification and regression.
NuSVC
Learn what NuSVC does, when to use it, and how to run NuSVC in JavaScript or TypeScript with @kanaries/ml for browser and Node.js applications.