Skip to content

Commit 83f10b7

Browse files
committed
simplify tests and move code around
1 parent c5830e2 commit 83f10b7

File tree

4 files changed

+18
-49
lines changed

4 files changed

+18
-49
lines changed

python/cuml/dask/ensemble/base.py

+17
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,23 @@ def _get_json(self):
257257
combined_dump.extend(obj)
258258
return json.dumps(combined_dump)
259259

260+
def get_combined_model(self):
261+
"""
262+
Return single-GPU model for serialization.
263+
264+
Returns
265+
-------
266+
267+
model : Trained single-GPU model or None if the model has not
268+
yet been trained.
269+
"""
270+
271+
# set internal model if it hasn't been accessed before
272+
if self._get_internal_model() is None:
273+
self._set_internal_model(self._concat_treelite_models())
274+
275+
return BaseEstimator.get_combined_model(self)
276+
260277

261278
def _func_fit(model, input_data, convert_dtype):
262279
X = concatenate([item[0] for item in input_data])

python/cuml/dask/ensemble/randomforestclassifier.py

-17
Original file line numberDiff line numberDiff line change
@@ -206,23 +206,6 @@ def get_summary_text(self):
206206
"""
207207
return self._get_summary_text()
208208

209-
def get_combined_model(self):
210-
"""
211-
Return single-GPU model for serialization.
212-
213-
Returns
214-
-------
215-
216-
model : Trained single-GPU model or None if the model has not
217-
yet been trained.
218-
"""
219-
220-
# set internal model if it hasn't been accessed before
221-
if self._get_internal_model() is None:
222-
self._set_internal_model(self._concat_treelite_models())
223-
224-
return BaseEstimator.get_combined_model(self)
225-
226209
def get_detailed_text(self):
227210
"""
228211
Obtain the detailed information for the random forest model, as text

python/cuml/dask/ensemble/randomforestregressor.py

-17
Original file line numberDiff line numberDiff line change
@@ -206,23 +206,6 @@ def get_summary_text(self):
206206
"""
207207
return self._get_summary_text()
208208

209-
def get_combined_model(self):
210-
"""
211-
Return single-GPU model for serialization.
212-
213-
Returns
214-
-------
215-
216-
model : Trained single-GPU model or None if the model has not
217-
yet been trained.
218-
"""
219-
220-
# set internal model if it hasn't been accessed before
221-
if self._get_internal_model() is None:
222-
self._set_internal_model(self._concat_treelite_models())
223-
224-
return BaseEstimator.get_combined_model(self)
225-
226209
def get_detailed_text(self):
227210
"""
228211
Obtain the detailed information for the random forest model, as text

python/cuml/test/dask/test_random_forest.py

+1-15
Original file line numberDiff line numberDiff line change
@@ -443,24 +443,13 @@ def predict_with_json_rf_regressor(rf, x):
443443
def test_rf_get_combined_model_right_aftter_fit(client, estimator_type):
444444
max_depth = 3
445445
n_estimators = 5
446-
X, y = make_classification(
447-
n_samples=350,
448-
n_features=20,
449-
n_clusters_per_class=1,
450-
n_informative=10,
451-
random_state=123,
452-
n_classes=2
453-
)
446+
X, y = make_classification()
454447
X = X.astype(np.float32)
455448
if estimator_type == 'classification':
456449
cu_rf_mg = cuRFC_mg(
457450
max_features=1.0,
458451
max_samples=1.0,
459452
n_bins=16,
460-
split_algo=0,
461-
split_criterion=0,
462-
min_samples_leaf=2,
463-
seed=23707,
464453
n_streams=1,
465454
n_estimators=n_estimators,
466455
max_leaves=-1,
@@ -472,9 +461,6 @@ def test_rf_get_combined_model_right_aftter_fit(client, estimator_type):
472461
max_features=1.0,
473462
max_samples=1.0,
474463
n_bins=16,
475-
split_algo=0,
476-
min_samples_leaf=2,
477-
seed=23707,
478464
n_streams=1,
479465
n_estimators=n_estimators,
480466
max_leaves=-1,

0 commit comments

Comments
 (0)