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
16 changes: 0 additions & 16 deletions python/cuml/cuml/cluster/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,3 @@
from cuml.cluster.dbscan import DBSCAN
from cuml.cluster.hdbscan import HDBSCAN
from cuml.cluster.kmeans import KMeans


def __getattr__(name):
import warnings

if name in ("all_points_membership_vectors", "approximate_predict"):
warnings.warn(
f"Accessing {name!r} from the `cuml.cluster` namespace is deprecated "
"and will be removed in 25.10. Please access it from the "
"`cuml.cluster.hdbscan` namespace instead.",
FutureWarning,
)
import cuml.cluster.hdbscan as mod

return getattr(mod, name)
raise AttributeError(f"module `cuml.cluster` has no attribute {name!r}")
1 change: 0 additions & 1 deletion python/cuml/cuml/cluster/hdbscan/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
# limitations under the License.
#

import cuml.cluster.hdbscan.prediction as prediction
from cuml.cluster.hdbscan.hdbscan import (
HDBSCAN,
all_points_membership_vectors,
Expand Down
11 changes: 0 additions & 11 deletions python/cuml/cuml/cluster/hdbscan/hdbscan.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
#

# distutils: language = c++
import warnings

import cupy as cp
import numpy as np
from pylibraft.common.handle import Handle
Expand Down Expand Up @@ -645,7 +643,6 @@ class HDBSCAN(Base, InteropMixin, ClusterMixin, CMajorInputTagMixin):
"cluster_selection_method",
"allow_single_cluster",
"gen_min_span_tree",
"connectivity",
"prediction_data"
]

Expand Down Expand Up @@ -754,7 +751,6 @@ class HDBSCAN(Base, InteropMixin, ClusterMixin, CMajorInputTagMixin):
gen_min_span_tree=False,
handle=None,
verbose=False,
connectivity='deprecated',
output_type=None,
prediction_data=False):

Expand All @@ -765,12 +761,6 @@ class HDBSCAN(Base, InteropMixin, ClusterMixin, CMajorInputTagMixin):
if min_samples is None:
min_samples = min_cluster_size

if connectivity != "deprecated":
warnings.warn(
"The `connectivity` parameter is deprecated and will be removed in 25.10",
FutureWarning,
)

if 2 < min_samples and min_samples > 1023:
raise ValueError("'min_samples' must be a positive number "
"between 2 and 1023")
Expand All @@ -784,7 +774,6 @@ class HDBSCAN(Base, InteropMixin, ClusterMixin, CMajorInputTagMixin):
self.alpha = alpha
self.cluster_selection_method = cluster_selection_method
self.allow_single_cluster = allow_single_cluster
self.connectivity = connectivity
self.gen_min_span_tree = gen_min_span_tree
self.prediction_data = prediction_data

Expand Down
36 changes: 0 additions & 36 deletions python/cuml/cuml/cluster/hdbscan/prediction.py

This file was deleted.

38 changes: 1 addition & 37 deletions python/cuml/cuml/fil/fil.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#
import itertools
import pathlib
import warnings
from time import perf_counter

import numpy as np
Expand Down Expand Up @@ -621,7 +620,6 @@ class ForestInference(Base, CMajorInputTagMixin):
output_type=None,
verbose=False,
is_classifier=False,
default_threshold=None,
layout='depth_first',
default_chunk_size=None,
align_bytes=None,
Expand All @@ -631,9 +629,6 @@ class ForestInference(Base, CMajorInputTagMixin):
super().__init__(
handle=handle, verbose=verbose, output_type=output_type
)
# TODO(hcho3): 25.10: Remove this parameter; direct users to set `threshold`
# in predict()
self.default_threshold = default_threshold if default_threshold else 0.5
self.is_classifier = is_classifier
self.default_chunk_size = default_chunk_size
self.align_bytes = align_bytes
Expand Down Expand Up @@ -727,7 +722,6 @@ class ForestInference(Base, CMajorInputTagMixin):
path,
*,
is_classifier=False,
threshold=None,
precision='single',
model_type=None,
output_type=None,
Expand All @@ -749,8 +743,6 @@ class ForestInference(Base, CMajorInputTagMixin):
made to load the file based on its extension.
is_classifier : boolean, default=False
True for classification models, False for regressors
threshold : float
Deprecated in 25.08. Please set `threshold` in `predict()` instead.
precision : {'single', 'double', None}, default='single'
Use the given floating point precision for evaluating the model. If
None, use the native precision of the model. Note that
Expand Down Expand Up @@ -791,12 +783,6 @@ class ForestInference(Base, CMajorInputTagMixin):
For GPU execution, the RAFT handle containing the stream or stream
pool to use during loading and inference.
"""
if threshold is not None:
warnings.warn(
"The `threshold` parameter of `load()` is deprecated and "
"will be removed in 25.10. Please set `threshold` in `predict()` instead.",
FutureWarning
)
if model_type is None:
extension = pathlib.Path(path).suffix
if extension == '.json':
Expand Down Expand Up @@ -827,7 +813,6 @@ class ForestInference(Base, CMajorInputTagMixin):
output_type=output_type,
verbose=verbose,
is_classifier=is_classifier,
default_threshold=threshold,
default_chunk_size=default_chunk_size,
align_bytes=align_bytes,
layout=layout,
Expand All @@ -841,7 +826,6 @@ class ForestInference(Base, CMajorInputTagMixin):
skl_model,
*,
is_classifier=False,
threshold=None,
precision='single',
model_type=None,
output_type=None,
Expand All @@ -859,8 +843,6 @@ class ForestInference(Base, CMajorInputTagMixin):
The Scikit-Learn forest model to load.
is_classifier : boolean, default=False
True for classification models, False for regressors
threshold : float
Deprecated in 25.08. Please set `threshold` in `predict()` instead.
precision : {'single', 'double', None}, default='single'
Use the given floating point precision for evaluating the model. If
None, use the native precision of the model. Note that
Expand Down Expand Up @@ -911,20 +893,13 @@ class ForestInference(Base, CMajorInputTagMixin):
For GPU execution, the RAFT handle containing the stream or stream
pool to use during loading and inference.
"""
if threshold is not None:
warnings.warn(
"The `threshold` parameter of `load_from_sklearn()` is deprecated and "
"will be removed in 25.10. Please set `threshold` in `predict()` instead.",
FutureWarning
)
tl_model = treelite.sklearn.import_model(skl_model)
result = cls(
treelite_model=tl_model,
handle=handle,
output_type=output_type,
verbose=verbose,
is_classifier=is_classifier,
default_threshold=threshold,
default_chunk_size=default_chunk_size,
align_bytes=align_bytes,
layout=layout,
Expand All @@ -939,7 +914,6 @@ class ForestInference(Base, CMajorInputTagMixin):
tl_model,
*,
is_classifier=False,
threshold=None,
precision='single',
model_type=None,
output_type=None,
Expand All @@ -957,8 +931,6 @@ class ForestInference(Base, CMajorInputTagMixin):
The Treelite model to load.
is_classifier : boolean, default=False
True for classification models, False for regressors
threshold : float
Deprecated in 25.08. Please set `threshold` in `predict()` instead.
precision : {'single', 'double', None}, default='single'
Use the given floating point precision for evaluating the model. If
None, use the native precision of the model. Note that
Expand Down Expand Up @@ -1009,19 +981,12 @@ class ForestInference(Base, CMajorInputTagMixin):
For GPU execution, the RAFT handle containing the stream or stream
pool to use during loading and inference.
"""
if threshold is not None:
warnings.warn(
"The `threshold` parameter of `load_from_treelite_model()` is deprecated and "
"will be removed in 25.10. Please set `threshold` in `predict()` instead.",
FutureWarning
)
return cls(
treelite_model=tl_model,
handle=handle,
output_type=output_type,
verbose=verbose,
is_classifier=is_classifier,
default_threshold=threshold,
default_chunk_size=default_chunk_size,
align_bytes=align_bytes,
layout=layout,
Expand Down Expand Up @@ -1156,7 +1121,7 @@ class ForestInference(Base, CMajorInputTagMixin):
proba = self.forest.predict(X, chunk_size=chunk_size)
if len(proba.shape) < 2 or proba.shape[1] == 1:
if threshold is None:
threshold = self.default_threshold
threshold = 0.5
result = (
proba.to_output(output_type='array') > threshold
).astype('int')
Expand Down Expand Up @@ -1413,7 +1378,6 @@ class ForestInference(Base, CMajorInputTagMixin):
"output_type",
"verbose",
"is_classifier",
"default_threshold",
"layout",
"default_chunk_size",
"align_bytes",
Expand Down
11 changes: 1 addition & 10 deletions python/cuml/cuml/solvers/sgd.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
#

# distutils: language = c++
import warnings

import cupy as cp
import numpy as np

Expand Down Expand Up @@ -230,14 +228,7 @@ class SGD(Base,
else:
raise ValueError(f"loss {loss!r} is not supported")

if penalty == 'none':
warnings.warn(
"penalty='none' is deprecated and will be removed in 25.10. Please use "
"`penalty=None` instead.",
FutureWarning,
)
self.penalty = None
elif penalty in [None, 'l1', 'l2', 'elasticnet']:
if penalty in [None, 'l1', 'l2', 'elasticnet']:
self.penalty = penalty
else:
raise ValueError(f"penalty {penalty!r} is not supported")
Expand Down
23 changes: 0 additions & 23 deletions python/cuml/tests/test_fil.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,29 +552,6 @@ def test_chunk_size(chunk_size, small_classifier_and_preds):
np.testing.assert_array_equal(fil_preds, xgb_preds_int)


@pytest.mark.parametrize("is_classifier", [True, False])
def test_thresholding(is_classifier, small_classifier_and_preds):
model_path, model_type, X, xgb_preds = small_classifier_and_preds
fm = ForestInference.load(
model_path,
model_type=model_type,
is_classifier=is_classifier,
)
fil_preds = np.asarray(fm.predict(X, threshold=0.5))
if is_classifier:
assert ((fil_preds != 0.0) & (fil_preds != 1.0)).sum() == 0
else:
assert ((fil_preds != 0.0) & (fil_preds != 1.0)).sum() > 0

with pytest.warns(FutureWarning):
_ = ForestInference.load(
model_path,
model_type=model_type,
is_classifier=is_classifier,
threshold=0.5,
)


@pytest.mark.parametrize("train_device", ("cpu", "gpu"))
@pytest.mark.parametrize("infer_device", ("cpu", "gpu"))
def test_output_args(train_device, infer_device, small_classifier_and_preds):
Expand Down
38 changes: 0 additions & 38 deletions python/cuml/tests/test_hdbscan.py
Original file line number Diff line number Diff line change
Expand Up @@ -1144,44 +1144,6 @@ def test_membership_vector_circles(
assert_membership_vectors(cu_membership_vectors, sk_membership_vectors)


def test_prediction_namespace_deprecated():
# Attribute access warns
with pytest.warns(FutureWarning, match="all_points_membership_vectors"):
func = cuml.cluster.hdbscan.prediction.all_points_membership_vectors

assert func is cuml.cluster.hdbscan.all_points_membership_vectors

# Imports warn
with pytest.warns(FutureWarning, match="all_points_membership_vectors"):
from cuml.cluster.hdbscan.prediction import (
all_points_membership_vectors as func,
)

assert func is cuml.cluster.hdbscan.all_points_membership_vectors

# Unknown attribute errors
with pytest.raises(AttributeError, match="not_a_real_attr"):
cuml.cluster.hdbscan.prediction.not_a_real_attr


def test_prediction_functions_cluster_namespace_deprecated():
# Attribute access warns
with pytest.warns(FutureWarning, match="all_points_membership_vectors"):
func = cuml.cluster.all_points_membership_vectors

assert func is cuml.cluster.hdbscan.all_points_membership_vectors

# Imports warn
with pytest.warns(FutureWarning, match="all_points_membership_vectors"):
from cuml.cluster import all_points_membership_vectors as func

assert func is cuml.cluster.hdbscan.all_points_membership_vectors

# Unknown attribute errors
with pytest.raises(AttributeError, match="not_a_real_attr"):
cuml.cluster.not_a_real_attr


def test_all_points_membership_vectors_output_type():
X, y = make_blobs(random_state=42)
X_df = pd.DataFrame(X, index=[f"row{i}" for i in range(X.shape[0])])
Expand Down
6 changes: 0 additions & 6 deletions python/cuml/tests/test_sgd.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@
from cuml.solvers import SGD as cumlSGD


def test_sgd_penalty_none_deprecated():
with pytest.warns(FutureWarning, match="penalty='none' is deprecated"):
solver = cumlSGD(penalty="none")
assert solver.penalty is None


@pytest.mark.parametrize("lrate", ["constant", "invscaling", "adaptive"])
@pytest.mark.parametrize("dtype", [np.float32, np.float64])
@pytest.mark.parametrize("penalty", [None, "l1", "l2", "elasticnet"])
Expand Down