WOEEncoder<T>
Models & Types · AiDotNet.Preprocessing.Encoders
Encodes categorical features using Weight of Evidence (WOE).
Inheritance: TransformerBase<T, Matrix<T>, Matrix<T>> → WOEEncoder<T>
For Beginners
WOE tells you how “good” or “bad” a category is for prediction:
- WOE > 0: Category is more likely to have positive outcomes
- WOE < 0: Category is more likely to have negative outcomes
- WOE ≈ 0: Category has no predictive power
Example in loan default prediction:
- “Employed” might have WOE = -0.5 (less likely to default)
- “Unemployed” might have WOE = +0.8 (more likely to default)
How It Works
Weight of Evidence is commonly used in credit scoring and binary classification. It measures the strength of the relationship between a category and the binary target. WOE = ln(Distribution of Events / Distribution of Non-Events)
Higher WOE values indicate categories more associated with the positive class, while lower (negative) values indicate association with the negative class.
Constructors
| Constructor | Summary |
|---|---|
WOEEncoder(double regularization, WOEHandleUnknown handleUnknown, int[] columnIndices) |
Creates a new instance of WOEEncoder. |
Properties
| Property | Summary |
|---|---|
Dictionary<int, CategoryValueMap<T>> WOEValues { get; } |
Gets the WOE values for each category. |
WOEHandleUnknown HandleUnknown { get; } |
Gets how unknown categories are handled. |
bool SupportsInverseTransform { get; } |
Gets whether this transformer supports inverse transformation. |
double Regularization { get; } |
Gets the regularization parameter to prevent infinite WOE values. |
Methods
| Method | Summary |
|---|---|
Dictionary<int, T> CalculateInformationValue(Matrix<T> data, Vector<T> target) |
Calculates Information Value (IV) for each feature. |
Matrix<T> FitTransform(Matrix<T> data, Vector<T> target) |
Fits and transforms the data. |
string[] GetFeatureNamesOut(string[] inputFeatureNames) |
Gets the output feature names after transformation. |
void Fit(Matrix<T> data, Vector<T> target) |
Fits the encoder by computing WOE values for each category. |