Conversation
Make sure predict (and cousins) do not panic when called on a learner that hasn't been fit yet. The following learners all follow the same pattern and were easy to fix. - src/ensemble/extra_trees_regressor.rs - src/ensemble/random_forest_regressor.rs - src/naive_bayes/bernoulli.rs - src/naive_bayes/categorical.rs - src/naive_bayes/gaussian.rs - src/naive_bayes/multinomial.rs - src/tree/decision_tree_regressor.rs
Following classes got a guard against calling predict without fit. Test cases were added. - src/neighbors/knn_classifier.rs - src/neighbors/knn_regressor.rs - src/svm/svc.rs - src/svm/svr.rs
Changes to the following classes with tests. - src/linear/elastic_net.rs - src/linear/lasso.rs - src/linear/linear_regression.rs - src/linear/logistic_regression.rs - src/linear/ridge_regression.rs
Added for - src/ensemble/random_forest_classifier.rs - src/tree/decision_tree_classifier.rs Tests were added.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #470 +/- ##
===========================================
+ Coverage 43.97% 63.63% +19.65%
===========================================
Files 85 96 +11
Lines 7281 8514 +1233
===========================================
+ Hits 3202 5418 +2216
+ Misses 4079 3096 -983 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
predict changed and test added
|
@slievens Great contribution — the fix is well-scoped and the consistent error message makes it easy to match on downstream. A few issues to address and suggestions below. Issues to Address1. Inconsistent guard strategiesTwo patterns are used interchangeably with no apparent reason:
The 2. Missing test:
|
- Removed all is_none and replaced by match. - Added missing tests - Fixed typo - Fixed lint issue
|
Issues 1 to 5 addressed in commit 6e81d2e. |
Fixes #469
Checklist
Current behaviour
Many "predict" and related methods panic when fit hasn't been called.
New expected behaviour
"predict" no longer panics in said case, but returns a Result.
Change logs
Changed