[−][src]Function oner_quantize::find_intervals
pub fn find_intervals<A, C>(
attribute: &[A],
classes: &[C],
small: usize
) -> Vec<Interval<A, C>> where
A: OrdSubset + Copy + Debug,
C: Eq + Hash + Copy + Debug,
Quantize the given attribute
(aka feature, column) into an ordered list of Intervals
.
Arguments
attribute
- a single attribute, typically numeric, to be quantized.classes
- the corresponsing class for each attribute value.small
- the small disjunct threshold, such as 3. There has to be at least one class in an interval with more thansmall
values in the interval.
Examples
use oner_quantize::find_intervals; use oner_quantize::Interval; use oner_quantize::Interval::{Lower, Range, Upper}; // Fake data that has three clear splits: let attribute = vec![ 1, 10, 3, 1, 20, 30, 100]; let classes = vec!["a", "b", "a", "a", "b", "b", "c"]; let intervals = find_intervals(&attribute, &classes, 2); assert_eq!(intervals, vec![ Lower { below: 10, class: "a" }, Range { from: 10, below: 100, class: "b" }, Upper { from: 100, class: "c" } ]);