SVC - Scikit-Learn 1.5.1 Documentation
SVC - Scikit-Learn 1.5.1 Documentation
1 documentation
https://scikit-learn.org/stable/modules/generated/sklearn.svm.SVC.html#sklearn.svm.SVC 1/19
18/07/24, 22:13 SVC — scikit-learn 1.5.1 documentation
of scaling the regularization parameter C, see Scaling the regularization parameter for SVCs.
Changed in version 0.22: The default value of gamma changed from ‘auto’ to ‘scale’.
https://scikit-learn.org/stable/modules/generated/sklearn.svm.SVC.html#sklearn.svm.SVC 3/19
18/07/24, 22:13 SVC — scikit-learn 1.5.1 documentation
Attributes:
https://scikit-learn.org/stable/modules/generated/sklearn.svm.SVC.html#sklearn.svm.SVC 4/19
18/07/24, 22:13 SVC — scikit-learn 1.5.1 documentation
Dual coefficients of the support vector in the decision function (see Mathematical formulation),
multiplied by their targets. For multiclass, coefficient for all 1-vs-1 classifiers. The layout of the
coefficients in the multiclass case is somewhat non-trivial. See the multi-class section of the User
Guide for details.
fit_status_ : int
0 if correctly fitted, 1 otherwise (will raise warning)
n_features_in_ : int
Number of features seen during fit.
See also
SVR
Support Vector Machine for Regression implemented using libsvm.
LinearSVC
Scalable Linear Support Vector Machine for classification implemented using liblinear. Check
the See Also section of LinearSVC for more comparison element.
References
[2] Platt, John (1999). “Probabilistic Outputs for Support Vector Machines and Comparisons to
Regularized Likelihood Methods”
https://scikit-learn.org/stable/modules/generated/sklearn.svm.SVC.html#sklearn.svm.SVC 6/19
18/07/24, 22:13 SVC — scikit-learn 1.5.1 documentation
Examples
property coef_
Weights assigned to the features when kernel="linear" .
Returns:
decision_function(X) [source]
Parameters:
https://scikit-learn.org/stable/modules/generated/sklearn.svm.SVC.html#sklearn.svm.SVC 7/19
18/07/24, 22:13 SVC — scikit-learn 1.5.1 documentation
Returns:
Notes
If decision_function_shape=’ovo’, the function values are proportional to the distance of the samples X
to the separating hyperplane. If the exact distances are required, divide the function values by the
norm of the weight vector ( coef_ ). See also this question for further details. If
decision_function_shape=’ovr’, the decision function is a monotonic transformation of ovo decision
function.
Parameters:
https://scikit-learn.org/stable/modules/generated/sklearn.svm.SVC.html#sklearn.svm.SVC 8/19
18/07/24, 22:13 SVC — scikit-learn 1.5.1 documentation
Returns:
self : object
Fitted estimator.
Notes
If X and y are not C-ordered and contiguous arrays of np.float64 and X is not a scipy.sparse.csr_matrix,
X and/or y may be copied.
If X is a dense array, then the other methods will not support sparse matrices as input.
get_metadata_routing() [source]
Returns:
routing : MetadataRequest
A MetadataRequest encapsulating routing information.
get_params(deep=True) [source]
Parameters:
Returns:
params : dict
Parameter names mapped to their values.
property n_support_
Number of support vectors for each class.
predict(X) [source]
Parameters:
Returns:
predict_log_proba(X) [source]
The model need to have probability information computed at training time: fit with attribute
probability set to True.
https://scikit-learn.org/stable/modules/generated/sklearn.svm.SVC.html#sklearn.svm.SVC 10/19
18/07/24, 22:13 SVC — scikit-learn 1.5.1 documentation
Parameters:
Returns:
Notes
The probability model is created using cross validation, so the results can be slightly different than
those obtained by predict. Also, it will produce meaningless results on very small datasets.
predict_proba(X) [source]
The model needs to have probability information computed at training time: fit with attribute
probability set to True.
Parameters:
Returns:
https://scikit-learn.org/stable/modules/generated/sklearn.svm.SVC.html#sklearn.svm.SVC 11/19
18/07/24, 22:13 SVC — scikit-learn 1.5.1 documentation
Returns the probability of the sample for each class in the model. The columns correspond to
the classes in sorted order, as they appear in the attribute classes_.
Notes
The probability model is created using cross validation, so the results can be slightly different than
those obtained by predict. Also, it will produce meaningless results on very small datasets.
property probA_
Parameter learned in Platt scaling when probability=True .
Returns:
property probB_
Parameter learned in Platt scaling when probability=True .
Returns:
Return the mean accuracy on the given test data and labels.
In multi-label classification, this is the subset accuracy which is a harsh metric since you require for
each sample that each label set be correctly predicted.
Parameters:
https://scikit-learn.org/stable/modules/generated/sklearn.svm.SVC.html#sklearn.svm.SVC 12/19
18/07/24, 22:13 SVC — scikit-learn 1.5.1 documentation
Returns:
score : float
Mean accuracy of self.predict(X) w.r.t. y .
True : metadata is requested, and passed to fit if provided. The request is ignored if metadata
is not provided.
False : metadata is not requested and the meta-estimator will not pass it to fit .
None : metadata is not requested, and the meta-estimator will raise an error if the user provides it.
str : metadata should be passed to the meta-estimator with this given alias instead of the
original name.
https://scikit-learn.org/stable/modules/generated/sklearn.svm.SVC.html#sklearn.svm.SVC 13/19
18/07/24, 22:13 SVC — scikit-learn 1.5.1 documentation
The default ( sklearn.utils.metadata_routing.UNCHANGED ) retains the existing request. This allows you
to change the request for some parameters and not others.
Note
Parameters:
Returns:
self : object
The updated object.
set_params(**params) [source]
The method works on simple estimators as well as on nested objects (such as Pipeline ). The latter
have parameters of the form <component>__<parameter> so that it’s possible to update each
component of a nested object.
https://scikit-learn.org/stable/modules/generated/sklearn.svm.SVC.html#sklearn.svm.SVC 14/19
18/07/24, 22:13 SVC — scikit-learn 1.5.1 documentation
Parameters:
**params : dict
Estimator parameters.
Returns:
True : metadata is requested, and passed to score if provided. The request is ignored if
metadata is not provided.
False : metadata is not requested and the meta-estimator will not pass it to score .
None : metadata is not requested, and the meta-estimator will raise an error if the user provides it.
str : metadata should be passed to the meta-estimator with this given alias instead of the
original name.
The default ( sklearn.utils.metadata_routing.UNCHANGED ) retains the existing request. This allows you
to change the request for some parameters and not others.
https://scikit-learn.org/stable/modules/generated/sklearn.svm.SVC.html#sklearn.svm.SVC 15/19
18/07/24, 22:13 SVC — scikit-learn 1.5.1 documentation
Note
Parameters:
Returns:
self : object
The updated object.
Gallery examples
Release Highlights for Release Highlights for Classifier comparison Plot classification
scikit-learn 0.24 scikit-learn 0.22 probability
https://scikit-learn.org/stable/modules/generated/sklearn.svm.SVC.html#sklearn.svm.SVC 16/19
18/07/24, 22:13 SVC — scikit-learn 1.5.1 documentation
Recognizing hand- Plot the decision Faces recognition Scalable learning with
written digits boundaries of a example using polynomial kernel
VotingClassifier eigenfaces and SVMs approximation
Comparison between Confusion matrix Custom refit strategy Nested versus non-
grid search and of a grid search with nested cross-
successive halving cross-validation validation
https://scikit-learn.org/stable/modules/generated/sklearn.svm.SVC.html#sklearn.svm.SVC 17/19
18/07/24, 22:13 SVC — scikit-learn 1.5.1 documentation
Effect of varying Plot classification Plot different SVM RBF SVM parameters
threshold for self- boundaries with classifiers in the iris
training different SVM Kernels dataset
https://scikit-learn.org/stable/modules/generated/sklearn.svm.SVC.html#sklearn.svm.SVC 18/19
18/07/24, 22:13 SVC — scikit-learn 1.5.1 documentation
SVM Margins SVM Tie Breaking SVM with custom SVM-Anova: SVM
Example Example kernel with univariate
feature selection
https://scikit-learn.org/stable/modules/generated/sklearn.svm.SVC.html#sklearn.svm.SVC 19/19