Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions sklearn/svm/_classes.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import warnings
from warnings import warn
from numbers import Integral, Real

import numpy as np
Expand Down Expand Up @@ -307,6 +308,7 @@ def fit(self, X, y, sample_weight=None):
self : object
An instance of the estimator.
"""

X, y = self._validate_data(
X,
y,
Expand All @@ -315,8 +317,23 @@ def fit(self, X, y, sample_weight=None):
order="C",
accept_large_sparse=False,
)

check_classification_targets(y)

self.classes_ = np.unique(y)
if self.kernel == 'linear':
if self.gamma not in ('scale', 'auto'):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's warn for all non-default values

Suggested change
if self.gamma not in ('scale', 'auto'):
if self.gamma != "scale":

warn(
"The 'gamma' parameter has been set but is not relevant for the 'linear' kernel. It will be ignored.",
UserWarning)
if self.coef0 != 0:
warn(
"The 'coef0' parameter has been set but is not relevant for the 'linear' kernel. It will be ignored.",
UserWarning)
if self.degree != 3:
warn(
"The 'degree' parameter has been set but is not relevant for the 'linear' kernel. It will be ignored.",
UserWarning)

_dual = _validate_dual_parameter(
self.dual, self.loss, self.penalty, self.multi_class, X
Expand Down