pub struct FittedDecisionTreeClassifier<F> { /* private fields */ }Expand description
A fitted CART decision tree classifier.
Stores the learned tree as a flat Vec<Node<F>> for cache-friendly traversal.
Implements Predict for generating class predictions and
HasFeatureImportances for inspecting per-feature importance scores.
Implementations§
Source§impl<F: Float + Send + Sync + 'static> FittedDecisionTreeClassifier<F>
impl<F: Float + Send + Sync + 'static> FittedDecisionTreeClassifier<F>
Sourcepub fn n_features(&self) -> usize
pub fn n_features(&self) -> usize
Returns the number of features the model was trained on.
Sourcepub fn predict_proba(&self, x: &Array2<F>) -> Result<Array2<F>, FerroError>
pub fn predict_proba(&self, x: &Array2<F>) -> Result<Array2<F>, FerroError>
Predict class probabilities for each sample.
Returns a 2-D array of shape (n_samples, n_classes).
§Errors
Returns FerroError::ShapeMismatch if the number of features does
not match the training data.
Sourcepub fn score(&self, x: &Array2<F>, y: &Array1<usize>) -> Result<F, FerroError>
pub fn score(&self, x: &Array2<F>, y: &Array1<usize>) -> Result<F, FerroError>
Mean accuracy on the given test data and labels.
Equivalent to sklearn’s ClassifierMixin.score.
§Errors
Returns FerroError::ShapeMismatch if x.nrows() != y.len() or
the feature count does not match the training data.
Sourcepub fn predict_log_proba(&self, x: &Array2<F>) -> Result<Array2<F>, FerroError>
pub fn predict_log_proba(&self, x: &Array2<F>) -> Result<Array2<F>, FerroError>
Element-wise log of predict_proba. Mirrors
sklearn’s ClassifierMixin.predict_log_proba.
§Errors
Forwards any error from predict_proba.
Trait Implementations§
Source§impl<F: Clone> Clone for FittedDecisionTreeClassifier<F>
impl<F: Clone> Clone for FittedDecisionTreeClassifier<F>
Source§fn clone(&self) -> FittedDecisionTreeClassifier<F>
fn clone(&self) -> FittedDecisionTreeClassifier<F>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<F: Debug> Debug for FittedDecisionTreeClassifier<F>
impl<F: Debug> Debug for FittedDecisionTreeClassifier<F>
Source§impl<F: Float + Send + Sync + 'static> HasClasses for FittedDecisionTreeClassifier<F>
impl<F: Float + Send + Sync + 'static> HasClasses for FittedDecisionTreeClassifier<F>
Source§impl<F: Float + Send + Sync + 'static> HasFeatureImportances<F> for FittedDecisionTreeClassifier<F>
impl<F: Float + Send + Sync + 'static> HasFeatureImportances<F> for FittedDecisionTreeClassifier<F>
Source§fn feature_importances(&self) -> &Array1<F>
fn feature_importances(&self) -> &Array1<F>
Source§impl<F: Float + Send + Sync + 'static> Predict<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>> for FittedDecisionTreeClassifier<F>
impl<F: Float + Send + Sync + 'static> Predict<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>> for FittedDecisionTreeClassifier<F>
Source§fn predict(&self, x: &Array2<F>) -> Result<Array1<usize>, FerroError>
fn predict(&self, x: &Array2<F>) -> Result<Array1<usize>, FerroError>
Predict class labels for the given feature matrix.
§Errors
Returns FerroError::ShapeMismatch if the number of features does
not match the fitted model.
Source§type Output = ArrayBase<OwnedRepr<usize>, Dim<[usize; 1]>>
type Output = ArrayBase<OwnedRepr<usize>, Dim<[usize; 1]>>
ndarray::Array1<F> or ndarray::Array1<usize>).Source§type Error = FerroError
type Error = FerroError
predict.Auto Trait Implementations§
impl<F> Freeze for FittedDecisionTreeClassifier<F>
impl<F> RefUnwindSafe for FittedDecisionTreeClassifier<F>where
F: RefUnwindSafe,
impl<F> Send for FittedDecisionTreeClassifier<F>where
F: Send,
impl<F> Sync for FittedDecisionTreeClassifier<F>where
F: Sync,
impl<F> Unpin for FittedDecisionTreeClassifier<F>where
F: Unpin,
impl<F> UnsafeUnpin for FittedDecisionTreeClassifier<F>
impl<F> UnwindSafe for FittedDecisionTreeClassifier<F>where
F: RefUnwindSafe + UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more