mirror of
https://github.com/hanzoai/ml.git
synced 2026-11-20 23:08:29 +00:00
An isolation forest fits each tree on 256 rows. It got them by shuffling all n and truncating — a million swaps and eight megabytes to throw 999,744 rows away, per tree, on every core at once. That made the fit O(n) per tree in time and memory and the cost claim in the module docs aspirational. Twister::choose draws `take` distinct values in `take` draws and O(take) space. It works because the shuffle sweeps from the top: a position is settled once and never touched again, so the last `take` entries are fully determined after `take` draws while the first `take` are not determined until the sweep ends — which is why this returns the tail and truncating the head could not. Only positions a swap disturbed are remembered. The draws are identical to permutation(n), so a partial choice IS the tail of the whole shuffle, reversed; that identity is the test, and it is what makes the subsample uniform rather than merely cheap. Also: the confusion-matrix thresholds in the parity suite are keyed as the generator writes them, str(float), so "0.0" and not "0".