pub struct FittedQDA<F> { /* private fields */ }Expand description
Fitted Quadratic Discriminant Analysis model.
Stores per-class means, covariance inverses, and priors. Implements
Predict to produce class labels.
Implementations§
Source§impl<F: Float + ScalarOperand + Send + Sync + 'static> FittedQDA<F>
impl<F: Float + ScalarOperand + Send + Sync + 'static> FittedQDA<F>
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 per-class probabilities. Mirrors sklearn
QuadraticDiscriminantAnalysis.predict_proba.
Computes softmax over the per-class quadratic discriminants
δ_c(x) = -½ log|Σ_c| - ½ (x-μ_c)ᵀ Σ_c⁻¹ (x-μ_c) + log π_c.
Returns shape (n_samples, n_classes); rows sum to 1.
§Errors
Returns FerroError::ShapeMismatch if the number of features
does not match the fitted model.
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>
Sourcepub fn decision_function(&self, x: &Array2<F>) -> Result<Array2<F>, FerroError>
pub fn decision_function(&self, x: &Array2<F>) -> Result<Array2<F>, FerroError>
Per-class quadratic discriminant scores. Mirrors sklearn
QuadraticDiscriminantAnalysis.decision_function. Returns shape
(n_samples, n_classes) with δ_c(x) = -½ log|Σ_c| - ½ (x-μ_c)ᵀ Σ_c⁻¹ (x-μ_c) + log π_c. argmax of each row agrees with Predict.
§Errors
Returns FerroError::ShapeMismatch if the number of features
does not match the fitted model.
Trait Implementations§
Source§impl<F: Float + Send + Sync + ScalarOperand + 'static> HasClasses for FittedQDA<F>
impl<F: Float + Send + Sync + ScalarOperand + 'static> HasClasses for FittedQDA<F>
Source§impl<F: Float + Send + Sync + ScalarOperand + 'static> Predict<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>> for FittedQDA<F>
impl<F: Float + Send + Sync + ScalarOperand + 'static> Predict<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>> for FittedQDA<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.
Selects the class with the largest log-posterior for each sample.
§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 FittedQDA<F>
impl<F> RefUnwindSafe for FittedQDA<F>where
F: RefUnwindSafe,
impl<F> Send for FittedQDA<F>where
F: Send,
impl<F> Sync for FittedQDA<F>where
F: Sync,
impl<F> Unpin for FittedQDA<F>where
F: Unpin,
impl<F> UnsafeUnpin for FittedQDA<F>
impl<F> UnwindSafe for FittedQDA<F>where
F: UnwindSafe + RefUnwindSafe,
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