Struct abd_clam::VecDataset
source · pub struct VecDataset<I: Instance, U: Number, M: Instance> { /* private fields */ }
Expand description
A Dataset
of a Vec
of instances.
This may be used for any data that can fit in memory. It is not recommended for large datasets.
§Type Parameters
T
: The type of the instances in theDataset
.U
: The type of the distance values between instances.M
: The type of the metadata associated with each instance.
Implementations§
source§impl<I: Instance, U: Number> VecDataset<I, U, usize>
impl<I: Instance, U: Number> VecDataset<I, U, usize>
sourcepub fn new(
name: String,
data: Vec<I>,
metric: fn(_: &I, _: &I) -> U,
is_expensive: bool,
) -> Self
pub fn new( name: String, data: Vec<I>, metric: fn(_: &I, _: &I) -> U, is_expensive: bool, ) -> Self
Creates a new dataset.
§Arguments
name
: The name of the dataset.data
: The vector of instances.metric
: The metric for computing distances between instances.is_expensive
: Whether the metric is expensive to compute.
source§impl<I: Instance, U: Number, M: Instance> VecDataset<I, U, M>
impl<I: Instance, U: Number, M: Instance> VecDataset<I, U, M>
sourcepub fn assign_metadata<Mn: Instance>(
self,
metadata: Vec<Mn>,
) -> Result<VecDataset<I, U, Mn>, String>
pub fn assign_metadata<Mn: Instance>( self, metadata: Vec<Mn>, ) -> Result<VecDataset<I, U, Mn>, String>
sourcepub fn data_owned(self) -> Vec<I>
pub fn data_owned(self) -> Vec<I>
Moves the underlying data out of the dataset.
sourcepub fn metadata_owned(self) -> Vec<M>
pub fn metadata_owned(self) -> Vec<M>
Moves the underlying metadata out of the dataset.
sourcepub fn metadata_of(&self, index: usize) -> &M
pub fn metadata_of(&self, index: usize) -> &M
A reference to the metadata of a specific instance.
Trait Implementations§
source§impl<I: Clone + Instance, U: Clone + Number, M: Clone + Instance> Clone for VecDataset<I, U, M>
impl<I: Clone + Instance, U: Clone + Number, M: Clone + Instance> Clone for VecDataset<I, U, M>
source§fn clone(&self) -> VecDataset<I, U, M>
fn clone(&self) -> VecDataset<I, U, M>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl<I: Instance, U: Number, M: Instance> Dataset<I, U> for VecDataset<I, U, M>
impl<I: Instance, U: Number, M: Instance> Dataset<I, U> for VecDataset<I, U, M>
source§fn name(&self) -> &str
fn name(&self) -> &str
Returns the name of the dataset. This is used to identify the dataset in
various places.
source§fn cardinality(&self) -> usize
fn cardinality(&self) -> usize
Returns the number of instances in the dataset.
source§fn is_metric_expensive(&self) -> bool
fn is_metric_expensive(&self) -> bool
Whether or not the metric is expensive to calculate. Read more
source§fn metric(&self) -> fn(_: &I, _: &I) -> U
fn metric(&self) -> fn(_: &I, _: &I) -> U
Returns the metric used to calculate distances between instances. Read more
source§fn set_permuted_indices(&mut self, indices: Option<&[usize]>)
fn set_permuted_indices(&mut self, indices: Option<&[usize]>)
Sets the permutation of indices that was used to reorder the dataset. Read more
source§fn swap(&mut self, left: usize, right: usize) -> Result<(), String>
fn swap(&mut self, left: usize, right: usize) -> Result<(), String>
Swaps the location of two instances in the dataset. Read more
source§fn permuted_indices(&self) -> Option<&[usize]>
fn permuted_indices(&self) -> Option<&[usize]>
Returns the permutation of indices that was used to reorder the dataset. Read more
source§fn permute_instances(&mut self, permutation: &[usize]) -> Result<(), String>
fn permute_instances(&mut self, permutation: &[usize]) -> Result<(), String>
Reorders the internal order of instances by a given permutation of indices. Read more
source§fn make_shards(self, max_cardinality: usize) -> Vec<Self>
fn make_shards(self, max_cardinality: usize) -> Vec<Self>
Makes a vector of sharded datasets from the given dataset. Read more
source§fn load(
path: &Path,
metric: fn(_: &I, _: &I) -> U,
is_expensive: bool,
) -> Result<Self, String>
fn load( path: &Path, metric: fn(_: &I, _: &I) -> U, is_expensive: bool, ) -> Result<Self, String>
Loads a dataset from a file. Read more
source§fn original_index(&self, index: usize) -> usize
fn original_index(&self, index: usize) -> usize
Get the index before the dataset was reordered. If the dataset was not
reordered, this is the identity function.
source§fn one_to_one(&self, left: usize, right: usize) -> U
fn one_to_one(&self, left: usize, right: usize) -> U
Calculates the distance between two indexed instances in the dataset. Read more
source§fn are_instances_equal(&self, left: usize, right: usize) -> bool
fn are_instances_equal(&self, left: usize, right: usize) -> bool
Returns whether or not two indexed instances in the dataset are equal. Read more
source§fn one_to_many(&self, left: usize, right: &[usize]) -> Vec<U>
fn one_to_many(&self, left: usize, right: &[usize]) -> Vec<U>
Returns a vector of distances. Read more
source§fn many_to_many(&self, left: &[usize], right: &[usize]) -> Vec<Vec<U>>
fn many_to_many(&self, left: &[usize], right: &[usize]) -> Vec<Vec<U>>
Returns a vector of vectors of distances. Read more
source§fn pairs(&self, index_pairs: &[(usize, usize)]) -> Vec<U>
fn pairs(&self, index_pairs: &[(usize, usize)]) -> Vec<U>
Returns a vector of distances between the given pairs of indexed instances. Read more
source§fn pairwise(&self, indices: &[usize]) -> Vec<Vec<U>>
fn pairwise(&self, indices: &[usize]) -> Vec<Vec<U>>
Returns a vector of distances between all pairs of indexed instances. Read more
source§fn query_to_one(&self, query: &I, index: usize) -> U
fn query_to_one(&self, query: &I, index: usize) -> U
Calculates the distance between a query and an indexed instance in the dataset. Read more
source§fn query_to_many(&self, query: &I, indices: &[usize]) -> Vec<U>
fn query_to_many(&self, query: &I, indices: &[usize]) -> Vec<U>
Returns a vector of distances between a query and all indexed instances. Read more
source§fn choose_unique(
&self,
n: usize,
indices: &[usize],
seed: Option<u64>,
) -> Vec<usize>
fn choose_unique( &self, n: usize, indices: &[usize], seed: Option<u64>, ) -> Vec<usize>
Chooses a subset of indices that are unique with respect to the metric. Read more
source§fn median(&self, indices: &[usize]) -> Option<usize>
fn median(&self, indices: &[usize]) -> Option<usize>
Calculates the geometric median of a set of indexed instances. Returns
a value from the set of indices that is the index of the median in the
dataset. Read more
source§fn linear_knn(&self, query: &I, k: usize) -> Vec<(usize, U)>
fn linear_knn(&self, query: &I, k: usize) -> Vec<(usize, U)>
Runs linear KNN search on the dataset.
source§fn par_linear_knn(&self, query: &I, k: usize) -> Vec<(usize, U)>
fn par_linear_knn(&self, query: &I, k: usize) -> Vec<(usize, U)>
Runs parallelized linear KNN search on the dataset.
Auto Trait Implementations§
impl<I, U, M> Freeze for VecDataset<I, U, M>
impl<I, U, M> RefUnwindSafe for VecDataset<I, U, M>where
I: RefUnwindSafe,
M: RefUnwindSafe,
impl<I, U, M> Send for VecDataset<I, U, M>
impl<I, U, M> Sync for VecDataset<I, U, M>
impl<I, U, M> Unpin for VecDataset<I, U, M>
impl<I, U, M> UnwindSafe for VecDataset<I, U, M>where
I: UnwindSafe,
M: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more