Skip to main content

Dataset

Struct Dataset 

Source
pub struct Dataset { /* private fields */ }
Expand description

A labelled dataset stored column by column.

Before a search, every column must be sorted and its values indexed; see Dataset::is_prepared. Dataset::from_rows and the file reader do both.

Implementations§

Source§

impl Dataset

Source

pub fn new() -> Self

An empty dataset.

Source

pub fn is_prepared(&self) -> bool

Whether both preparation steps have run. See SearchError::UnpreparedDataset.

Source

pub fn count(&self) -> usize

Number of instances. Zero for an empty dataset.

Source

pub fn is_empty(&self) -> bool

Whether the dataset has no instances.

Source

pub fn num_features(&self) -> usize

Number of feature columns.

Source

pub fn num_labels(&self) -> usize

Number of classes; labels are 0..num_labels.

Source

pub fn insert(&mut self, data_point: DataPoint, feature_index: usize)

Appends an observation to column feature_index. The observation of instance 0 opens a new column.

Source

pub fn set_num_label(&mut self, value: usize)

Sets the number of classes.

Source

pub fn sort_features(&mut self)

Sorts every column by value.

Source

pub fn compute_unique_feature_values(&mut self)

Assigns each observation the index of its value among the column’s distinct values. It may run before or after sort_features, and must run before any fit.

Source§

impl Dataset

Source

pub fn from_rows( values: &[f64], labels: &[usize], n_features: usize, ) -> Result<Self, DatasetError>

Builds a dataset from a row-major value buffer and its labels.

This is the in-memory counterpart of DataReader::read_file, and takes numpy’s C-order (n_rows, n_features) layout directly.

The returned dataset is prepared: its columns are sorted and indexed.

Trait Implementations§

Source§

impl Debug for Dataset

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Dataset

Source§

fn default() -> Dataset

Returns the “default value” for a type. Read more
Source§

impl Index<usize> for Dataset

Source§

type Output = Feature

The returned type after indexing.
Source§

fn index(&self, index: usize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl IndexMut<usize> for Dataset

Source§

fn index_mut(&mut self, index: usize) -> &mut Feature

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<'a> IntoIterator for &'a Dataset

Source§

type Item = &'a Feature

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'a, Feature>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V