Expand description
Bagging, random forest, Extra-Trees, gradient boosting, and AdaBoost ensemble methods.
This crate provides ensemble learning algorithms that combine multiple decision trees for improved accuracy and robustness:
BaggingClassifier/BaggingRegressor– bootstrap aggregating with the full feature set (no random feature subsampling).RandomForestClassifier/RandomForestRegressor– bagging with bootstrap samples and optional random feature subsets.ExtraTreesClassifier/ExtraTreesRegressor– extremely randomized trees that use random split thresholds and train on the full dataset (no bootstrap).GradientBoostingClassifier/GradientBoostingRegressor– sequential boosting that fits each tree to the residuals of the ensemble.AdaBoostClassifier/AdaBoostRegressor– adaptive boosting that re-weights samples to focus on hard examples.
§Examples
use ndarray::array;
use anofox_ml_core::{Fit, Predict};
use anofox_ml_ensemble::RandomForestClassifier;
let x = array![
[1.0, 0.0],
[2.0, 0.0],
[3.0, 0.0],
[10.0, 1.0],
[11.0, 1.0],
[12.0, 1.0]
];
let y = array![0.0, 0.0, 0.0, 1.0, 1.0, 1.0];
let rf = RandomForestClassifier::new(20)
.with_max_depth(Some(3))
.with_seed(42);
let fitted = Fit::fit(&rf, &x, &y).unwrap();
let preds = fitted.predict(&x).unwrap();
assert!((preds[0] - 0.0_f64).abs() < 1e-10);
assert!((preds[5] - 1.0_f64).abs() < 1e-10);Re-exports§
pub use adaboost_classifier::AdaBoostClassifier;pub use adaboost_classifier::FittedAdaBoostClassifier;pub use adaboost_regressor::AdaBoostLoss;pub use adaboost_regressor::AdaBoostRegressor;pub use adaboost_regressor::FittedAdaBoostRegressor;pub use bagging_classifier::BaggingClassifier;pub use bagging_classifier::FittedBaggingClassifier;pub use bagging_regressor::BaggingRegressor;pub use bagging_regressor::FittedBaggingRegressor;pub use calibrated_classifier::CalibratedClassifierCV;pub use calibrated_classifier::CalibrationMethod;pub use extra_trees_classifier::ExtraTreesClassifier;pub use extra_trees_classifier::FittedExtraTreesClassifier;pub use extra_trees_regressor::ExtraTreesRegressor;pub use extra_trees_regressor::FittedExtraTreesRegressor;pub use gradient_boosting_classifier::FittedGradientBoostingClassifier;pub use gradient_boosting_classifier::GradientBoostingClassifier;pub use gradient_boosting_regressor::FittedGradientBoostingRegressor;pub use gradient_boosting_regressor::GradientBoostingRegressor;pub use hist_gradient_boosting::FittedHistGradientBoostingClassifier;pub use hist_gradient_boosting::FittedHistGradientBoostingRegressor;pub use hist_gradient_boosting::HistGradientBoostingClassifier;pub use hist_gradient_boosting::HistGradientBoostingRegressor;pub use isolation_forest::FittedIsolationForest;pub use isolation_forest::IsolationForest;pub use lgbm::BoostingType;pub use lgbm::FittedLgbmClassifier;pub use lgbm::FittedLgbmRegressor;pub use lgbm::LgbmClassWeight;pub use lgbm::LgbmClassifier;pub use lgbm::LgbmFitOptions;pub use lgbm::LgbmObjective;pub use lgbm::LgbmRegressor;pub use random_forest_classifier::FittedRandomForestClassifier;pub use random_forest_classifier::RandomForestClassifier;pub use random_forest_regressor::FittedRandomForestRegressor;pub use random_forest_regressor::RandomForestRegressor;pub use stacking_classifier::FittedStackingClassifier;pub use stacking_classifier::StackingClassifier;pub use stacking_regressor::StackingRegressor;pub use voting_classifier::VotingClassifier;pub use voting_regressor::VotingRegressor;
Modules§
- adaboost_
classifier - adaboost_
regressor - bagging_
classifier - bagging_
regressor - calibrated_
classifier - CalibratedClassifierCV — probability calibration for classifiers.
- extra_
trees_ classifier - extra_
trees_ regressor - gradient_
boosting_ classifier - gradient_
boosting_ regressor - hist_
gradient_ boosting - Histogram-based gradient boosting (classifier and regressor).
- isolation_
forest - Isolation Forest for outlier detection.
- lgbm
- LightGBM-like gradient boosting booster.
- random_
forest_ classifier - random_
forest_ regressor - stacking_
classifier - Stacking classifier: two-level ensemble where base classifiers’ predictions are used as features for a meta-classifier.
- stacking_
regressor - Stacking regressor: two-level ensemble where base models’ predictions are combined by a meta-estimator.
- voting_
classifier - Voting classifier: combines predictions from multiple heterogeneous models.
- voting_
regressor - Voting regressor: averages predictions from multiple heterogeneous models.