Skip to content

Commit

Permalink
Revert remaining changes and update base class for verbosity compatib…
Browse files Browse the repository at this point in the history
…ility
  • Loading branch information
vyasr committed Dec 12, 2024
1 parent 6d90bbb commit 8cbb2fe
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 15 deletions.
10 changes: 9 additions & 1 deletion python/cuml/cuml/internals/base.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,15 @@ class Base(TagsMixin,
self.handle = None

IF GPUBUILD == 1:
self.verbose = logger.level_enum(verbose)
# Internally, self.verbose follows the spdlog/c++ standard of
# 0 is most logging, and logging decreases from there.
# So if the user passes an int value for logging, we convert it.
if verbose is True:
self.verbose = logger.level_enum.debug
elif verbose is False:
self.verbose = logger.level_enum.info
else:
self.verbose = logger.level_enum(verbose)
ELSE:
self.verbose = verbose

Expand Down
3 changes: 2 additions & 1 deletion python/cuml/cuml/manifold/umap.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import cuml.internals
from cuml.internals.base import UniversalBase
from cuml.common.doc_utils import generate_docstring
from cuml.internals import logger
from cuml.internals.logger cimport level_enum
from cuml.internals.available_devices import is_cuda_available
from cuml.internals.input_utils import input_to_cuml_array
from cuml.internals.array import CumlArray
Expand Down Expand Up @@ -469,7 +470,7 @@ class UMAP(UniversalBase,
umap_params.repulsion_strength = <float> cls.repulsion_strength
umap_params.negative_sample_rate = <int> cls.negative_sample_rate
umap_params.transform_queue_size = <int> cls.transform_queue_size
umap_params.verbosity = cls.verbose
umap_params.verbosity = <level_enum> cls.verbose
umap_params.a = <float> cls.a
umap_params.b = <float> cls.b
if cls.init == "spectral":
Expand Down
12 changes: 6 additions & 6 deletions python/cuml/cuml/svm/svc.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ import cuml.internals
from cuml.internals.array import CumlArray
from cuml.internals.mixins import ClassifierMixin
from cuml.common.doc_utils import generate_docstring
from cuml.internals import logger
from cuml.internals cimport logger
from cuml.internals.logger import warn
from cuml.internals.logger cimport level_enum
from pylibraft.common.handle cimport handle_t
from pylibraft.common.interruptible import cuda_interruptible
from cuml.common import input_to_cuml_array, input_to_host_array, input_to_host_array_with_sparse_support
Expand Down Expand Up @@ -77,7 +77,7 @@ cdef extern from "cuml/svm/svm_parameter.h" namespace "ML::SVM":
int max_iter
int nochange_steps
double tol
logger.level_enum verbosity
level_enum verbosity
double epsilon
SvmType svmType

Expand Down Expand Up @@ -353,7 +353,7 @@ class SVC(SVMBase,
self.probability = probability
self.random_state = random_state
if probability and random_state is not None:
logger.warn("Random state is currently ignored by probabilistic SVC")
warn("Random state is currently ignored by probabilistic SVC")
self.class_weight = class_weight
self.svmType = C_SVC
self.multiclass_strategy = multiclass_strategy
Expand Down Expand Up @@ -405,8 +405,8 @@ class SVC(SVMBase,

def _fit_multiclass(self, X, y, sample_weight) -> "SVC":
if sample_weight is not None:
logger.warn("Sample weights are currently ignored for multi class "
"classification")
warn("Sample weights are currently ignored for multi class "
"classification")
if not has_sklearn():
raise RuntimeError("Scikit-learn is needed to fit multiclass SVM")

Expand Down
12 changes: 6 additions & 6 deletions python/cuml/cuml/svm/svm_base.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ from pylibraft.common.handle cimport handle_t
from cuml.common import input_to_cuml_array
from cuml.internals.input_utils import determine_array_type_full
from cuml.common import using_output_type
from cuml.internals import logger
from cuml.internals cimport logger
from cuml.internals.logger import warn
from cuml.internals.logger cimport level_enum
from cuml.internals.mixins import FMajorInputTagMixin
from cuml.internals.array_sparse import SparseCumlArray, SparseCumlArrayInput
from libcpp cimport bool
Expand Down Expand Up @@ -69,7 +69,7 @@ cdef extern from "cuml/svm/svm_parameter.h" namespace "ML::SVM":
int max_iter
int nochange_steps
double tol
logger.level_enum verbosity
level_enum verbosity
double epsilon
SvmType svmType

Expand Down Expand Up @@ -264,9 +264,9 @@ class SVMBase(Base,
and not getattr(type(self), "_linear_kernel_warned", False):
setattr(type(self), "_linear_kernel_warned", True)
cname = type(self).__name__
logger.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.')
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
1 change: 0 additions & 1 deletion python/cuml/cuml/svm/svr.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ from cuml.internals.array import CumlArray
from cuml.internals.array_sparse import SparseCumlArray
from cuml.internals.input_utils import determine_array_type_full
from cuml.internals.mixins import RegressorMixin
from cuml.internals import logger
from cuml.common.doc_utils import generate_docstring
from pylibraft.common.handle cimport handle_t
from cuml.common import input_to_cuml_array
Expand Down

0 comments on commit 8cbb2fe

Please sign in to comment.