pub struct Cover {
pub num_attributes: usize,
pub num_labels: usize,
pub num_samples: usize,
/* private fields */
}Expand description
A binary dataset and the set of instances reaching the current node.
Features and classes are stored as bitsets over the instances. Branching on an item intersects the current set with a feature’s bitset (or its complement), and backtracking restores the previous set in constant time thanks to a reversible sparse bitset.
An item encodes a feature and a branch: 2 * feature is the branch where
the feature is 0 (left) and 2 * feature + 1 the branch where it is 1
(right). See crate::globals.
Fields§
§num_attributes: usizeNumber of binary features.
num_labels: usizeNumber of classes.
num_samples: usizeNumber of instances in the dataset.
Implementations§
Source§impl Cover
impl Cover
Sourcepub fn new(
attributes: Vec<Bitset>,
labels: Vec<Bitset>,
num_samples: usize,
) -> Self
pub fn new( attributes: Vec<Bitset>, labels: Vec<Bitset>, num_samples: usize, ) -> Self
A cover over all instances, from one bitset per feature (instances where it is 1) and one per class.
Sourcepub fn labels_count(&self) -> Vec<usize>
pub fn labels_count(&self) -> Vec<usize>
Number of instances of each class in the current node.
Sourcepub fn labels_count_with_buffer(&self, buffer: &mut Vec<usize>)
pub fn labels_count_with_buffer(&self, buffer: &mut Vec<usize>)
Self::labels_count writing into buffer.
Sourcepub fn branch_on(&mut self, item: usize) -> usize
pub fn branch_on(&mut self, item: usize) -> usize
Moves to the child reached by item and returns its number of
instances.
Sourcepub fn count_if_branch_on(&self, item: usize) -> usize
pub fn count_if_branch_on(&self, item: usize) -> usize
Number of instances the child reached by item would have.
Sourcepub fn shallow_cover(&self) -> ShallowBitset
pub fn shallow_cover(&self) -> ShallowBitset
A plain copy of the current set of instances.
Sourcepub fn sparse(&self) -> &SparseBitset
pub fn sparse(&self) -> &SparseBitset
The reversible set of instances.