Struct BoundsInfo

Source
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,

Source

pub fn new( nb_class: u32, values: &[T], type_classif: Classification, ) -> Result<Self, &'static str>

Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.