Skip to content
Merged
Show file tree
Hide file tree
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
30 changes: 0 additions & 30 deletions python/cuml/cuml/dask/ensemble/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,6 @@ def _create_model(
)
self.workers = workers
self._set_internal_model(None)
# rapids-pre-commit-hooks: disable-next-line
# TODO(26.08): Drop along with the single-GPU deprecation in
# cuml.ensemble.randomforest_common.
# Record whether the user explicitly set `max_depth`; the warning is
# emitted from `_fit` so it fires at fit time (matching the single-GPU
# path) rather than at construction. We still forward an explicit
# `max_depth=16` to the per-worker single-GPU estimators so they don't
# each emit their own FutureWarning.
self._max_depth_user_set = "max_depth" in kwargs
if not self._max_depth_user_set:
kwargs["max_depth"] = 16

self.active_workers = list()
self.ignore_empty_partitions = ignore_empty_partitions
self.n_estimators = n_estimators
Expand Down Expand Up @@ -101,19 +89,6 @@ def _estimators_per_worker(self, n_estimators):
return n_estimators_per_worker

def _fit(self, model, dataset, convert_dtype, broadcast_data):
# rapids-pre-commit-hooks: disable-next-line
# TODO(26.08): Drop along with the single-GPU deprecation in
# cuml.ensemble.randomforest_common.
if not getattr(self, "_max_depth_user_set", True):
warnings.warn(
"The default value of 'max_depth' will change from 16 to "
# rapids-pre-commit-hooks: disable-next-line
"None (unlimited depth) in release 26.08. To suppress this "
"warning, set 'max_depth' explicitly.",
FutureWarning,
stacklevel=3,
)

data = DistributedDataHandler.create(dataset, client=self.client)
self.active_workers = data.workers
self.datatype = data.datatype
Expand Down Expand Up @@ -255,11 +230,6 @@ def _get_params(self, deep):
return params_of_each_model

def _set_params(self, **params):
# rapids-pre-commit-hooks: disable-next-line
# TODO(26.08): Drop along with the single-GPU deprecation in
# cuml.ensemble.randomforest_common.
if "max_depth" in params:
self._max_depth_user_set = True
model_params = list()
for idx, worker in enumerate(self.workers):
model_params.append(
Expand Down
7 changes: 2 additions & 5 deletions python/cuml/cuml/dask/ensemble/randomforestclassifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,13 @@ class RandomForestClassifier(
* If ``False``, the whole dataset is used to build each tree.
max_samples : float (default = 1.0)
Ratio of dataset rows used while fitting each tree.
max_depth : int or None (default = 16)
max_depth : int or None (default = None)
Maximum tree depth. Use ``None`` for unlimited depth (trees grow
until all leaves are pure). Must be a positive integer or ``None``.

.. note:: This default differs from scikit-learn's
random forest, which defaults to unlimited depth.

.. rapids-pre-commit-hooks: disable-next-line
.. versionchanged:: 26.08
The default of `max_depth` will change from `16` to `None`.
The default of `max_depth` changed from `16` to `None`.
max_leaves : int (default = -1)
Maximum leaf nodes per tree. Soft constraint. Unlimited, If ``-1``.
max_features : float (default = 'auto')
Expand Down
7 changes: 2 additions & 5 deletions python/cuml/cuml/dask/ensemble/randomforestregressor.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,13 @@ class RandomForestRegressor(
* If ``False``, the whole dataset is used to build each tree.
max_samples : float (default = 1.0)
Ratio of dataset rows used while fitting each tree.
max_depth : int or None (default = 16)
max_depth : int or None (default = None)
Maximum tree depth. Use ``None`` for unlimited depth (trees grow
until all leaves are pure). Must be a positive integer or ``None``.

.. note:: This default differs from scikit-learn's
random forest, which defaults to unlimited depth.

.. rapids-pre-commit-hooks: disable-next-line
.. versionchanged:: 26.08
The default of `max_depth` will change from `16` to `None`.
The default of `max_depth` changed from `16` to `None`.
max_leaves : int (default = -1)
Maximum leaf nodes per tree. Soft constraint. Unlimited, If ``-1``.
max_features : float (default = 'auto')
Expand Down
18 changes: 2 additions & 16 deletions python/cuml/cuml/ensemble/randomforest_common.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,6 @@ def compute_max_features(
)


_DEPRECATED_MAX_DEPTH_DEFAULT = "deprecated"


class BaseRandomForestModel(Base, InteropMixin):

@classmethod
Expand Down Expand Up @@ -248,9 +245,7 @@ class BaseRandomForestModel(Base, InteropMixin):
return {
"n_estimators": self.n_estimators,
"criterion": criterion,
"max_depth": (
16 if self.max_depth == _DEPRECATED_MAX_DEPTH_DEFAULT else self.max_depth
),
"max_depth": self.max_depth,
"min_samples_split": self.min_samples_split,
"min_samples_leaf": self.min_samples_leaf,
"max_features": self.max_features,
Expand Down Expand Up @@ -313,7 +308,7 @@ class BaseRandomForestModel(Base, InteropMixin):
n_estimators=100,
bootstrap=True,
max_samples=1.0,
max_depth=_DEPRECATED_MAX_DEPTH_DEFAULT,
max_depth=None,
max_leaves=-1,
max_features='sqrt',
n_bins=128,
Expand Down Expand Up @@ -472,15 +467,6 @@ class BaseRandomForestModel(Base, InteropMixin):
cdef int max_depth_c
max_depth = self.max_depth

if max_depth == _DEPRECATED_MAX_DEPTH_DEFAULT:
warnings.warn(
"The default value of 'max_depth' will change from 16 to "
# rapids-pre-commit-hooks: disable-next-line
"None (unlimited depth) in release 26.08. To suppress this "
"warning, set 'max_depth' explicitly.",
FutureWarning, stacklevel=3)
max_depth = 16

if max_depth is None:
max_depth_c = np.iinfo(np.int32).max
elif not isinstance(max_depth, int) or max_depth <= 0:
Expand Down
9 changes: 3 additions & 6 deletions python/cuml/cuml/ensemble/randomforestclassifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,13 @@ class RandomForestClassifier(BaseRandomForestModel, ClassifierMixin):
* If ``False``, the whole dataset is used to build each tree.
max_samples : float (default = 1.0)
Ratio of dataset rows used while fitting each tree.
max_depth : int or None (default = 16)
max_depth : int or None (default = None)
Maximum tree depth. Use ``None`` for unlimited depth (trees grow
until all leaves are pure). Must be a positive integer or ``None``.

.. note:: This default differs from scikit-learn's random forest,
which defaults to unlimited depth.

.. rapids-pre-commit-hooks: disable-next-line
.. versionchanged:: 26.08
The default of `max_depth` will change from `16` to `None`.
The default of `max_depth` changed from `16` to `None`.
max_leaves : int (default = -1)
Maximum leaf nodes per tree. Soft constraint. Unlimited,
If ``-1``.
Expand Down Expand Up @@ -194,7 +191,7 @@ def __init__(
split_criterion="gini",
bootstrap=True,
max_samples=1.0,
max_depth="deprecated",
max_depth=None,
max_leaves=-1,
max_features="sqrt",
n_bins=128,
Expand Down
9 changes: 3 additions & 6 deletions python/cuml/cuml/ensemble/randomforestregressor.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,13 @@ class RandomForestRegressor(BaseRandomForestModel, RegressorMixin):
* If ``False``, the whole dataset is used to build each tree.
max_samples : float (default = 1.0)
Ratio of dataset rows used while fitting each tree.
max_depth : int or None (default = 16)
max_depth : int or None (default = None)
Maximum tree depth. Use ``None`` for unlimited depth (trees grow
until all leaves are pure). Must be a positive integer or ``None``.

.. note:: This default differs from scikit-learn's random forest,
which defaults to unlimited depth.

.. rapids-pre-commit-hooks: disable-next-line
.. versionchanged:: 26.08
The default of `max_depth` will change from `16` to `None`.
The default of `max_depth` changed from `16` to `None`.
max_leaves : int (default = -1)
Maximum leaf nodes per tree. Soft constraint. Unlimited,
If ``-1``.
Expand Down Expand Up @@ -164,7 +161,7 @@ def __init__(
split_criterion="mse",
bootstrap=True,
max_samples=1.0,
max_depth="deprecated",
max_depth=None,
max_leaves=-1,
max_features=1.0,
n_bins=128,
Expand Down
6 changes: 0 additions & 6 deletions python/cuml/tests/dask/test_dask_random_forest.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,6 @@
from cuml.ensemble import RandomForestClassifier as cuRFC_sg
from cuml.ensemble import RandomForestRegressor as cuRFR_sg

# rapids-pre-commit-hooks: disable-next-line
# TODO(26.08): Remove this filter
pytestmark = pytest.mark.filterwarnings(
"ignore:The default value of 'max_depth':FutureWarning"
)


def _prep_training_data(c, X_train, y_train, partitions_per_worker):
workers = c.has_what().keys()
Expand Down
5 changes: 0 additions & 5 deletions python/cuml/tests/explainer/test_explainer_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@
pytest.mark.filterwarnings(
"ignore:cuml.fil.ForestInference.* is deprecated:FutureWarning"
),
# rapids-pre-commit-hooks: disable-next-line
# TODO(26.08) Remove this filter
pytest.mark.filterwarnings(
"ignore:The default value of 'max_depth':FutureWarning"
),
]
models_config = ClassEnumerator(module=cuml)
models = models_config.get_models()
Expand Down
5 changes: 0 additions & 5 deletions python/cuml/tests/explainer/test_explainer_kernel_shap.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@
from cuml.testing.datasets import with_dtype
from cuml.testing.utils import ClassEnumerator, get_shap_values

# rapids-pre-commit-hooks: disable-next-line
# TODO(26.08): Remove this filter
pytestmark = pytest.mark.filterwarnings(
"ignore:The default value of 'max_depth':FutureWarning"
)
models_config = ClassEnumerator(module=cuml)
models = models_config.get_models()

Expand Down
7 changes: 0 additions & 7 deletions python/cuml/tests/explainer/test_gpu_treeshap.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,6 @@
shap = pytest.importorskip("shap")


# rapids-pre-commit-hooks: disable-next-line
# TODO(26.08): Remove this filter
pytestmark = pytest.mark.filterwarnings(
"ignore:The default value of 'max_depth':FutureWarning"
)


def make_classification_with_categorical(
*,
n_samples,
Expand Down
5 changes: 1 addition & 4 deletions python/cuml/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,8 @@ def test_mro(model):


@pytest.mark.parametrize("model_name", list(models.keys()))
# ignore random forest float64 warnings and max_depth deprecation
# ignore random forest float64 warnings
@pytest.mark.filterwarnings("ignore:To use pickling or GPU-based")
# rapids-pre-commit-hooks: disable-next-line
# TODO(26.08): Remove this filter
@pytest.mark.filterwarnings("ignore:The default value of 'max_depth'")
def test_fit_function(dataset, model_name):
# This test ensures that our estimators return self after a call to fit
if model_name in [
Expand Down
11 changes: 1 addition & 10 deletions python/cuml/tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,8 @@ def get_param_doc(param_doc_obj, name: str):


@pytest.mark.parametrize("child_class", list(all_base_children.keys()))
# ignore ColumnTransformer init warning and max_depth deprecation
# ignore ColumnTransformer init warning
@pytest.mark.filterwarnings("ignore:Transformers are required")
# rapids-pre-commit-hooks: disable-next-line
# TODO(26.08) Remove this filter
@pytest.mark.filterwarnings("ignore:The default value of 'max_depth'")
@pytest.mark.filterwarnings("ignore::FutureWarning")
def test_base_children__get_param_names(child_class: str):
"""
Expand Down Expand Up @@ -302,9 +299,6 @@ def test_get_handle_device_ids():
and hasattr(cls, "predict")
],
)
# rapids-pre-commit-hooks: disable-next-line
# TODO(26.08) Remove this filter
@pytest.mark.filterwarnings("ignore:The default value of 'max_depth'")
def test_regressor_predict_dtype(cls):
X, y = make_regression(n_samples=200, random_state=42)
X32 = X.astype("float32")
Expand Down Expand Up @@ -345,9 +339,6 @@ def test_regressor_predict_dtype(cls):
],
)
# rapids-pre-commit-hooks: disable-next-line
# TODO(26.08) Remove this filter
@pytest.mark.filterwarnings("ignore:The default value of 'max_depth'")
# rapids-pre-commit-hooks: disable-next-line
# TODO(26.08): Remove once `probability` is removed from cuml.svm.SVC.
@pytest.mark.filterwarnings(
"ignore:The `probability` parameter is deprecated:FutureWarning"
Expand Down
3 changes: 0 additions & 3 deletions python/cuml/tests/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@
],
)
@pytest.mark.filterwarnings("ignore:The number of bins.*:UserWarning")
# rapids-pre-commit-hooks: disable-next-line
# TODO(26.08) Remove this filter
@pytest.mark.filterwarnings("ignore:The default value of 'max_depth'")
def test_random_state_argument(Estimator):
X, y = make_blobs(random_state=0)
# Check that both integer and np.random.RandomState are accepted
Expand Down
3 changes: 0 additions & 3 deletions python/cuml/tests/test_fil.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@
pytest.mark.filterwarnings(
r"ignore:.*as_fil\(\) method is deprecated.*:FutureWarning"
),
pytest.mark.filterwarnings(
"ignore:The default value of 'max_depth':FutureWarning"
),
]


Expand Down
6 changes: 0 additions & 6 deletions python/cuml/tests/test_meta_estimators.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@
from cuml.svm import SVC
from cuml.testing.utils import ClassEnumerator

# rapids-pre-commit-hooks: disable-next-line
# TODO(26.08): Remove this filter
pytestmark = pytest.mark.filterwarnings(
"ignore:The default value of 'max_depth':FutureWarning"
)


def test_pipeline():
X, y = make_classification(random_state=0)
Expand Down
6 changes: 0 additions & 6 deletions python/cuml/tests/test_pickle.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@
from cuml.tsa.arima import ARIMA

pytestmark = [
# rapids-pre-commit-hooks: disable-next-line
# TODO(26.08): Remove this filter
pytest.mark.filterwarnings(
"ignore:The default value of 'max_depth':FutureWarning"
),
# rapids-pre-commit-hooks: disable-next-line
# TODO(26.08): Remove once `probability` is removed from cuml.svm.SVC/LinearSVC.
pytest.mark.filterwarnings(
Expand Down Expand Up @@ -381,7 +376,6 @@ def assert_model(pickled_model, X_train):
@pytest.mark.filterwarnings(
"ignore:Transformers((.|\n)*):UserWarning:cuml[.*]"
)
@pytest.mark.filterwarnings("ignore:The default value of 'max_depth'")
def test_unfit_pickle(model_name):
# Any model xfailed in this test cannot be used for hyperparameter sweeps
# with dask or sklearn
Expand Down
18 changes: 5 additions & 13 deletions python/cuml/tests/test_random_forest.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@
from cuml.metrics import r2_score
from cuml.testing.utils import quality_param, stress_param, unit_param

# rapids-pre-commit-hooks: disable-next-line
# TODO(26.08): Remove this filter
pytestmark = pytest.mark.filterwarnings(
"ignore:The default value of 'max_depth':FutureWarning"
)


@pytest.fixture(
scope="session",
Expand Down Expand Up @@ -190,23 +184,18 @@ def special_reg(request):
return X, y


@pytest.mark.filterwarnings(
"default:The default value of 'max_depth':FutureWarning"
)
def test_default_parameters():
X = np.array([[1.0, 2.0]], dtype=np.float32)
y_reg = np.array([1.0], dtype=np.float32)
y_clf = np.array([1], dtype=np.int32)

reg = curfr()
reg_params = reg.get_params()
with pytest.warns(FutureWarning, match="The default value of 'max_depth'"):
reg.fit(X, y_reg)
reg.fit(X, y_reg)

clf = curfc()
clf_params = clf.get_params()
with pytest.warns(FutureWarning, match="The default value of 'max_depth'"):
clf.fit(X, y_clf)
clf.fit(X, y_clf)

with warnings.catch_warnings():
warnings.simplefilter("error", FutureWarning)
Expand All @@ -223,6 +212,9 @@ def test_default_parameters():
assert reg_params["split_criterion"] == "mse"
assert clf_params["split_criterion"] == "gini"

assert reg_params["max_depth"] is None
assert clf_params["max_depth"] is None

# Drop differing params
for name in ["max_features", "split_criterion"]:
reg_params.pop(name)
Expand Down
Loading
Loading