Struct kodama::Dendrogram
[−]
[src]
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:
- 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.
- A cluster with more than one observation has the label
N + i
, whereN
is the total number of observations andi
corresponds to the thei
th step in which the cluster was created. So for example, the very first step in a dendrogram creates a cluster with the labelN
and the last step in a dendrogram creates a cluster with the label(N + N - 1) - 1
(since there are alwaysN - 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.
Methods
impl<T> Dendrogram<T>
[src]
fn new(observations: usize) -> Dendrogram<T>
Return a new dendrogram with space for the given number of observations.
fn reset(&mut self, observations: usize)
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.
fn push(&mut self, step: Step<T>)
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.
fn steps(&self) -> &[Step<T>]
Returns the steps in the dendrogram.
fn steps_mut(&mut self) -> &mut [Step<T>]
Return a mutable slice of the steps in this dendrogram.
fn len(&self) -> usize
Return the number of steps in this dendrogram.
fn is_empty(&self) -> bool
Return true if and only if this dendrogram has no steps.
fn observations(&self) -> usize
Return the number of observations that this dendrogram supports.
fn cluster_size(&self, label: usize) -> usize
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]
fn eq_with_epsilon(&self, other: &Dendrogram<T>, epsilon: T) -> bool
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]
fn hash<__HT: Hasher>(&self, __arg_0: &mut __HT)
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl<T: PartialEq> PartialEq for Dendrogram<T>
[src]
fn eq(&self, __arg_0: &Dendrogram<T>) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Dendrogram<T>) -> bool
This method tests for !=
.
impl<T> Index<usize> for Dendrogram<T>
[src]
type Output = Step<T>
The returned type after indexing
fn index(&self, i: usize) -> &Step<T>
The method for the indexing (container[index]
) operation