Skip to main content

DataView

Struct DataView 

Source
pub struct DataView<'a> {
    pub dataset: &'a Dataset,
    pub total_instances: usize,
    pub feature_columns: Vec<Vec<usize>>,
    pub possible_split_indices: Vec<Vec<usize>>,
    pub label_freq: Vec<usize>,
    pub sort_by_heuristic: bool,
    pub heuristic_values: HeuristicValues,
    pub bitset: Bitset,
}
Expand description

A subset of the dataset: the instances that reach one node of the tree.

Each feature column is kept sorted by value, so candidate thresholds are the positions where the value changes. Splitting a view partitions every column in one linear pass, preserving the order.

Fields§

§dataset: &'a Dataset

The full dataset the view refers into.

§total_instances: usize

Number of instances in the full dataset.

§feature_columns: Vec<Vec<usize>>

For each feature, positions into dataset[f] of the instances in the view, in increasing value order.

§possible_split_indices: Vec<Vec<usize>>

For each feature, positions in feature_columns[f] where the value changes: the candidate thresholds.

§label_freq: Vec<usize>

Number of instances of each class in the view.

§sort_by_heuristic: bool

Whether features and splits are ordered by Gini.

§heuristic_values: HeuristicValues

Gini ordering of features and splits, when sort_by_heuristic is set.

§bitset: Bitset

The instances in the view; the cache key of the subproblem.

Implementations§

Source§

impl<'a> DataView<'a>

Source

pub fn root(dataset: &'a Dataset, sort_by_heuristic: bool) -> Self

The view of the whole dataset. The dataset’s features must be sorted.

Source

pub fn get_dataset_size(&self) -> usize

Number of instances in the view.

Source

pub fn get_feature_number(&self) -> usize

Number of features.

Source

pub fn get_sorted_feature(&self, f: usize) -> &Feature

The full, sorted column of feature f.

Source

pub fn get_feature_indices(&self, f: usize) -> &[usize]

Positions into Self::get_sorted_feature of the instances in the view, in value order.

Source

pub fn get_labels_freqs(&self) -> &[usize]

Number of instances of each class in the view.

Source

pub fn get_num_labels(&self) -> usize

Number of classes in the dataset.

Source

pub fn get_possible_split_indices(&self, f: usize) -> &[usize]

Candidate thresholds of feature f, as positions in the sorted column.

Source

pub fn get_max_splits(&self) -> usize

Largest number of candidate thresholds of any feature.

Source

pub fn ordered_possible_splits(&self, feature: usize) -> &[usize]

Indices into the candidate thresholds of feature, best Gini first. Empty unless the heuristic ordering is enabled.

Source

pub fn features_best_score(&self) -> &[(f64, usize)]

(best Gini, feature) pairs, best first when the heuristic ordering is enabled and in feature order otherwise.

Source

pub fn initialize_split_parameters( &self, feature_index: usize, split_point: usize, left_freq: &mut [usize], right_freq: &mut [usize], )

Fills the class histograms of both sides of a split of feature_index at split_point. Both slices must start zeroed.

Source

pub fn split(&self, sf: usize, split_point: usize) -> (Self, Self)

Splits the view on feature sf at position split_point of its sorted column. The left view holds the instances before the position.

Source

pub fn len(&self) -> usize

Number of instances in the view.

Source

pub fn is_empty(&self) -> bool

Whether the view has no instances.

Auto Trait Implementations§

§

impl<'a> Freeze for DataView<'a>

§

impl<'a> RefUnwindSafe for DataView<'a>

§

impl<'a> Send for DataView<'a>

§

impl<'a> Sync for DataView<'a>

§

impl<'a> Unpin for DataView<'a>

§

impl<'a> UnsafeUnpin for DataView<'a>

§

impl<'a> UnwindSafe for DataView<'a>

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