pub struct MatrixScaler { /* private fields */ }Expand description
Matrix Scaling - full affine transformation for maximum calibration flexibility Uses full weight matrix W and bias vector b: calibrated = softmax(W @ logits + b) More expressive than vector scaling but requires more data to avoid overfitting
Implementations§
Source§impl MatrixScaler
impl MatrixScaler
Sourcepub fn with_regularization(regularization: f64) -> Self
pub fn with_regularization(regularization: f64) -> Self
Create matrix scaler with custom regularization
Sourcepub fn fit(
&mut self,
logits: &Array2<f64>,
labels: &Array1<usize>,
) -> Result<()>
pub fn fit( &mut self, logits: &Array2<f64>, labels: &Array1<usize>, ) -> Result<()>
Fit the matrix scaler to logits and true labels Uses gradient descent with L2 regularization on off-diagonal weights
Sourcepub fn transform(&self, logits: &Array2<f64>) -> Result<Array2<f64>>
pub fn transform(&self, logits: &Array2<f64>) -> Result<Array2<f64>>
Transform logits to calibrated probabilities using matrix scaling
Sourcepub fn fit_transform(
&mut self,
logits: &Array2<f64>,
labels: &Array1<usize>,
) -> Result<Array2<f64>>
pub fn fit_transform( &mut self, logits: &Array2<f64>, labels: &Array1<usize>, ) -> Result<Array2<f64>>
Fit and transform in one step
Sourcepub fn parameters(&self) -> Option<(Array2<f64>, Array1<f64>)>
pub fn parameters(&self) -> Option<(Array2<f64>, Array1<f64>)>
Get the fitted parameters (weight_matrix, bias_vector)
Sourcepub fn condition_number(&self) -> Option<f64>
pub fn condition_number(&self) -> Option<f64>
Get the condition number of the weight matrix (for diagnostics) Higher values indicate potential numerical instability
Trait Implementations§
Source§impl Clone for MatrixScaler
impl Clone for MatrixScaler
Source§fn clone(&self) -> MatrixScaler
fn clone(&self) -> MatrixScaler
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for MatrixScaler
impl Debug for MatrixScaler
Auto Trait Implementations§
impl Freeze for MatrixScaler
impl RefUnwindSafe for MatrixScaler
impl Send for MatrixScaler
impl Sync for MatrixScaler
impl Unpin for MatrixScaler
impl UnwindSafe for MatrixScaler
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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 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>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.