pub enum Cakes<I: Instance, U: Number, D: Dataset<I, U>> {
SingleShard(SingleShard<I, U, D>),
RandomlySharded(RandomlySharded<I, U, D>),
}
Expand description
CAKES search.
Variants§
SingleShard(SingleShard<I, U, D>)
Search with a single shard.
RandomlySharded(RandomlySharded<I, U, D>)
Search with multiple shards.
Implementations§
source§impl<I: Instance, U: Number, D: Dataset<I, U>> Cakes<I, U, D>
impl<I: Instance, U: Number, D: Dataset<I, U>> Cakes<I, U, D>
sourcepub fn new<P: PartitionCriterion<U>>(
data: D,
seed: Option<u64>,
criteria: &P
) -> Self
pub fn new<P: PartitionCriterion<U>>( data: D, seed: Option<u64>, criteria: &P ) -> Self
Creates a new CAKES instance with a single shard dataset.
§Arguments
data
- The dataset to search.seed
- The seed to use for the random number generator.criteria
- The criteria to use for partitioning the tree.
sourcepub fn load(
path: &Path,
metric: fn(_: &I, _: &I) -> U,
is_expensive: bool
) -> Result<Self, String>
pub fn load( path: &Path, metric: fn(_: &I, _: &I) -> U, is_expensive: bool ) -> Result<Self, String>
Loads the Cakes structure from the given path.
§Arguments
path
- The path to load the Cakes structure from.metric
- The metric to use for the search.is_expensive
- Whether the metric is expensive to compute.
§Returns
The Cakes structure.
§Errors
- If the
path
does not exist. - If the
path
is not a valid directory. - If the
path
does not contain a valid Cakes structure.
sourcepub fn trees(&self) -> Vec<&Tree<I, U, D, UniBall<U>>>
pub fn trees(&self) -> Vec<&Tree<I, U, D, UniBall<U>>>
Returns the references to the tree(s) of the dataset.
sourcepub fn new_randomly_sharded<P: PartitionCriterion<U>>(
shards: Vec<D>,
seed: Option<u64>,
criteria: &P
) -> Self
pub fn new_randomly_sharded<P: PartitionCriterion<U>>( shards: Vec<D>, seed: Option<u64>, criteria: &P ) -> Self
Creates a new CAKES instance with a randomly sharded dataset.
§Arguments
shards
- The shards of the dataset to search.seed
- The seed to use for the random number generator.criteria
- The criteria to use for partitioning the tree.
sourcepub fn num_shards(&self) -> usize
pub fn num_shards(&self) -> usize
Returns the number of shards in the dataset.
sourcepub fn shard_cardinalities(&self) -> Vec<usize>
pub fn shard_cardinalities(&self) -> Vec<usize>
Returns the cardinalities of the shards in the dataset.
sourcepub fn total_cardinality(&self) -> usize
pub fn total_cardinality(&self) -> usize
Returns the total cardinality of the dataset.
sourcepub fn tuned_rnn_algorithm(&self) -> Algorithm
pub fn tuned_rnn_algorithm(&self) -> Algorithm
Returns the tuned RNN algorithm.
sourcepub fn batch_rnn_search(
&self,
queries: &[&I],
radius: U,
algo: Algorithm
) -> Vec<Vec<(usize, U)>>
pub fn batch_rnn_search( &self, queries: &[&I], radius: U, algo: Algorithm ) -> Vec<Vec<(usize, U)>>
sourcepub fn linear_rnn_search(&self, query: &I, radius: U) -> Vec<(usize, U)>
pub fn linear_rnn_search(&self, query: &I, radius: U) -> Vec<(usize, U)>
sourcepub fn tuned_knn_algorithm(&self) -> Algorithm
pub fn tuned_knn_algorithm(&self) -> Algorithm
Returns the tuned KNN algorithm.
sourcepub fn batch_knn_search(
&self,
queries: &[&I],
k: usize,
algo: Algorithm
) -> Vec<Vec<(usize, U)>>
pub fn batch_knn_search( &self, queries: &[&I], k: usize, algo: Algorithm ) -> Vec<Vec<(usize, U)>>
sourcepub fn auto_tune_rnn(&mut self, radius: U, tuning_depth: usize)
pub fn auto_tune_rnn(&mut self, radius: U, tuning_depth: usize)
Automatically finds the best RNN algorithm to use.
§Arguments
radius
- The search radius.tuning_depth
- The number of instances to use for tuning.
sourcepub fn auto_tune_knn(&mut self, k: usize, tuning_depth: usize)
pub fn auto_tune_knn(&mut self, k: usize, tuning_depth: usize)
Automatically finds the best KNN algorithm to use.
§Arguments
k
- The number of nearest neighbors to return.tuning_depth
- The number of instances to use for tuning.
sourcepub fn batch_tuned_rnn_search(
&self,
queries: &[&I],
radius: U
) -> Vec<Vec<(usize, U)>>
pub fn batch_tuned_rnn_search( &self, queries: &[&I], radius: U ) -> Vec<Vec<(usize, U)>>
Performs RNN search on a batch of queries with the tuned algorithm.
If the algorithm has not been tuned, this will use the default algorithm.
§Arguments
queries
- The queries to search.radius
- The search radius.
§Returns
A vector of vectors of tuples containing the index of the instance and the distance to the query.
sourcepub fn tuned_rnn_search(&self, query: &I, radius: U) -> Vec<(usize, U)>
pub fn tuned_rnn_search(&self, query: &I, radius: U) -> Vec<(usize, U)>
sourcepub fn batch_tuned_knn_search(
&self,
queries: &[&I],
k: usize
) -> Vec<Vec<(usize, U)>>
pub fn batch_tuned_knn_search( &self, queries: &[&I], k: usize ) -> Vec<Vec<(usize, U)>>
Performs KNN search on a batch of queries with the tuned algorithm.
If the algorithm has not been tuned, this will use the default algorithm.
§Arguments
queries
- The queries to search.k
- The number of nearest neighbors to return.
§Returns
A vector of vectors of tuples containing the index of the instance and the distance to the query.
sourcepub fn tuned_knn_search(&self, query: &I, k: usize) -> Vec<(usize, U)>
pub fn tuned_knn_search(&self, query: &I, k: usize) -> Vec<(usize, U)>
Performs a KNN search with the tuned algorithm.
If the algorithm has not been tuned, this will use the default algorithm.
§Arguments
query
- The query instance.k
- The number of nearest neighbors to return.
§Returns
A vector of tuples containing the index of the instance and the distance to the query.