pub struct BoundsInfo<T> {
pub type_classif: Classification,
pub nb_class: u32,
pub bounds: Vec<T>,
pub min: T,
pub max: T,
pub mean: T,
}
Expand description
A struct containing the bounds computed at its creation and some basic statistical informations : minimum, maximum and mean value.
The main field of BoundsInfo
struct is the bounds
field: a Vec<T>
containing the bounds. The lower bound is the minimum of the input values
and the upper bound is the maximum.
The get_class_index
method allows to retrieve the index of the cluster in which
belongs an input value.
§Example :
extern crate classif;
extern crate num_traits;
let values = vec![1.0, 1.3, 2.4, 5.0, 2.1, 5.3, 4.0, 3.0, 1.3, 4.3, 6.0, 2.1];
let bounds_info = classif::BoundsInfo::new(4, &values, classif::Classification::EqualInterval).unwrap();
// The first bounds value is the minimum:
assert_eq!(*bounds_info.bounds.first().unwrap(), bounds_info.min);
// And the last bounds value is the maximum:
assert_eq!(*bounds_info.bounds.last().unwrap(), bounds_info.max);
// So for 4 class we need a vector of 5 values :
assert_eq!(bounds_info.bounds.len(), 5);
// In which class belong the value 4.4 ?
let ix = bounds_info.get_class_index(4.4).unwrap();
Fields§
§type_classif: Classification
§nb_class: u32
§bounds: Vec<T>
§min: T
§max: T
§mean: T
Implementations§
Source§impl<T> BoundsInfo<T>where
T: Float + NumAssignOps,
impl<T> BoundsInfo<T>where
T: Float + NumAssignOps,
pub fn new( nb_class: u32, values: &[T], type_classif: Classification, ) -> Result<Self, &'static str>
Sourcepub fn get_class_index(&self, value: T) -> Option<u32>
pub fn get_class_index(&self, value: T) -> Option<u32>
Returns the index of the class to which the value
belongs, wrapped
in an Option. Returns None if the value is outside the serie range.
Auto Trait Implementations§
impl<T> Freeze for BoundsInfo<T>where
T: Freeze,
impl<T> RefUnwindSafe for BoundsInfo<T>where
T: RefUnwindSafe,
impl<T> Send for BoundsInfo<T>where
T: Send,
impl<T> Sync for BoundsInfo<T>where
T: Sync,
impl<T> Unpin for BoundsInfo<T>where
T: Unpin,
impl<T> UnwindSafe for BoundsInfo<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more