Nonlinear classification
Classifying labeled tabular data with nonlinear boundaries.
Scikit-Learn · Class
SVC is a libsvm-based C-support vector classifier for binary and multiclass problems. It supports several kernels, with RBF as the default, and handles multiclass classification through one-vs-one models.
SVC learns a support-vector classifier using libsvm. It can apply linear, polynomial, RBF, sigmoid, precomputed, or callable kernels; multiclass classification is handled with one-vs-one models, and predictions require fitting the estimator first.
class sklearn.svm.SVC(*, C=1.0, kernel='rbf', degree=3, gamma='scale', coef0=0.0, shrinking=True, probability='deprecated', tol=0.001, cache_size=200, class_weight=None, verbose=False, max_iter=-1, decision_function_shape='ovr', break_ties=False, random_state=None)| Name | Type | Description |
|---|---|---|
C | float, default=1.0 | Regularization parameter; must be strictly positive. |
kernel | {'linear', 'poly', 'rbf', 'sigmoid', 'precomputed'} or callable, default='rbf' | Kernel type: linear, poly, rbf, sigmoid, precomputed, or callable. |
degree | int, default=3 | Polynomial kernel degree; must be non-negative and is used with the poly kernel. |
gamma | {'scale', 'auto'} or float, default='scale' | Kernel coefficient for rbf, poly, and sigmoid kernels. |
coef0 | float, default=0.0 | Independent term in the kernel function. |
shrinking | bool, default=True | Whether to use the shrinking heuristic. |
probability | deprecated | Probability estimation setting; the current stable page reports this parameter as deprecated. |
tol | float, default=0.001 | Tolerance for stopping criterion. |
cache_size | float, default=200 | Kernel cache size in megabytes. |
class_weight | dict or 'balanced', default=None | Class weights; None leaves classes unweighted. |
verbose | bool, default=False | Enable verbose output. |
max_iter | int, default=-1 | Hard limit on iterations; -1 means no limit. |
A fitted SVC estimator from fit; prediction methods return class labels or decision scores according to the selected method.
from sklearn.svm import SVC
from sklearn.datasets import load_iris
X, y = load_iris(return_X_y=True)
model = SVC(kernel="rbf", gamma="scale", C=1.0)
model.fit(X, y)
print(model.predict(X[:3]))This trains an RBF-kernel SVC on the Iris dataset and predicts labels for three samples.
Classifying labeled tabular data with nonlinear boundaries.
Using a linear, polynomial, RBF, or sigmoid similarity function.
Predicting among multiple target classes.
SVC is a C-support vector classifier based on libsvm. Its fit-time complexity scales at least quadratically with the number of samples, so it may not suit very large datasets.
Follow-up: How does SVC handle multiclass classification? It uses a one-versus-one scheme, training binary classifiers for pairs of classes.
The kernel selects the transformation or similarity function used by the algorithm. Supported choices include linear, polynomial, RBF, sigmoid, precomputed, and callable kernels; the default is RBF.
Follow-up: Which parameter controls the polynomial degree? The degree parameter controls the polynomial kernel degree and is ignored by other kernels.
C is the regularization parameter and must be strictly positive. Regularization strength varies inversely with C, while gamma is the kernel coefficient for RBF, polynomial, and sigmoid kernels.
Follow-up: What is gamma's default behavior? With gamma='scale', its value is derived from the input feature variance and feature count.
sklearn.svm.LinearSVCsklearn.svm.NuSVCsklearn.svm.SVRsklearn.svm.OneClassSVM