lance_linalg

Trait Clustering

Source
pub trait Clustering<T: Num> {
    // Required methods
    fn dimension(&self) -> u32;
    fn num_clusters(&self) -> u32;
    fn find_partitions(
        &self,
        query: &[T],
        nprobes: usize,
    ) -> Result<UInt32Array>;
    fn compute_membership(
        &self,
        data: &[T],
        nprobes: Option<usize>,
    ) -> Vec<Option<u32>>;
}
Expand description

Clustering Trait.

Required Methods§

Source

fn dimension(&self) -> u32

The dimension of the vectors.

Source

fn num_clusters(&self) -> u32

The number of clusters.

Source

fn find_partitions(&self, query: &[T], nprobes: usize) -> Result<UInt32Array>

Find n-nearest partitions for the given query.

§Parameters
  • query: a D-dimensional query vector.
  • nprobes: The number of probes to return.
§Returns

n of nearest partitions.

Source

fn compute_membership( &self, data: &[T], nprobes: Option<usize>, ) -> Vec<Option<u32>>

Get the n nearest partitions for an array of vectors.

§Parameters:
  • data: an N * D of D-dimensional vectors.
  • nprobes: If provided, the number of partitions per vector to return. If not provided, return 1 partition per vector.
§Returns:
  • An N * nprobes matrix of partition IDs.

Implementors§