pub struct RANSACRegressor<F, E> {
pub estimator: E,
pub min_samples: Option<usize>,
pub residual_threshold: Option<F>,
pub max_trials: usize,
pub random_state: Option<u64>,
}Expand description
RANSAC robust regression meta-estimator.
Wraps a base regressor (e.g., LinearRegression)
and repeatedly fits it on random subsets to find a model robust to
outliers.
§Type Parameters
F: The floating-point type (f32orf64).E: The base estimator type.
Fields§
§estimator: EThe base estimator.
min_samples: Option<usize>Minimum number of samples for fitting.
residual_threshold: Option<F>Residual threshold: points with absolute residual below this are
considered inliers. If None, uses the MAD of the target.
max_trials: usizeMaximum number of random trials.
random_state: Option<u64>Optional random seed for reproducibility.
Implementations§
Source§impl<F: Float, E> RANSACRegressor<F, E>
impl<F: Float, E> RANSACRegressor<F, E>
Sourcepub fn new(estimator: E) -> Self
pub fn new(estimator: E) -> Self
Create a new RANSACRegressor with the given base estimator.
Defaults: min_samples = None (auto: n_features + 1),
residual_threshold = None (auto: MAD), max_trials = 100,
random_state = None.
Sourcepub fn with_min_samples(self, min_samples: usize) -> Self
pub fn with_min_samples(self, min_samples: usize) -> Self
Set the minimum number of samples for fitting.
Sourcepub fn with_residual_threshold(self, threshold: F) -> Self
pub fn with_residual_threshold(self, threshold: F) -> Self
Set the residual threshold for inlier detection.
Sourcepub fn with_max_trials(self, max_trials: usize) -> Self
pub fn with_max_trials(self, max_trials: usize) -> Self
Set the maximum number of random trials.
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, E: Clone> Clone for RANSACRegressor<F, E>
impl<F: Clone, E: Clone> Clone for RANSACRegressor<F, E>
Source§fn clone(&self) -> RANSACRegressor<F, E>
fn clone(&self) -> RANSACRegressor<F, E>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<F, E, Ef> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<F>, Dim<[usize; 1]>>> for RANSACRegressor<F, E>where
F: Float + Send + Sync + ScalarOperand + FromPrimitive + 'static,
E: Fit<Array2<F>, Array1<F>, Fitted = Ef, Error = FerroError> + Clone,
Ef: Predict<Array2<F>, Output = Array1<F>, Error = FerroError> + Clone,
impl<F, E, Ef> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<F>, Dim<[usize; 1]>>> for RANSACRegressor<F, E>where
F: Float + Send + Sync + ScalarOperand + FromPrimitive + 'static,
E: Fit<Array2<F>, Array1<F>, Fitted = Ef, Error = FerroError> + Clone,
Ef: Predict<Array2<F>, Output = Array1<F>, Error = FerroError> + Clone,
Source§fn fit(
&self,
x: &Array2<F>,
y: &Array1<F>,
) -> Result<FittedRANSACRegressor<E::Fitted>, FerroError>
fn fit( &self, x: &Array2<F>, y: &Array1<F>, ) -> Result<FittedRANSACRegressor<E::Fitted>, FerroError>
Fit the RANSAC model by repeatedly sampling and fitting.
§Errors
Returns FerroError::ShapeMismatch if x and y have different
sample counts.
Returns FerroError::ConvergenceFailure if no valid model is found
after max_trials iterations.
Source§type Fitted = FittedRANSACRegressor<Ef>
type Fitted = FittedRANSACRegressor<Ef>
fit.Source§type Error = FerroError
type Error = FerroError
fit.Auto Trait Implementations§
impl<F, E> Freeze for RANSACRegressor<F, E>
impl<F, E> RefUnwindSafe for RANSACRegressor<F, E>where
E: RefUnwindSafe,
F: RefUnwindSafe,
impl<F, E> Send for RANSACRegressor<F, E>
impl<F, E> Sync for RANSACRegressor<F, E>
impl<F, E> Unpin for RANSACRegressor<F, E>
impl<F, E> UnsafeUnpin for RANSACRegressor<F, E>where
E: UnsafeUnpin,
F: UnsafeUnpin,
impl<F, E> UnwindSafe for RANSACRegressor<F, E>where
E: UnwindSafe,
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