• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

yzhao062 / pyod / 23972073553

04 Apr 2026 05:15AM UTC coverage: 93.926% (+0.01%) from 93.913%
23972073553

push

github

yzhao062
Fix CD detector train-test split: reuse fitted models at prediction time (#624)

decision_function() previously re-fitted the regression model on test
data instead of using models trained during fit(). This patch stores
per-feature fitted models and reuses them at prediction time.

Additional fixes:
- Fix broken NaN check: (mse != 0) or (mse != np.nan) was always True;
  replaced with (mse != 0) and not np.isnan(mse)
- Use sklearn.base.clone instead of deepcopy for model copying
- Fix mutable default argument model=LinearRegression() in __init__
- Add check_is_fitted guard for _models attribute
- Update docstrings to reflect sklearn clone contract

Tests added:
- Sentinel-based test proving decision_function does not refit
- sklearn.base.clone compatibility test with non-picklable estimator

Based on the idea from PR #624 by Daniel Kulik (@KulikDM), with
corrections applied during code review.

51 of 52 new or added lines in 2 files covered. (98.08%)

10779 of 11476 relevant lines covered (93.93%)

10.33 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

98.2
/pyod/test/test_cd.py


Source Not Available

STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc