SplitStrategyΒΆ
- class SplitStrategy[source]ΒΆ
Bases:
ABCAbstract 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