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 DatasetThe full dataset the view refers into.
total_instances: usizeNumber 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: boolWhether features and splits are ordered by Gini.
heuristic_values: HeuristicValuesGini ordering of features and splits, when sort_by_heuristic is set.
bitset: BitsetThe instances in the view; the cache key of the subproblem.
Implementations§
Source§impl<'a> DataView<'a>
impl<'a> DataView<'a>
Sourcepub fn root(dataset: &'a Dataset, sort_by_heuristic: bool) -> Self
pub fn root(dataset: &'a Dataset, sort_by_heuristic: bool) -> Self
The view of the whole dataset. The dataset’s features must be sorted.
Sourcepub fn get_dataset_size(&self) -> usize
pub fn get_dataset_size(&self) -> usize
Number of instances in the view.
Sourcepub fn get_feature_number(&self) -> usize
pub fn get_feature_number(&self) -> usize
Number of features.
Sourcepub fn get_sorted_feature(&self, f: usize) -> &Feature
pub fn get_sorted_feature(&self, f: usize) -> &Feature
The full, sorted column of feature f.
Sourcepub fn get_feature_indices(&self, f: usize) -> &[usize]
pub fn get_feature_indices(&self, f: usize) -> &[usize]
Positions into Self::get_sorted_feature of the instances in the
view, in value order.
Sourcepub fn get_labels_freqs(&self) -> &[usize]
pub fn get_labels_freqs(&self) -> &[usize]
Number of instances of each class in the view.
Sourcepub fn get_num_labels(&self) -> usize
pub fn get_num_labels(&self) -> usize
Number of classes in the dataset.
Sourcepub fn get_possible_split_indices(&self, f: usize) -> &[usize]
pub fn get_possible_split_indices(&self, f: usize) -> &[usize]
Candidate thresholds of feature f, as positions in the sorted column.
Sourcepub fn get_max_splits(&self) -> usize
pub fn get_max_splits(&self) -> usize
Largest number of candidate thresholds of any feature.
Sourcepub fn ordered_possible_splits(&self, feature: usize) -> &[usize]
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.
Sourcepub fn features_best_score(&self) -> &[(f64, usize)]
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.
Sourcepub fn initialize_split_parameters(
&self,
feature_index: usize,
split_point: usize,
left_freq: &mut [usize],
right_freq: &mut [usize],
)
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.