Struct linfa::correlation::PearsonCorrelation[][src]

pub struct PearsonCorrelation<F> { /* fields omitted */ }

Pearson Correlation Coefficients (or Bivariate Coefficients)

The PCCs indicate the linear correlation between variables. This type also supports printing the PCC as an upper triangle matrix together with the feature names.

Implementations

impl<F: Float> PearsonCorrelation<F>[src]

pub fn from_dataset<D: Data<Elem = F>, T>(
    dataset: &DatasetBase<ArrayBase<D, Ix2>, T>,
    num_iter: Option<usize>
) -> Self
[src]

Calculate the Pearson Correlation Coefficients and optionally p-values from dataset

The PCC describes the linear correlation between two variables. It is the covariance divided by the product of the standard deviations, therefore essentially a normalised measurement of the covariance and in range (-1, 1). A negative coefficient indicates a negative correlation between both variables.

The p-value supports or reject the null hypthesis that two variables are not correlated. A small p-value indicates a strong evidence that two variables are correlated.

Parameters

  • dataset: Data for the correlation analysis
  • num_iter: optionally number of iterations of the p-value test, if none then no p-value are calculate

Example

let corr = linfa_datasets::diabetes()
    .pearson_correlation_with_p_value(100);

println!("{}", corr);

The output looks like this (the p-value is in brackets behind the PCC):

age                        +0.17 (0.61) +0.18 (0.62) +0.33 (0.34) +0.26 (0.47) +0.22 (0.54) -0.07 (0.83) +0.20 (0.60) +0.27 (0.54) +0.30 (0.41)
sex                                     +0.09 (0.74) +0.24 (0.59) +0.04 (0.91) +0.14 (0.74) -0.38 (0.28) +0.33 (0.30) +0.15 (0.74) +0.21 (0.58)
body mass index                                      +0.39 (0.20) +0.25 (0.45) +0.26 (0.51) -0.37 (0.31) +0.41 (0.24) +0.45 (0.21) +0.39 (0.21)
blood pressure                                                    +0.24 (0.54) +0.19 (0.56) -0.18 (0.61) +0.26 (0.45) +0.39 (0.20) +0.39 (0.16)
t-cells                                                                        +0.90 (0.00) +0.05 (0.89) +0.54 (0.05) +0.52 (0.10) +0.33 (0.37)
low-density lipoproteins                                                                    -0.20 (0.53) +0.66 (0.04) +0.32 (0.42) +0.29 (0.42)
high-density lipoproteins                                                                                -0.74 (0.02) -0.40 (0.21) -0.27 (0.42)
thyroid stimulating hormone                                                                                           +0.62 (0.04) +0.42 (0.21)
lamotrigine                                                                                                                        +0.47 (0.14)
blood sugar level

pub fn get_coeffs(&self) -> &Array1<F>[src]

Return the Pearson’s Correlation Coefficients

The coefficients are describing the linear correlation, normalized in range (-1, 1) between two variables. Because the correlation is commutative and PCC to the same variable is always perfectly correlated (i.e. 1), this function only returns the upper triangular matrix with (n-1)*n/2 elements.

pub fn get_p_values(&self) -> Option<&Array1<F>>[src]

Return the p values supporting the null-hypothesis

This implementation estimates the p value with the permutation test. As null-hypothesis the non-correlation between two variables is chosen such that the smaller the p-value the stronger we can reject the null-hypothesis and conclude that they are linearily correlated.

Trait Implementations

impl<F: Float> Display for PearsonCorrelation<F>[src]

Display the Pearson’s Correlation Coefficients as upper triangular matrix

This function prints the feature names for each row, the corresponding PCCs and optionally the p-values in brackets after the PCCs.

Auto Trait Implementations

impl<F> RefUnwindSafe for PearsonCorrelation<F> where
    F: RefUnwindSafe

impl<F> Send for PearsonCorrelation<F> where
    F: Send

impl<F> Sync for PearsonCorrelation<F> where
    F: Sync

impl<F> Unpin for PearsonCorrelation<F>

impl<F> UnwindSafe for PearsonCorrelation<F> where
    F: RefUnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,