Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a warning to prefer LinearSVM over SVM(kernel='linear') #4382

Merged
Merged
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
10 changes: 10 additions & 0 deletions python/cuml/svm/svm_base.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@ from cuml.common.exceptions import NotFittedError
from cuml.raft.common.handle cimport handle_t
from cuml.common import input_to_cuml_array
from cuml.common import using_output_type
from cuml.common.logger import warn
from cuml.common.mixins import FMajorInputTagMixin
from libcpp cimport bool


cdef extern from "cuml/matrix/kernelparams.h" namespace "MLCommon::Matrix":
enum KernelType:
LINEAR,
Expand Down Expand Up @@ -246,6 +248,14 @@ class SVMBase(Base,
self._model = None # structure of the model parameters
self._freeSvmBuffers = False # whether to call the C++ lib for cleanup

if (kernel == 'linear' or (kernel == 'poly' and degree == 1)) \
and not getattr(type(self), "_linear_kernel_warned", False):
setattr(type(self), "_linear_kernel_warned", True)
cname = type(self).__name__
warn(f'{cname} with the linear kernel can be much faster using '
f'the specialized solver provided by Linear{cname}. Consider '
f'switching to Linear{cname} if tranining takes too long.')

def __del__(self):
self._dealloc()

Expand Down