pub struct IsolationForest<F> {
pub n_estimators: usize,
pub max_samples: usize,
pub contamination: f64,
pub random_state: Option<u64>,
/* private fields */
}Expand description
Isolation forest anomaly detector.
Builds an ensemble of isolation trees, each trained on a random subsample. Anomaly scores are derived from the average path length: points that are isolated in fewer splits are more anomalous.
§Type Parameters
F: The floating-point type (f32orf64).
Fields§
§n_estimators: usizeNumber of isolation trees in the forest.
max_samples: usizeNumber of samples to draw for each tree.
contamination: f64Proportion of anomalies in the dataset, used to set the decision threshold.
random_state: Option<u64>Random seed for reproducibility. None means non-deterministic.
Implementations§
Source§impl<F: Float> IsolationForest<F>
impl<F: Float> IsolationForest<F>
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new IsolationForest with default settings.
Defaults: n_estimators = 100, max_samples = 256,
contamination = 0.1, random_state = None.
Sourcepub fn with_n_estimators(self, n_estimators: usize) -> Self
pub fn with_n_estimators(self, n_estimators: usize) -> Self
Set the number of isolation trees.
Sourcepub fn with_max_samples(self, max_samples: usize) -> Self
pub fn with_max_samples(self, max_samples: usize) -> Self
Set the number of samples to draw for each tree.
Sourcepub fn with_contamination(self, contamination: f64) -> Self
pub fn with_contamination(self, contamination: f64) -> Self
Set the contamination fraction (proportion of anomalies).
Sourcepub fn with_random_state(self, seed: u64) -> Self
pub fn with_random_state(self, seed: u64) -> Self
Set the random seed for reproducibility.
Trait Implementations§
Source§impl<F: Clone> Clone for IsolationForest<F>
impl<F: Clone> Clone for IsolationForest<F>
Source§fn clone(&self) -> IsolationForest<F>
fn clone(&self) -> IsolationForest<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 IsolationForest<F>
impl<F: Debug> Debug for IsolationForest<F>
Source§impl<F: Float> Default for IsolationForest<F>
impl<F: Float> Default for IsolationForest<F>
Source§impl<'de, F> Deserialize<'de> for IsolationForest<F>
impl<'de, F> Deserialize<'de> for IsolationForest<F>
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl<F: Float + Send + Sync + 'static> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, ()> for IsolationForest<F>
impl<F: Float + Send + Sync + 'static> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, ()> for IsolationForest<F>
Source§fn fit(
&self,
x: &Array2<F>,
_y: &(),
) -> Result<FittedIsolationForest<F>, FerroError>
fn fit( &self, x: &Array2<F>, _y: &(), ) -> Result<FittedIsolationForest<F>, FerroError>
Fit the isolation forest on the training data.
§Errors
Returns FerroError::InsufficientSamples if there are no samples.
Returns FerroError::InvalidParameter if hyperparameters are invalid.
Source§type Fitted = FittedIsolationForest<F>
type Fitted = FittedIsolationForest<F>
fit.Source§type Error = FerroError
type Error = FerroError
fit.Auto Trait Implementations§
impl<F> Freeze for IsolationForest<F>
impl<F> RefUnwindSafe for IsolationForest<F>where
F: RefUnwindSafe,
impl<F> Send for IsolationForest<F>where
F: Send,
impl<F> Sync for IsolationForest<F>where
F: Sync,
impl<F> Unpin for IsolationForest<F>where
F: Unpin,
impl<F> UnsafeUnpin for IsolationForest<F>
impl<F> UnwindSafe for IsolationForest<F>where
F: 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