Skip to Content
OchreML
Trees, Ensembles & Boosting

ExtraTreesRegressor

Extremely randomized regression tree ensemble with random split thresholds, Rayon parallelism, and N6 GPU support.

ExtraTreesRegressor fits an ensemble of randomized regression trees that draw random split thresholds for candidate features and average leaf predictions across the forest to reduce variance. (o´∀`o)

Backend & Hardware Acceleration

  • Parallel Forest Execution: Individual regression trees are trained concurrently with Rust Rayon across CPU cores.
  • GPU N6 & CPU/TPU Fallback: Integrates with OchreML's N6 histogram path on CUDA/wgpu where applicable and falls back seamlessly to CPU Rayon on CPU and TPU targets.
  • Default bootstrap=False: Uses the full training set for each tree by default (bootstrap=False) with max_features=1.0, deriving ensemble diversity from randomized split thresholds.

Import & Signature

from ochreml.ensemble import ExtraTreesRegressor
# or: from ochreml import ExtraTreesRegressor

ExtraTreesRegressor(
    n_estimators: int = 100,
    criterion: str = "squared_error",
    max_depth: Optional[int] = None,
    min_samples_split: int = 2,
    min_samples_leaf: int = 1,
    max_features: Union[str, int, float, None] = 1.0,
    bootstrap: bool = False,
    random_state: Optional[int] = None,
    device: Optional[str] = None,
)

Parameters

ParameterTypeDefaultDescription
n_estimatorsint100Number of regression trees in the forest.
criterionstr"squared_error"Split quality criterion ("squared_error").
max_depthint | NoneNoneMaximum depth of each tree.
min_samples_splitint2Minimum number of samples required to split an internal node.
min_samples_leafint1Minimum number of samples required at a leaf node.
max_featuresstr | int | float | None1.0Number of features considered at each split: "sqrt", "log2", "all", positive int, fraction float in (0.0, 1.0], or None.
bootstrapboolFalseWhether bootstrap samples are used when building trees.
random_stateint | NoneNoneSeed controlling random threshold selection, feature sampling, and optional bootstrapping.
devicestr | NoneNoneTarget compute device ("auto", "cpu", "cuda:0", "wgpu", "tpu"). Defaults to ochreml.get_default_device().

Attributes

AttributeTypeDescription
n_features_in_int | NoneNumber of features seen during fit.
feature_importances_np.ndarray | NoneNormalized impurity-based feature importances of shape (n_features,).
device_str | NoneResolved hardware device string used by the underlying Rust estimator.

Methods

MethodSignatureDescription
fitfit(X, y, sample_weight=None) -> ExtraTreesRegressorFit the Extra-Trees regressor on training data with optional sample weights.
predictpredict(X) -> np.ndarrayPredict continuous target values for samples in X.
scorescore(X, y) -> floatReturn the coefficient of determination R^2 on (X, y).
savesave(path: str) -> NoneSave the fitted forest to a binary .dit file.
loadExtraTreesRegressor.load(path: str, device: str | None = None)Load a fitted regressor from a .dit file.
toto(device: str) -> ExtraTreesRegressorMove the estimator compute target to device.
set_deviceset_device(device: str | None = None) -> ExtraTreesRegressorSet or reset the compute device for the estimator.

Example

import numpy as np
from ochreml.ensemble import ExtraTreesRegressor

rng = np.random.default_rng(19)
X = rng.uniform(-2.0, 2.0, size=(100, 3))
y = 2.0 * X[:, 0] ** 2 - X[:, 1] + 0.5 * X[:, 2]

reg = ExtraTreesRegressor(
    n_estimators=50,
    max_depth=8,
    random_state=19,
    device="auto",
)
reg.fit(X, y)

print("R^2 score:", reg.score(X, y))
print("Feature importances:", reg.feature_importances_)
print("Sample predictions:", reg.predict(X[:4]))

On this page