Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
5 changes: 2 additions & 3 deletions python/cuml/cuml/ensemble/randomforest_common.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,6 @@ class BaseRandomForestModel(Base, InteropMixin):
min_impurity_decrease=0.0,
max_batch_size=4096,
random_state=None,
criterion=None,
n_streams=4,
oob_score=False,
verbose=False,
Expand Down Expand Up @@ -644,8 +643,8 @@ class BaseRandomForestModel(Base, InteropMixin):
)
self.n_outputs_ = 1
self._treelite_model_bytes = <bytes>(tl_bytes[:tl_bytes_len])
# Ensure cached nvforest model is reset
self._nvforest_model = None
# Reload nvforest model
self._nvforest_model = self.as_nvforest()

# Compute OOB score if requested
if self.oob_score:
Expand Down
30 changes: 28 additions & 2 deletions python/cuml/cuml/ensemble/randomforestclassifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,16 +190,42 @@ def _attrs_to_cpu(self, model):
def __init__(
self,
*,
n_estimators=100,
split_criterion="gini",
bootstrap=True,
max_samples=1.0,
max_depth="deprecated",
max_leaves=-1,
max_features="sqrt",
n_bins=128,
min_samples_leaf=1,
min_samples_split=2,
min_impurity_decrease=0.0,
max_batch_size=4096,
random_state=None,
n_streams=4,
oob_score=False,
verbose=False,
output_type=None,
**kwargs,
):
super().__init__(
split_criterion=split_criterion,
n_estimators=n_estimators,
bootstrap=bootstrap,
max_samples=max_samples,
max_depth=max_depth,
max_leaves=max_leaves,
max_features=max_features,
n_bins=n_bins,
min_samples_leaf=min_samples_leaf,
min_samples_split=min_samples_split,
min_impurity_decrease=min_impurity_decrease,
max_batch_size=max_batch_size,
random_state=random_state,
n_streams=n_streams,
oob_score=oob_score,
verbose=verbose,
output_type=output_type,
**kwargs,
)

@nvtx.annotate(
Expand Down
28 changes: 26 additions & 2 deletions python/cuml/cuml/ensemble/randomforestregressor.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,18 +160,42 @@ class RandomForestRegressor(BaseRandomForestModel, RegressorMixin):
def __init__(
self,
*,
n_estimators=100,
split_criterion="mse",
bootstrap=True,
max_samples=1.0,
max_depth="deprecated",
max_leaves=-1,
max_features=1.0,
n_bins=128,
min_samples_leaf=1,
min_samples_split=2,
min_impurity_decrease=0.0,
max_batch_size=4096,
random_state=None,
n_streams=4,
oob_score=False,
verbose=False,
output_type=None,
**kwargs,
):
super().__init__(
n_estimators=n_estimators,
split_criterion=split_criterion,
bootstrap=bootstrap,
max_samples=max_samples,
max_depth=max_depth,
max_leaves=max_leaves,
max_features=max_features,
n_bins=n_bins,
min_samples_leaf=min_samples_leaf,
min_samples_split=min_samples_split,
min_impurity_decrease=min_impurity_decrease,
max_batch_size=max_batch_size,
random_state=random_state,
n_streams=n_streams,
oob_score=oob_score,
verbose=verbose,
output_type=output_type,
**kwargs,
)

@nvtx.annotate(
Expand Down
20 changes: 18 additions & 2 deletions python/cuml/cuml/neighbors/kneighbors_classifier.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,28 @@ class KNeighborsClassifier(ClassifierMixin, FMajorInputTagMixin, NeighborsBase):
def __init__(
self,
*,
n_neighbors=5,
algorithm="auto",
metric="euclidean",
weights="uniform",
p=2,
algo_params=None,
metric_params=None,
n_jobs=None, # Ignored, here for sklearn API compatibility
verbose=False,
output_type=None,
**kwargs,
):
super().__init__(verbose=verbose, output_type=output_type, **kwargs)
super().__init__(
n_neighbors=n_neighbors,
algorithm=algorithm,
metric=metric,
p=p,
algo_params=algo_params,
metric_params=metric_params,
n_jobs=n_jobs,
verbose=verbose,
output_type=output_type,
)
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
self.weights = weights

@generate_docstring(convert_dtype_cast='np.float32')
Expand Down
20 changes: 18 additions & 2 deletions python/cuml/cuml/neighbors/kneighbors_regressor.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,28 @@ class KNeighborsRegressor(RegressorMixin, FMajorInputTagMixin, NeighborsBase):
def __init__(
self,
*,
n_neighbors=5,
algorithm="auto",
metric="euclidean",
weights="uniform",
p=2,
algo_params=None,
metric_params=None,
n_jobs=None, # Ignored, here for sklearn API compatibility
verbose=False,
output_type=None,
**kwargs,
):
super().__init__(verbose=verbose, output_type=output_type, **kwargs)
super().__init__(
n_neighbors=n_neighbors,
algorithm=algorithm,
metric=metric,
p=p,
algo_params=algo_params,
metric_params=metric_params,
n_jobs=n_jobs,
verbose=verbose,
output_type=output_type,
)
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
self.weights = weights

@generate_docstring(convert_dtype_cast='np.float32')
Expand Down
2 changes: 1 addition & 1 deletion python/cuml/cuml/neighbors/nearest_neighbors.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -559,13 +559,13 @@ class NeighborsBase(Base, InteropMixin, CMajorInputTagMixin, SparseInputTagMixin
self,
*,
n_neighbors=5,
verbose=False,
algorithm="auto",
metric="euclidean",
p=2,
algo_params=None,
metric_params=None,
n_jobs=None, # Ignored, here for sklearn API compatibility
verbose=False,
output_type=None,
):
super().__init__(verbose=verbose, output_type=output_type)
Expand Down
8 changes: 1 addition & 7 deletions python/cuml/tests/test_sklearn_compatibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,24 +118,18 @@
},
RandomForestRegressor: {
"check_estimator_tags_renamed": "No support for modern tags infrastructure",
"check_do_not_raise_errors_in_init_or_set_params": "RandomForestRegressor raises errors in init or set_params",
"check_regressor_data_not_an_array": "RandomForestRegressor does not handle non-array data",
"check_dict_unchanged": "RandomForestRegressor modifies input dictionaries",
},
RandomForestClassifier: {
"check_estimator_tags_renamed": "No support for modern tags infrastructure",
"check_do_not_raise_errors_in_init_or_set_params": "RandomForestClassifier raises errors in init or set_params",
"check_classifier_data_not_an_array": "RandomForestClassifier does not handle non-array data",
"check_dict_unchanged": "RandomForestClassifier modifies input dictionaries",
},
KNeighborsClassifier: {
"check_estimator_tags_renamed": "No support for modern tags infrastructure",
"check_do_not_raise_errors_in_init_or_set_params": "KNeighborsClassifier raises errors in init or set_params",
"check_classifier_data_not_an_array": "KNeighborsClassifier does not handle non-array data",
},
KNeighborsRegressor: {
"check_estimator_tags_renamed": "No support for modern tags infrastructure",
"check_do_not_raise_errors_in_init_or_set_params": "KNeighborsRegressor raises errors in init or set_params",
"check_regressor_data_not_an_array": "KNeighborsRegressor does not handle non-array data",
"check_supervised_y_2d": "KNeighborsRegressor does not handle 2D y",
},
Expand Down Expand Up @@ -182,7 +176,7 @@
},
TSNE: {
"check_estimator_tags_renamed": "No support for modern tags infrastructure",
"check_dont_overwrite_parameters": "TSNE overwrites parameters during fit",
"check_dont_overwrite_parameters": "TSNE only supports n_components = 2",
"check_pipeline_consistency": "TSNE results are not deterministic",
"check_methods_sample_order_invariance": "TSNE results depend on sample order",
"check_methods_subset_invariance": "TSNE results depend on data subset",
Expand Down
Loading