FlatMatrixRegressionSplitter#

class FlatMatrixRegressionSplitter(criterion='squared_error', min_samples_leaf=1, gain_function=None)[source]#

Bases: FlatMatrixSplitter

Splitter for regression that evaluates all the candidate splits together with matrix operations (see FlatMatrixSplitter) and maximizes the decrease of impurity.

Parameters:
  • criterion ({'squared_error', 'poisson'}, default='squared_error') – Impurity measure. ‘poisson’ is half the Poisson deviance: the target cannot be negative, and a child whose target sums to 0 is not allowed.

  • min_samples_leaf (int or float, default=1) – Minimum number of instances in each child (a fraction of the instances of the node if float).

  • gain_function (callable, default=None) – Gain of all the candidates of a node, instead of the information gain (see FlatMatrixSplitter).

Variables:
  • feature (int) – Column of the feature matrix used by the split.

  • threshold (float or object) – Threshold of a numerical split, or value of a categorical split.

  • is_categorical (bool) – Whether the split is categorical.

  • gain (float) – Gain of the split: the decrease of impurity, or the value of gain_function.

  • impurity (list of float) – Impurity of the node, of the left child and of the right child.

See also

RegressionSplitter

the splitter to use when the impurity is not changed.

Examples

>>> from sklearn.datasets import load_diabetes
>>> from RuleTree.stumps.splitters import FlatMatrixRegressionSplitter
>>> X, y = load_diabetes(return_X_y=True)
>>> splitter = FlatMatrixRegressionSplitter()
>>> splitter = splitter.fit(X, y, numerical=list(range(10)), categorical=[], context=None, node_id=None, cache=None)
>>> splitter.feature_, round(splitter.threshold_, 4)
(8, -0.0038)
task = 'reg'#