Skip to content

Commit 631802f

Browse files
committed
fix(model_selection): pin KFold seed in knn cross-validation tests
Under --all-features the std_rand feature makes an unseeded KFold draw OS entropy, so every CI run shuffled the folds differently. A sweep of 20k seeds showed 0.17% of shuffles violate the MAE < 10.0 assertion in test_cross_val_predict_knn (worst 12.81) and 0.01% violate train_score < test_score in test_cross_validate_knn. Pin seed Some(11) in both tests; margins are comfortable (predict MAE 2.84 vs 10, validate test 2.71 vs 15). The entropy path stays covered by the rand_custom tests.
1 parent c80a7de commit 631802f

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/model_selection/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,9 @@ mod tests {
451451

452452
let cv = KFold {
453453
n_splits: 5,
454+
// Pinned seed: under std_rand an unseeded KFold draws OS entropy,
455+
// which makes these assertions flaky across CI runs.
456+
seed: Some(11),
454457
..KFold::default()
455458
};
456459

@@ -500,6 +503,9 @@ mod tests {
500503

501504
let cv: KFold = KFold {
502505
n_splits: 2,
506+
// Pinned seed: under std_rand an unseeded KFold draws OS entropy,
507+
// which makes these assertions flaky across CI runs.
508+
seed: Some(11),
503509
..KFold::default()
504510
};
505511

0 commit comments

Comments
 (0)