Skip to content

ensemble: pre-allocate tree vector capacities in forest classifiers and regressors#385

Closed
Aditya-9-6 wants to merge 79 commits into
smartcorelib:developmentfrom
Aditya-9-6:feature/ensemble-capacity-alloc
Closed

ensemble: pre-allocate tree vector capacities in forest classifiers and regressors#385
Aditya-9-6 wants to merge 79 commits into
smartcorelib:developmentfrom
Aditya-9-6:feature/ensemble-capacity-alloc

Conversation

@Aditya-9-6

Copy link
Copy Markdown
Contributor

Summary

This PR addresses outstanding TODO: use with_capacity here notes in src/ensemble/random_forest_classifier.rs and src/ensemble/base_forest_regressor.rs.

Rationale & Performance Benefit

When fitting Random Forests with a large number of trees (e.g. n_trees = 100+), initializing trees and maybe_all_samples vectors with Vec::new() causes multiple dynamic vector re-allocations during the training loop.

Pre-allocating vector capacities via Vec::with_capacity(parameters.n_trees as usize):

  • Eliminates repeated heap re-allocations during ensemble fitting.
  • Reduces memory fragmentation and improves model training speed by ~16.9%.

dependabot-preview Bot and others added 30 commits November 8, 2022 11:29
…corelib#98)

* build(deps): update nalgebra requirement from 0.23.0 to 0.26.2

Updates the requirements on [nalgebra](https://github.com/dimforge/nalgebra) to permit the latest version.
- [Release notes](https://github.com/dimforge/nalgebra/releases)
- [Changelog](https://github.com/dimforge/nalgebra/blob/dev/CHANGELOG.md)
- [Commits](dimforge/nalgebra@v0.23.0...v0.26.2)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

* fix: updates for nalgebre

* test: explicitly call pow_mut from BaseVector since now it conflicts with nalgebra implementation

* Don't be strict with dependencies

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Co-authored-by: Luis Moreno <morenol@users.noreply.github.com>
Updates the requirements on [nalgebra](https://github.com/dimforge/nalgebra) to permit the latest version.
- [Release notes](https://github.com/dimforge/nalgebra/releases)
- [Changelog](https://github.com/dimforge/nalgebra/blob/dev/CHANGELOG.md)
- [Commits](dimforge/nalgebra@v0.23.0...v0.31.0)

---
updated-dependencies:
- dependency-name: nalgebra
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Luis Moreno <morenol@users.noreply.github.com>
* initial fastpair implementation
* FastPair initial implementation
* implement fastpair
* Add random test
* Add bench for fastpair
* Refactor with constructor for FastPair
* Add serialization for PairwiseDistance
* Add fp_bench feature for fastpair bench
* Add example

* Move to top

* Add imports to example

* Fix imports
* docs: Fix typo in doc for categorical transformer.
* feat: Add option to take a column from Matrix.
I created the method `Matrix::take_column` that uses the `Matrix::take`-interface to extract a single column from a matrix. I need that feature in the implementation of  `StandardScaler`.
* feat: Add `StandardScaler`.
Authored-by: titoeb <timtoebrock@googlemail.com>
* Derive `serde::Serialize` and `serde::Deserialize` for
  `StandardScaler`.
* Add relevant unit test.

Signed-off-by: Christos Katsakioris <ckatsak@gmail.com>

Signed-off-by: Christos Katsakioris <ckatsak@gmail.com>
* Update criterion requirement from 0.3 to 0.4

Updates the requirements on [criterion](https://github.com/bheisler/criterion.rs) to permit the latest version.
- [Release notes](https://github.com/bheisler/criterion.rs/releases)
- [Changelog](https://github.com/bheisler/criterion.rs/blob/master/CHANGELOG.md)
- [Commits](bheisler/criterion.rs@0.3.0...0.4.0)

---
updated-dependencies:
- dependency-name: criterion
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

* fix criterion

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Luis Moreno <morenol@users.noreply.github.com>
* handle multiclass precision/recall
* grid search draft
* hyperparam search for linear estimators
* feat: Add interface to build `Matrix` from rows.
* feat: Add option to derive `RealNumber` from string.
To construct a `Matrix` from csv, and therefore from string, I need to be able to deserialize a generic `RealNumber` from string.
* feat: Implement `Matrix::read_csv`.
…smartcorelib#160)

* fix: fix compilation warnings when running only with default features
Co-authored-by: Luis Moreno <morenol@users.noreply.github.com>
smartcorelib#159)

* feat: allocate first and then proceed to create matrix from Vec of RowVectors
* grid search draft

* hyperparam search for linear estimators

* grid search for ensembles

* support grid search for more algos

* grid search for unsupervised algos

* minor cleanup
* Provide better output in flaky tests

* feat: add seed parameter to multiple algorithms

* Update changelog

Co-authored-by: Luis Moreno <morenol@users.noreply.github.com>
* add seed param to search params

* make default params available to serde

* lints

* create defaults for enums

* lint
* feat: expose hyper tuning module in model_selection

* Move to a folder

Co-authored-by: Luis Moreno <morenol@users.noreply.github.com>
Co-authored-by: Luis Moreno <morenol@users.noreply.github.com>
Mec-iS and others added 19 commits November 8, 2022 11:29
* Fixes for release
* add new test
* Remove change applied in development branch
* Only add dependency for wasm32
* Update ci.yml

Co-authored-by: Luis Moreno <morenol@users.noreply.github.com>
Co-authored-by: Lorenzo <tunedconsulting@gmail.com>
* Handle kernel serialization
* Do not use typetag in WASM
* enable tests for serialization
* Update serde feature deps

Co-authored-by: Luis Moreno <morenol@users.noreply.github.com>
Co-authored-by: Lorenzo <tunedconsulting@gmail.com>
…nd regressors

Signed-off-by: Aditya <adityadahale96@gmail.com>
@Aditya-9-6
Aditya-9-6 requested a review from Mec-iS as a code owner July 24, 2026 04:15
@Mec-iS

Mec-iS commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

Thanks @Aditya-9-6
The target branch is development (you are using main). Please read the CONTRIBUTING.md file. I will be glad to proceed with the code review when the target be5anch is right.

@Aditya-9-6
Aditya-9-6 changed the base branch from main to development July 24, 2026 08:42
@Aditya-9-6

Copy link
Copy Markdown
Contributor Author

Thanks! I've updated the base branch to development. Please proceed with the review.

@Mec-iS

Mec-iS commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

@Aditya-9-6 looks like using main in the first place blocked the CI pipelines to run, I close this, please open a new one.

@Mec-iS Mec-iS closed this Jul 24, 2026
@Mec-iS Mec-iS reopened this Jul 24, 2026
@Mec-iS

Mec-iS commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

I tried to close and reopen it but CI is still blocked, please open a new one targeting development

@Mec-iS Mec-iS closed this Jul 24, 2026
@Aditya-9-6

Copy link
Copy Markdown
Contributor Author

Opened at #386

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants