The current code for predict is this:
pub fn predict(&self, x: &X) -> Result<Y, Failed> {
self.tree_regressor.as_ref().unwrap().predict(x)
}
this will panic when tree_regressor is still None (when fit wasn't called prior to predict).
Propose to change the implementation to:
pub fn predict(&self, x: &X) -> Result<Y, Failed> {
match &self.tree_regressor {
Some(tree) => tree.predict(x),
None => Err(Failed::predict(
"'fit' should be called before calling 'predict'",
)),
}
}
Similar changes can be made for many other classifiers.
If you want, I can create a PR for this (and all classifiers/regressors that have the same or similar issue).
The current code for
predictis this:this will panic when
tree_regressoris still None (when fit wasn't called prior to predict).Propose to change the implementation to:
Similar changes can be made for many other classifiers.
If you want, I can create a PR for this (and all classifiers/regressors that have the same or similar issue).