pub fn gini<T>(data: &[T]) -> f32
Expand description
Compute the gini impurity of a dataset.
Returns a float, 0 representing a perfectly pure dataset. Normal distribution: ~0.33
By default, any empty dataset will return a gini of 1.0. This may be unexpected behaviour.
use parsnip::gini;
assert_eq!(gini(&vec![0, 0, 0, 1]), 0.375);