[][src]Struct kodama::Dendrogram

pub struct Dendrogram<T> { /* fields omitted */ }

A step-wise dendrogram that represents a hierarchical clustering as a binary tree.

A dendrogram consists of a series of N - 1 steps, where N is the number of observations that were clustered. Each step corresponds to a merge between two other clusters (where a cluster might consist of one or more observations). Each step includes the labels for the pair of clusters that were merged, the number of total observations in the new merged cluster and the dissimilarity between the two merged clusters.

The labels of clusters are assigned as follows:

  1. A cluster that corresponds to a single observation is assigned a label that corresponds to the given observation's index in the pairwise dissimilarity matrix.
  2. A cluster with more than one observation has the label N + i, where N is the total number of observations and i corresponds to the the ith step in which the cluster was created. So for example, the very first step in a dendrogram creates a cluster with the label N and the last step in a dendrogram creates a cluster with the label (N + N - 1) - 1 (since there are always N - 1 steps in a dendrogram).

This labeling scheme corresponds to the same labeling scheme used by SciPy.

The type parameter T refers to the type of dissimilarity used in the steps. In practice, T is a floating point type.

Implementations

impl<T> Dendrogram<T>[src]

pub fn new(observations: usize) -> Dendrogram<T>[src]

Return a new dendrogram with space for the given number of observations.

pub fn reset(&mut self, observations: usize)[src]

Clear this dendrogram and ensure there is space for the given number of observations.

This method is useful for reusing a dendrogram's allocation.

Note that this method does not need to be called before passing it to one of the clustering functions. The clustering functions will reset the dendrogram for you.

pub fn push(&mut self, step: Step<T>)[src]

Push a new step on to this dendrogram.

Panics

This method panics if the dendrogram has N - 1 steps, where N is the number of observations supported by this dendrogram.

pub fn steps(&self) -> &[Step<T>][src]

Returns the steps in the dendrogram.

pub fn steps_mut(&mut self) -> &mut [Step<T>][src]

Return a mutable slice of the steps in this dendrogram.

pub fn len(&self) -> usize[src]

Return the number of steps in this dendrogram.

pub fn is_empty(&self) -> bool[src]

Return true if and only if this dendrogram has no steps.

pub fn observations(&self) -> usize[src]

Return the number of observations that this dendrogram supports.

pub fn cluster_size(&self, label: usize) -> usize[src]

Returns the total number of observations in the cluster identified by the following label.

The label may be any value in the half-open interval [0, N + N - 1), where N is the total number of observations.

impl<T: Float> Dendrogram<T>[src]

pub fn eq_with_epsilon(&self, other: &Dendrogram<T>, epsilon: T) -> bool[src]

Compare two dendrograms for approximate equality.

Approximate equality in this case refers to the dissimilarities in each step. In particular, two dissimilarities are considered equal if and only if the absolute value of their difference is less than or equal to the given epsilon value.

Trait Implementations

impl<T: Debug> Debug for Dendrogram<T>[src]

impl<T: Eq> Eq for Dendrogram<T>[src]

impl<T: Hash> Hash for Dendrogram<T>[src]

impl<T> Index<usize> for Dendrogram<T>[src]

type Output = Step<T>

The returned type after indexing.

impl<T> IndexMut<usize> for Dendrogram<T>[src]

impl<T: PartialEq> PartialEq<Dendrogram<T>> for Dendrogram<T>[src]

impl<T> StructuralEq for Dendrogram<T>[src]

impl<T> StructuralPartialEq for Dendrogram<T>[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for Dendrogram<T> where
    T: RefUnwindSafe

impl<T> Send for Dendrogram<T> where
    T: Send

impl<T> Sync for Dendrogram<T> where
    T: Sync

impl<T> Unpin for Dendrogram<T> where
    T: Unpin

impl<T> UnwindSafe for Dendrogram<T> where
    T: UnwindSafe

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