Skip to main content

Dendrogram

pub struct Dendrogram {
    pub points: usize,
    pub merges: Vec<Merge>,
}
Expand description

The full merge tree.

Fields§

§points: usize§merges: Vec<Merge>

Implementations§

Source§

impl Dendrogram

Source

pub fn cut_clusters(&self, k: usize) -> Result<Vec<usize>, ErrorsJSL>

Cuts the tree into exactly k clusters (1 <= k <= points), returning a label per point.

Source

pub fn cut_distance(&self, height: f64) -> Vec<usize>

Cuts the tree at height: merges at distance <= height are applied.

Source

pub fn cophenetic_distances(&self) -> R2D

The cophenetic distance matrix: the height at which each pair of points first joins.

Source§

impl Dendrogram

Source

pub fn to_linkage_matrix(&self) -> R2D

The linkage matrix in SciPy’s format: row i is [a, b, distance, size] for the merge that creates cluster points + i. The two ids are in the dendrogram’s left-to-right order, which for trees from agglomerate need not have the smaller id first as SciPy’s linkage does; the tree is the same.

Source

pub fn from_linkage_matrix(z: VR2D<'_>) -> Result<Dendrogram, ErrorsJSL>

A dendrogram from a linkage matrix in SciPy’s format (n − 1 rows of [a, b, distance, size]), checking that each row joins two existing, unused clusters and that the sizes add up.

Source

pub fn leaves(&self) -> Vec<usize>

The points in the order the dendrogram draws them, left to right (SciPy’s leaves_list).

Source

pub fn inconsistent(&self, depth: usize) -> Result<R2D, ErrorsJSL>

The inconsistency statistics of every merge (SciPy’s inconsistent(Z, d)): row i holds the mean and standard deviation of the heights of the merges at most depth − 1 levels below merge i (itself included), their number, and the inconsistency coefficient (h_i − mean) / std (0 when the deviation is 0). A large coefficient marks a merge much higher than those beneath it: a natural place to cut.

Source

pub fn optimal_leaf_ordering( &self, distances: VR2D<'_>, ) -> Result<Dendrogram, ErrorsJSL>

The same tree with the two children of each merge swapped where needed so that the sum of the distances between neighbouring leaves is as small as possible (SciPy’s optimal_leaf_ordering; Bar-Joseph, Gifford and Jaakkola’s dynamic programme, O(n³) time and O(n²) memory). distances is the full matrix the tree was built from.

Source

pub fn leaf_path_length(&self, distances: VR2D<'_>) -> f64

The sum of the distances between neighbouring leaves in leaves order, the quantity optimal_leaf_ordering minimises.

Trait Implementations§

Source§

impl Clone for Dendrogram

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Dendrogram

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Dendrogram

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Dendrogram

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.