Random Forest: majority vote aggregation
Beginner classical-mlensemblesrandom-forest
Implement:
def random_forest_predict(trees: list[dict], input: np.ndarray) -> np.ndarray:
"""
trees: a list of already-built trees.
Returns: shape (n_samples,), majority vote across all trees.
"""
- Reuse
03-best-split-minimal-tree's predict_tree, don't reimplement tree traversal here.
- Ties are broken by the lower class label (a natural side effect of using sorted class values, no special-case code needed).