Skip to main content

target_encoder

Function target_encoder 

Source
pub fn target_encoder(categorical_indices: Vec<usize>) -> TargetEncoder
Expand description

Create a target encoder with Bayesian smoothing for categorical features.

Note: TargetEncoder does not implement StreamingPreprocessor because it requires the target value. Use its methods directly.

use irithyll::target_encoder;

let mut enc = target_encoder(vec![0]); // feature 0 is categorical
enc.update(&[1.0, 3.5], 10.0);
let encoded = enc.transform(&[1.0, 3.5]);