Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e5d6c6d

Browse filesBrowse files
thomasjpfanTamaraAtanasoska
authored andcommitted
TST Improves testing for missing value support in random forest (scikit-learn#26939)
1 parent 168aeb9 commit e5d6c6d
Copy full SHA for e5d6c6d

File tree

Expand file treeCollapse file tree

1 file changed

+4
-1
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+4
-1
lines changed

‎sklearn/ensemble/tests/test_forest.py

Copy file name to clipboardExpand all lines: sklearn/ensemble/tests/test_forest.py
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1819,7 +1819,7 @@ def test_round_samples_to_one_when_samples_too_low(class_weight):
18191819
],
18201820
)
18211821
def test_missing_values_is_resilient(make_data, Forest):
1822-
"""Check that forest can deal with missing values and have decent performance."""
1822+
"""Check that forest can deal with missing values and has decent performance."""
18231823

18241824
rng = np.random.RandomState(0)
18251825
n_samples, n_features = 1000, 10
@@ -1828,6 +1828,8 @@ def test_missing_values_is_resilient(make_data, Forest):
18281828
# Create dataset with missing values
18291829
X_missing = X.copy()
18301830
X_missing[rng.choice([False, True], size=X.shape, p=[0.95, 0.05])] = np.nan
1831+
assert np.isnan(X_missing).any()
1832+
18311833
X_missing_train, X_missing_test, y_train, y_test = train_test_split(
18321834
X_missing, y, random_state=0
18331835
)
@@ -1864,6 +1866,7 @@ def test_missing_value_is_predictive(Forest):
18641866

18651867
predictive_feature = rng.standard_normal(size=n_samples)
18661868
predictive_feature[y_mask] = np.nan
1869+
assert np.isnan(predictive_feature).any()
18671870

18681871
X_predictive = X_non_predictive.copy()
18691872
X_predictive[:, 5] = predictive_feature

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.