SplitStrategyΒΆ

class SplitStrategy[source]ΒΆ

Bases: ABC

Abstract base class for split finding strategies.

__init__()ΒΆ

Methods

__init__()

find_best_split(X, y[, X_val, y_val, depth])

Find the best split for the given data.

should_stop(X, y, current_gain, depth, **kwargs)

Determine if splitting should stop at this node.

abstractmethod find_best_split(X, y, X_val=None, y_val=None, depth=0, **kwargs)[source]ΒΆ

Find the best split for the given data.

Parameters:
  • X (ndarray) – Training feature matrix for structure learning.

  • y (ndarray) – Training target values for structure learning.

  • X_val (ndarray | None) – Validation feature matrix for split evaluation.

  • y_val (ndarray | None) – Validation target values for split evaluation.

  • depth (int) – Current depth in the tree.

  • **kwargs – Strategy-specific parameters.

Returns:

Best split found, or None if no good split exists

Return type:

SplitCandidate | None

abstractmethod should_stop(X, y, current_gain, depth, **kwargs)[source]ΒΆ

Determine if splitting should stop at this node.

Parameters:
  • X (ndarray) – Feature matrix at current node.

  • y (ndarray) – Target values at current node.

  • current_gain (float) – Information gain of current best split.

  • depth (int) – Current tree depth.

  • **kwargs – Additional strategy-specific parameters.

Returns:

True if splitting should stop, False otherwise.

Return type:

bool