Skip to main content

RANSACRegressor

Struct RANSACRegressor 

Source
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 (f32 or f64).
  • E: The base estimator type.

Fields§

§estimator: E

The 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: usize

Maximum number of random trials.

§random_state: Option<u64>

Optional random seed for reproducibility.

Implementations§

Source§

impl<F: Float, E> RANSACRegressor<F, E>

Source

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.

Source

pub fn with_min_samples(self, min_samples: usize) -> Self

Set the minimum number of samples for fitting.

Source

pub fn with_residual_threshold(self, threshold: F) -> Self

Set the residual threshold for inlier detection.

Source

pub fn with_max_trials(self, max_trials: usize) -> Self

Set the maximum number of random trials.

Source

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>

Source§

fn clone(&self) -> RANSACRegressor<F, E>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<F: Debug, E: Debug> Debug for RANSACRegressor<F, E>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

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>

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>

The fitted model type returned by fit.
Source§

type Error = FerroError

The error type returned by fit.

Auto Trait Implementations§

§

impl<F, E> Freeze for RANSACRegressor<F, E>
where E: Freeze, F: Freeze,

§

impl<F, E> RefUnwindSafe for RANSACRegressor<F, E>

§

impl<F, E> Send for RANSACRegressor<F, E>
where E: Send, F: Send,

§

impl<F, E> Sync for RANSACRegressor<F, E>
where E: Sync, F: Sync,

§

impl<F, E> Unpin for RANSACRegressor<F, E>
where E: Unpin, F: Unpin,

§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ByRef<T> for T

Source§

fn by_ref(&self) -> &T

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DistributionExt for T
where T: ?Sized,

Source§

fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> T
where Self: Distribution<T>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T, U> Imply<T> for U
where T: ?Sized, U: ?Sized,