Trait abd_clam::Cluster

source ·
pub trait Cluster<U: Number>: Serialize + for<'a> Deserialize<'a> + PartialEq + Eq + PartialOrd + Ord + Debug + Hash + Display + Send + Sync + Clone {
Show 26 methods // Required methods fn new_root<I: Instance, D: Dataset<I, U>>( data: &D, seed: Option<u64>, ) -> Self; fn partition<I, D, P>( self, data: &mut D, criteria: &P, seed: Option<u64>, ) -> Self where I: Instance, D: Dataset<I, U>, P: PartitionCriterion<U>; fn offset(&self) -> usize; fn cardinality(&self) -> usize; fn depth(&self) -> usize; fn arg_center(&self) -> usize; fn radius(&self) -> U; fn arg_radial(&self) -> usize; fn lfd(&self) -> f64; fn children(&self) -> Option<[&Self; 2]>; fn polar_distance(&self) -> Option<U>; fn arg_poles(&self) -> Option<[usize; 2]>; // Provided methods fn name(&self) -> String { ... } fn descend_to(&self, offset: usize, cardinality: usize) -> Option<&Self> { ... } fn is_ancestor_of(&self, other: &Self) -> bool { ... } fn is_descendant_of(&self, other: &Self) -> bool { ... } fn is_leaf(&self) -> bool { ... } fn is_singleton(&self) -> bool { ... } fn indices(&self) -> Range<usize> { ... } fn subtree(&self) -> Vec<&Self> { ... } fn max_leaf_depth(&self) -> usize { ... } fn distance_to_instance<I: Instance, D: Dataset<I, U>>( &self, data: &D, instance: &I, ) -> U { ... } fn distance_to_other<I: Instance, D: Dataset<I, U>>( &self, data: &D, other: &Self, ) -> U { ... } fn overlapping_children<I: Instance, D: Dataset<I, U>>( &self, data: &D, query: &I, radius: U, ) -> Vec<&Self> { ... } fn save(&self, path: &Path) -> Result<(), String> { ... } fn load(path: &Path) -> Result<Self, String> { ... }
}
Expand description

A Cluster represents a set of “similar” instances under some distance function.

Required Methods§

source

fn new_root<I: Instance, D: Dataset<I, U>>(data: &D, seed: Option<u64>) -> Self

Creates a new Cluster from a given dataset.

source

fn partition<I, D, P>( self, data: &mut D, criteria: &P, seed: Option<u64>, ) -> Self
where I: Instance, D: Dataset<I, U>, P: PartitionCriterion<U>,

Recursively partitions the Cluster until the PartitionCriteria are met.

source

fn offset(&self) -> usize

The offset of the indices of the Cluster’s instances in the dataset.

source

fn cardinality(&self) -> usize

The number of points in the cluster.

source

fn depth(&self) -> usize

The depth of the cluster in the tree.

source

fn arg_center(&self) -> usize

The index of the instance at the center of the Cluster.

TODO: Remove this method when we have “center-less” clusters.

source

fn radius(&self) -> U

The radius of the cluster.

source

fn arg_radial(&self) -> usize

The index of the instance with the maximum distance from the center

source

fn lfd(&self) -> f64

The local fractal dimension of the å.

source

fn children(&self) -> Option<[&Self; 2]>

The two child clusters.

source

fn polar_distance(&self) -> Option<U>

The distance between the two poles of the Cluster used for partitioning.

source

fn arg_poles(&self) -> Option<[usize; 2]>

The indices of the instances used as poles for partitioning.

Provided Methods§

source

fn name(&self) -> String

The name of the Cluster String.

This is a human-readable representation of the Cluster’s offset and cardinality. It is a unique identifier in the tree. It may be used to store the Cluster in a database, or to identify the Cluster in a visualization.

source

fn descend_to(&self, offset: usize, cardinality: usize) -> Option<&Self>

Descends to the Cluster with the given offset and cardinality.

If such a Cluster does not exist, None is returned.

§Arguments
  • offset: The offset of the Cluster’s instances in the dataset.
  • cardinality: The number of instances in the Cluster.
source

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

Whether the Cluster is an ancestor of another Cluster.

source

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

Whether the Cluster is a descendant of another Cluster.

source

fn is_leaf(&self) -> bool

Whether the Cluster is a leaf node in the tree.

source

fn is_singleton(&self) -> bool

Whether the Cluster is a singleton, i.e. it contains only one instance or has a radius of zero.

source

fn indices(&self) -> Range<usize>

The indices of the instances in the Cluster after the dataset has been reordered.

source

fn subtree(&self) -> Vec<&Self>

The subtree of the Cluster.

source

fn max_leaf_depth(&self) -> usize

The maximum depth of and leaf in the subtree of the Cluster.

If this Cluster is a leaf, the maximum depth is the depth of the Cluster.

source

fn distance_to_instance<I: Instance, D: Dataset<I, U>>( &self, data: &D, instance: &I, ) -> U

Distance from the center to the given instance.

source

fn distance_to_other<I: Instance, D: Dataset<I, U>>( &self, data: &D, other: &Self, ) -> U

Distance from the center of this Cluster to the center of the other Cluster.

source

fn overlapping_children<I: Instance, D: Dataset<I, U>>( &self, data: &D, query: &I, radius: U, ) -> Vec<&Self>

Assuming the Cluster overlaps with the query ball, we return only those children that also overlap with the query ball.

source

fn save(&self, path: &Path) -> Result<(), String>

Saves a Cluster to a given location.

§Arguments
  • path: The path to the Cluster file.
§Errors
  • If the file cannot be created.
  • If the file cannot be serialized.
source

fn load(path: &Path) -> Result<Self, String>

Loads a Cluster from a given location.

§Arguments
  • path: The path to the Cluster file.
§Returns
  • The Cluster loaded from the file.
§Errors
  • If the file cannot be opened.
  • If the file cannot be deserialized.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<U: Number> Cluster<U> for Vertex<U>

source§

impl<U: Number> Cluster<U> for UniBall<U>

source§

impl<U: UInt> Cluster<U> for SquishyBall<U>