pub struct FittedRandomForestClassifier<F> { /* private fields */ }Expand description
A fitted random forest classifier.
Stores the ensemble of fitted decision trees and aggregates their predictions by majority vote.
Implementations§
Source§impl<F: Float + Send + Sync + 'static> FittedRandomForestClassifier<F>
impl<F: Float + Send + Sync + 'static> FittedRandomForestClassifier<F>
Sourcepub fn trees(&self) -> &[Vec<Node<F>>]
pub fn trees(&self) -> &[Vec<Node<F>>]
Returns a reference to the individual tree node vectors.
Sourcepub fn n_features(&self) -> usize
pub fn n_features(&self) -> usize
Returns the number of features the model was trained on.
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_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 by averaging per-tree
class distributions across the forest. Equivalent to sklearn’s
RandomForestClassifier.predict_proba.
Returns an (n_samples, n_classes) array. Each row sums to 1.
When a leaf does not carry a class distribution, it contributes a
one-hot vote at the leaf’s predicted class.
§Errors
Returns FerroError::ShapeMismatch if the number of features
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 FittedRandomForestClassifier<F>
impl<F: Clone> Clone for FittedRandomForestClassifier<F>
Source§fn clone(&self) -> FittedRandomForestClassifier<F>
fn clone(&self) -> FittedRandomForestClassifier<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 FittedRandomForestClassifier<F>
impl<F: Debug> Debug for FittedRandomForestClassifier<F>
Source§impl<F: Float + Send + Sync + 'static> HasClasses for FittedRandomForestClassifier<F>
impl<F: Float + Send + Sync + 'static> HasClasses for FittedRandomForestClassifier<F>
Source§impl<F: Float + Send + Sync + 'static> HasFeatureImportances<F> for FittedRandomForestClassifier<F>
impl<F: Float + Send + Sync + 'static> HasFeatureImportances<F> for FittedRandomForestClassifier<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 FittedRandomForestClassifier<F>
impl<F: Float + Send + Sync + 'static> Predict<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>> for FittedRandomForestClassifier<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 by majority vote across all trees.
§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 FittedRandomForestClassifier<F>
impl<F> RefUnwindSafe for FittedRandomForestClassifier<F>where
F: RefUnwindSafe,
impl<F> Send for FittedRandomForestClassifier<F>where
F: Send,
impl<F> Sync for FittedRandomForestClassifier<F>where
F: Sync,
impl<F> Unpin for FittedRandomForestClassifier<F>where
F: Unpin,
impl<F> UnsafeUnpin for FittedRandomForestClassifier<F>
impl<F> UnwindSafe for FittedRandomForestClassifier<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