Skip to content

Don't mutate the rng hyper-parameter in fit#64

Merged
ablaom merged 5 commits into
devfrom
dont-mutate-rng
Jun 15, 2026
Merged

Don't mutate the rng hyper-parameter in fit#64
ablaom merged 5 commits into
devfrom
dont-mutate-rng

Conversation

@ablaom

@ablaom ablaom commented Jun 14, 2026

Copy link
Copy Markdown
Member

Currently, the rng hyper-parameter, if an AbstractRNG, is mutated by fit. This makes it harder to get reproducibility in some contexts. This PR has fit make a copy of the rng before using it.

The state of the rng copy is now cached by the random forest models, so that it can be used in the update methods for warm-restarts (by handing it off DecisionTree.build_tree). The idea is that training 15 = 10 + 5 trees in two steps, with a warm restart, ought to be equivalent to training in one step with 15 trees. Turns out this already didn't work prior to this PR, and, because of the way build_tree works, cannot currently be made to work within MLJDecisionTree. However, as I wrote a test for this, I've included it here and tagged it as broken, with the explanation I've just made included as a code comment.

@ablaom ablaom merged commit cfa507b into dev Jun 15, 2026
2 checks passed
This was referenced Jun 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant