Skip to main content

DecisionTreeRegressor

#include <Skigen/Tree>

template <typename Scalar = double>
class Skigen::DecisionTreeRegressor(max_depth=-1, min_samples_split=2, max_features_mode=0, max_features_value=0.0, random_state=std::nullopt)

A decision tree regressor.

Uses MSE (Mean Squared Error) reduction as the splitting criterion. The prediction for a leaf node is the mean of the target values.

Mirrors sklearn.tree.DecisionTreeRegressor.



Attributes:

  • feature_importances : RowVectorType

  • n_targets : int


Methods

fit(X, y)

Build a decision tree regressor from the training set.


predict(X)

Predict using a sparse design matrix (densifies internally).


fit_with_indices(X, y, sample_indices)


fit(X, y)

Fit natively on a sparse design matrix without densifying.

Split finding runs through a CSC column accessor that materialises one feature column at a time (implicit zeros filled as 0), so the full dense n×pn \times p matrix is never built. Results match a dense fit exactly.


fit_columns(cols, y, sample_indices, n_rows, n_cols)


predict(X)

Predict target values for X.


score(X, y)

Return the R2R^2 coefficient of determination.


fit_multi(X, Y)

Fit on a multi-target response matrix Y (n_samples × n_targets).

Implementation: fits one shared tree whose split criterion is the sum of target variances across all output columns, matching sklearn's joint multi-output tree structure.

The single-target API (fit(X, y) / predict(X)) is unchanged; after fit_multi, the first target column's tree backs predict() for callers that expect a vector output.


fit_with_indices_multi(X, Y, sample_indices)

Multi-target fit on a specific row index subset.

Mirrors fit_with_indices for the single-target path but builds one shared joint tree with summed-variance split scoring. Used by ensemble bootstraps that need per-tree multi-output sample subsets.


predict_multi(X)

Multi-target predict (n_samples × n_targets).


build_tree(X, y, indices, depth)


build_multi_tree(X, Y, indices, depth)