maxframe.learn.tree.DecisionTreeRegressor#

class maxframe.learn.tree.DecisionTreeRegressor(*, criterion='squared_error', max_depth=None, max_bins=32, min_samples_split=2, min_samples_leaf=1, min_weight_fraction_leaf=0.0, max_features=None, random_state=None, min_impurity_decrease=0.0, max_memory_in_mb=256)[source]#

A distributed decision tree regressor.

This estimator implements a distributed version of the decision tree regressor using approximate split finding with feature binning, following the approach described in [1]. The algorithm is designed for large-scale datasets that do not fit in a single machine’s memory and runs on MaxCompute’s distributed execution engine.

Unlike scikit-learn’s DecisionTreeRegressor which uses an exact greedy algorithm to find optimal split points, this implementation discretizes continuous features into bins and finds approximate splits. This trades a small amount of split quality for the ability to efficiently aggregate statistics across distributed partitions.

Parameters:
  • criterion ({"squared_error"}, default="squared_error") –

    The function to measure the quality of a split. Supported criteria are “squared_error” for the mean squared error, which is equal to variance reduction as feature selection criterion and minimizes L2 loss using the mean of each terminal node.

    Note

    ”absolute_error”, “friedman_mse”, and “poisson” criteria are not yet supported in the distributed implementation.

  • max_depth (int, default=None) – The maximum depth of the tree. If None, then nodes are expanded until all leaves contain less than min_samples_split samples. Note that very deep trees may require many distributed communication rounds.

  • max_bins (int, default=32) –

    The maximum number of bins used to discretize continuous features. Higher values improve split approximation quality at the cost of increased memory usage and communication overhead. This parameter has no equivalent in scikit-learn and is specific to the distributed binning algorithm.

    Memory usage per node group is approximately n_features * max_bins * 3 * 8 bytes (3 doubles per bin for regression: count, sum, squared sum). When the memory budget (controlled by max_memory_in_mb) is exceeded, fewer nodes are processed per iteration, increasing the number of data passes.

  • min_samples_split (int or float, default=2) –

    The minimum number of samples required to split an internal node:

    • If int, then consider min_samples_split as the minimum number.

    • If float, then min_samples_split is a fraction and ceil(min_samples_split * n_samples) are the minimum number of samples for each split.

  • min_samples_leaf (int or float, default=1) –

    The minimum number of samples required to be at a leaf node. A split point at any depth will only be considered if it leaves at least min_samples_leaf training samples in each of the left and right branches.

    • If int, then consider min_samples_leaf as the minimum number.

    • If float, then min_samples_leaf is a fraction and ceil(min_samples_leaf * n_samples) are the minimum number of samples for each node.

  • min_weight_fraction_leaf (float, default=0.0) – The minimum weighted fraction of the sum total of weights (of all the input samples) required to be at a leaf node. Samples have equal weight when sample_weight is not provided.

  • max_features (int, float, {"sqrt", "log2"} or None, default=None) –

    The number of features to consider when looking for the best split:

    • If int, then consider max_features features at each split.

    • If float, then max_features is a fraction and max(1, int(max_features * n_features)) features are considered.

    • If “sqrt”, then max_features=sqrt(n_features).

    • If “log2”, then max_features=log2(n_features).

    • If None, then max_features=n_features.

  • random_state (int, RandomState instance or None, default=None) – Controls the randomness of the estimator. To obtain a deterministic behaviour during fitting, random_state has to be fixed to an integer.

  • min_impurity_decrease (float, default=0.0) – A node will be split if this split induces a decrease of the impurity greater than or equal to this value.

  • max_memory_in_mb (int, default=256) – The maximum memory in MB to use for aggregating statistics for a group of nodes during training. This parameter has no equivalent in scikit-learn and is specific to the distributed algorithm.

feature_importances_#

The impurity-based feature importances.

Type:

ndarray of shape (n_features,)

max_features_#

The inferred value of max_features.

Type:

int

n_features_in_#

Number of features seen during fit.

Type:

int

feature_names_in_#

Names of features seen during fit. Defined only when X has feature names that are all strings.

Type:

ndarray of shape (n_features_in_,)

n_outputs_#

The number of outputs when fit is performed.

Type:

int

tree_#

The underlying Tree object.

Type:

Tree instance

See also

DecisionTreeClassifier

A distributed decision tree classifier.

RandomForestRegressor

A distributed random forest regressor.

Notes

Distributed Algorithm

Same level-wise binning algorithm as DecisionTreeClassifier, but with regression-specific sufficient statistics: for each bin, the aggregated count, weighted sum, and weighted sum of squares are tracked. The squared_error criterion computes variance reduction at each candidate split.

Limitations compared to scikit-learn

In addition to the limitations documented in DecisionTreeClassifier:

  • Only “squared_error” criterion is supported. “absolute_error”, “friedman_mse”, and “poisson” criteria are not yet available in the distributed implementation.

  • class_weight is not applicable to regressors.

References

Examples

>>> from maxframe.learn.tree import DecisionTreeRegressor
>>> reg = DecisionTreeRegressor(max_depth=5, max_bins=32)
>>> reg.fit(X_train, y_train)
DecisionTreeRegressor(max_bins=32, max_depth=5)
>>> predictions = reg.predict(X_test)
__init__(*, criterion='squared_error', max_depth=None, max_bins=32, min_samples_split=2, min_samples_leaf=1, min_weight_fraction_leaf=0.0, max_features=None, random_state=None, min_impurity_decrease=0.0, max_memory_in_mb=256)[source]#

Methods

__init__(*[, criterion, max_depth, ...])

execute([session, run_kwargs, extra_tileables])

fetch([session, run_kwargs])

fit(X, y[, sample_weight, execute, session, ...])

Fit a distributed decision tree regressor.

predict(X[, execute, session, run_kwargs])

Predict regression value for X.

score(X, y[, sample_weight])

Return the coefficient of determination \(R^2\) of the prediction.

Attributes

tree_

The underlying Tree object.