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
impl Dataset
Sourcepub fn is_prepared(&self) -> bool
pub fn is_prepared(&self) -> bool
Whether both preparation steps have run. See SearchError::UnpreparedDataset.
Sourcepub fn num_features(&self) -> usize
pub fn num_features(&self) -> usize
Number of feature columns.
Sourcepub fn num_labels(&self) -> usize
pub fn num_labels(&self) -> usize
Number of classes; labels are 0..num_labels.
Sourcepub fn insert(&mut self, data_point: DataPoint, feature_index: usize)
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.
Sourcepub fn set_num_label(&mut self, value: usize)
pub fn set_num_label(&mut self, value: usize)
Sets the number of classes.
Sourcepub fn sort_features(&mut self)
pub fn sort_features(&mut self)
Sorts every column by value.
Sourcepub fn compute_unique_feature_values(&mut self)
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
impl Dataset
Sourcepub fn from_rows(
values: &[f64],
labels: &[usize],
n_features: usize,
) -> Result<Self, DatasetError>
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.