Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Scikit learn Scikit learn SVC

From Leeroopedia


Knowledge Sources
Domains Machine Learning, Support Vector Machines
Last Updated 2026-02-08 15:00 GMT

Overview

Concrete tool for C-Support Vector Classification and other SVM variants provided by scikit-learn.

Description

SVC implements C-Support Vector Classification based on libsvm. The module also includes NuSVC (Nu-Support Vector Classification), SVR (Support Vector Regression), NuSVR (Nu-Support Vector Regression), OneClassSVM (unsupervised outlier detection), LinearSVC (linear SVM using liblinear), and LinearSVR (linear SVR using liblinear). SVC supports multiple kernel functions (linear, polynomial, RBF, sigmoid, precomputed) and handles multiclass classification via a one-vs-one scheme.

Usage

Use SVC for classification tasks where you need a powerful, flexible classifier with kernel support. It works well for small to medium datasets. For large datasets, prefer LinearSVC or SGDClassifier. Use probability=True to enable predict_proba, though this adds computational cost.

Code Reference

Source Location

Signature

class SVC(BaseSVC):
    def __init__(
        self,
        *,
        C=1.0,
        kernel="rbf",
        degree=3,
        gamma="scale",
        coef0=0.0,
        shrinking=True,
        probability=False,
        tol=1e-3,
        cache_size=200,
        class_weight=None,
        verbose=False,
        max_iter=-1,
        decision_function_shape="ovr",
        break_ties=False,
        random_state=None,
    ):

Import

from sklearn.svm import SVC

I/O Contract

Inputs

Name Type Required Description
C float No Regularization parameter (default=1.0)
kernel str or callable No Kernel type: 'linear', 'poly', 'rbf', 'sigmoid', 'precomputed' (default='rbf')
degree int No Degree of polynomial kernel (default=3)
gamma str or float No Kernel coefficient: 'scale', 'auto', or float (default='scale')
coef0 float No Independent term in kernel function (default=0.0)
shrinking bool No Whether to use the shrinking heuristic (default=True)
probability bool No Whether to enable probability estimates (default=False)
tol float No Tolerance for stopping criterion (default=1e-3)
cache_size float No Kernel cache size in MB (default=200)
class_weight dict or str or None No Class weights; 'balanced' or dict mapping class to weight
verbose bool No Enable verbose output (default=False)
max_iter int No Maximum iterations; -1 for no limit (default=-1)
decision_function_shape str No Decision function shape: 'ovr' or 'ovo' (default='ovr')
break_ties bool No Whether to break ties using decision function values (default=False)
random_state int, RandomState, or None No Random state for probability estimation

Outputs

Name Type Description
class_weight_ ndarray of shape (n_classes,) Multipliers of parameter C for each class
classes_ ndarray of shape (n_classes,) Unique class labels
coef_ ndarray of shape (n_classes * (n_classes - 1) / 2, n_features) Weights (linear kernel only)
dual_coef_ ndarray of shape (n_classes - 1, n_SV) Dual coefficients of support vectors
fit_status_ int 0 if correctly fitted, 1 otherwise
intercept_ ndarray Constants in decision function
support_ ndarray Indices of support vectors
support_vectors_ ndarray of shape (n_SV, n_features) Support vectors
n_support_ ndarray of shape (n_classes,) Number of support vectors per class
n_features_in_ int Number of features seen during fit
n_iter_ ndarray Number of iterations run by the optimization routine

Usage Examples

Basic Usage

from sklearn.svm import SVC
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler

X, y = load_iris(return_X_y=True)
X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=42)

scaler = StandardScaler()
X_train = scaler.fit_transform(X_train)
X_test = scaler.transform(X_test)

clf = SVC(kernel="rbf", C=1.0, gamma="scale")
clf.fit(X_train, y_train)
print(f"Accuracy: {clf.score(X_test, y_test):.3f}")
print(f"Number of support vectors: {clf.n_support_}")

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment