Tree Splitting & Histograms
This document details how Strata computes recursive binary partition splits and Mean Decrease in Impurity (MDI) feature importances with streaming histogram updates.
1. Streaming Histogram Split Search
Section titled “1. Streaming Histogram Split Search”Given a continuous feature vector and target labels , finding the optimal threshold requires evaluating impurity for all candidate split points.
Naive split evaluation recalculates class counts in for each candidate threshold, yielding complexity per node.
Strata’s Streaming Engine
Section titled “Strata’s O(NlogN)\mathcal{O}(N \log N)O(NlogN) Streaming Engine”- Samples are sorted by feature values: .
- A single pass streams counts from the Right Partition into the Left Partition:
- Gini impurity or MSE is updated in time for each candidate split point:
2. Flat-Buffer Tree Layout
Section titled “2. Flat-Buffer Tree Layout”Instead of pointer-chasing tree structures where each node is a separate heap allocation, Strata stores tree topologies in contiguous flat array buffers:
struct Node(Copyable, Movable): var feature: Int # Split feature index (-1 for leaves) var threshold: Float64 # Split threshold var left: Int # Index into nodes buffer var right: Int # Index into nodes buffer var impurity: Float64 # Impurity at this node var n_node_samples: Int # Sample countAdvantages
Section titled “Advantages”- Cache-Friendly Inference: Evaluating predictions streams through sequential buffer indices.
- Zero-Fragmentation Allocation: Destroying a tree is a single buffer deallocation.