lucem_hist::forest
Random Trees: an ensemble of decision trees, each grown on a bootstrap sample with a random subset of the features tried at every split (Gini impurity); a prediction is the mean of the trees’ class fractions. Deterministic for a seed, and saved as JSON with its classifier.
ForestSettings
Section titled “ForestSettings”pub struct ForestSettingsFields
trees: usizemax_depth: usize: 0: no limit.min_samples_leaf: usizefeatures_per_split: Option<usize>: Features tried per split;None: the square root of their number.seed: u64
Implements Clone, Debug, Default, Deserialize, PartialEq, Serialize.
RandomForest
Section titled “RandomForest”pub struct RandomForestFields
n_classes: usizen_features: usize
Methods
pub fn train( x: &[Vec<f64>], y: &[usize], n_classes: usize, s: &ForestSettings,) -> HistResult<Self>Trains on rows x (all the same length, finite: replace missing values first) and their
classes y (0..n_classes).
pub fn predict_proba(&self, row: &[f64]) -> Vec<f64>The mean of the trees’ class fractions.
pub fn predict(&self, row: &[f64]) -> (usize, f64)The most likely class and its probability.
Implements Clone, Debug, Deserialize, PartialEq, Serialize.