pub struct WOEEncoder { /* private fields */ }
Expand description
Weight of Evidence (WOE) Encoder for converting categorical features using target information
WOE encoding transforms categorical features based on the relationship between each category and a binary target variable. It’s particularly useful for credit scoring and other binary classification tasks.
WOE = ln(P(target=1|category) / P(target=0|category))
Implementations§
Source§impl WOEEncoder
impl WOEEncoder
Sourcepub fn new(
regularization: f64,
handleunknown: &str,
unknownvalue: f64,
) -> Result<Self>
pub fn new( regularization: f64, handleunknown: &str, unknownvalue: f64, ) -> Result<Self>
Creates a new WOEEncoder
§Arguments
regularization
- Small value added to prevent division by zero (default: 0.5)handleunknown
- How to handle unknown categories (‘error’, ‘global_woe’, or ‘use_encoded_value’)unknownvalue
- Value to use for unknown categories (when handleunknown=“use_encoded_value”)
§Returns
Result<WOEEncoder>
- The new encoder instance
Sourcepub fn with_defaults() -> Self
pub fn with_defaults() -> Self
Creates a WOEEncoder with default settings
Sourcepub fn with_regularization(regularization: f64) -> Result<Self>
pub fn with_regularization(regularization: f64) -> Result<Self>
Creates a WOEEncoder with custom regularization
Sourcepub fn fit_transform<S>(
&mut self,
x: &ArrayBase<S, Ix2>,
y: &[f64],
) -> Result<Array2<f64>>
pub fn fit_transform<S>( &mut self, x: &ArrayBase<S, Ix2>, y: &[f64], ) -> Result<Array2<f64>>
Sourcepub fn woe_maps(&self) -> Option<&Vec<HashMap<u64, f64>>>
pub fn woe_maps(&self) -> Option<&Vec<HashMap<u64, f64>>>
Returns the learned WOE mappings if fitted
Sourcepub fn information_values(&self) -> Option<&Vec<f64>>
pub fn information_values(&self) -> Option<&Vec<f64>>
Returns the Information Values for each feature if fitted
Information Value interpretation:
- < 0.02: Not useful for prediction
- 0.02 - 0.1: Weak predictive power
- 0.1 - 0.3: Medium predictive power
- 0.3 - 0.5: Strong predictive power
-
0.5: Suspicious, too good to be true
Sourcepub fn global_woe(&self) -> f64
pub fn global_woe(&self) -> f64
Returns the global WOE value (overall log-odds)
Trait Implementations§
Source§impl Clone for WOEEncoder
impl Clone for WOEEncoder
Source§fn clone(&self) -> WOEEncoder
fn clone(&self) -> WOEEncoder
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 moreAuto Trait Implementations§
impl Freeze for WOEEncoder
impl RefUnwindSafe for WOEEncoder
impl Send for WOEEncoder
impl Sync for WOEEncoder
impl Unpin for WOEEncoder
impl UnwindSafe for WOEEncoder
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.