Skip to content

Commit 4290b9c

Browse files
committed
test fix
1 parent ea4b8ba commit 4290b9c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

tests/modules/test_training_feature_importances.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,10 @@ def _create_test_data():
142142
}
143143
)
144144

145+
# Compute regression target BEFORE injecting NaN into features,
146+
# so target_reg is always NaN-free.
147+
data["target_reg"] = 0.5 * data["num_col1"] + 0.3 * data["num_col2"] + np.random.normal(0, 1, n_samples)
148+
145149
# Inject some NaN values to test robustness
146150
nan_mask = np.random.random(n_samples) < 0.1
147151
data.loc[nan_mask, "num_col1"] = np.nan
@@ -154,7 +158,6 @@ def _create_test_data():
154158

155159
data["target_class"] = np.random.choice([0, 1], n_samples)
156160
data["target_multiclass"] = np.random.choice([0, 1, 2], n_samples)
157-
data["target_reg"] = 0.5 * data["num_col1"] + 0.3 * data["num_col2"] + np.random.normal(0, 1, n_samples)
158161
data["duration"] = np.random.exponential(10, n_samples)
159162
data["event"] = np.random.choice([True, False], n_samples, p=[0.7, 0.3])
160163

0 commit comments

Comments
 (0)