Expand description
Multi-label binarizer.
Transforms a list of label sets into a multi-hot binary indicator matrix. Each sample can belong to zero or more classes simultaneously.
§Examples
use ferrolearn_preprocess::multi_label_binarizer::MultiLabelBinarizer;
use ferrolearn_core::traits::{Fit, Transform};
let mlb = MultiLabelBinarizer::new();
let y = vec![vec![0, 1], vec![1, 2], vec![0]];
let fitted = mlb.fit(&y, &()).unwrap();
let mat = fitted.transform(&y).unwrap();
// 3 classes → (3, 3) multi-hot matrix
assert_eq!(mat.shape(), &[3, 3]);
assert_eq!(mat[[0, 0]], 1.0); // sample 0 has label 0
assert_eq!(mat[[0, 1]], 1.0); // sample 0 has label 1
assert_eq!(mat[[0, 2]], 0.0); // sample 0 does NOT have label 2Structs§
- Fitted
Multi Label Binarizer - A fitted multi-label binarizer holding the discovered class set.
- Multi
Label Binarizer - An unfitted multi-label binarizer.