[−][src]Struct ml_rust_cuda::learning::instance::Instance
Implementations
impl Instance
[src]
pub fn new(instances: Vec<f32>) -> Self
[src]
pub fn from_vector(feature_vec: Vector) -> Self
[src]
pub fn normalize(&mut self)
[src]
Mutates the feature vector of the instance such that all features are normalized to have a zero mean and unit standard deviation.
Examples
use ml_rust_cuda::{ learning::Instance, math::f32_eq }; let mut x = Instance::new(vec![9_f32, 5_f32, 8_f32, 3_f32, 4_f32, 0_f32]); x.normalize(); println!("{}", x);
pub fn distance(lhs1: &Instance, lhs2: &Instance, p: f32) -> f32
[src]
Returns the Lp-distance between two instances (i.e. the p-norm of the difference between the two vectors representing those instances).
Arguments
p
- A positive 32-bit float.
Examples
use ml_rust_cuda::{ learning::Instance, math::f32_eq }; let x1 = Instance::new(vec![9_f32, 5_f32, 8_f32, 3_f32, 4_f32, 0_f32]); let x2 = Instance::new(vec![3_f32, 8_f32, 1_f32, 2_f32, 3_f32, 1_f32]); let dist_1 = Instance::distance(&x1, &x2, 1_f32); let dist_2 = Instance::distance(&x1, &x2, 2_f32); let dist_3 = Instance::distance(&x1, &x2, 3_f32); assert!(f32_eq(dist_1, 19_f32)); assert!(f32_eq(dist_2, 97_f32.sqrt())); assert!(f32_eq(dist_3, 589_f32.cbrt()));
Panics
Panics if p
is less than or equal to 0, or if the number of attributes
in both instances is not equal.
Trait Implementations
impl Clone for Instance
[src]
impl Debug for Instance
[src]
impl Display for Instance
[src]
impl PartialEq<Instance> for Instance
[src]
Auto Trait Implementations
impl RefUnwindSafe for Instance
impl Send for Instance
impl Sync for Instance
impl Unpin for Instance
impl UnwindSafe for Instance
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,