RuleTreeBase#

class RuleTreeBase[source]#

Bases: BaseEstimator, ABC

Base class for RuleTree estimators.

RuleTree estimators may receive one input container for each supported data type: X for tabular data, X_ts for time series, X_img for images, and X_txt for text. The only assumption made by this base class is that the first dimension of every provided container is the number of samples. This is enough to validate that all provided inputs, and y when available, refer to the same set of instances.

Internally, the inputs are handled as a single dictionary {data_type: array} (see RuleTree.utils.define.DATA_INPUT_TYPES), built by _validate_inputs().

Notes

The class follows the scikit-learn estimator API by inheriting from sklearn.base.BaseEstimator. The base implementation only validates inputs; concrete estimators are expected to implement the actual fitting and prediction behavior.

See also

RuleTree.tree.RuleTree.RuleTree

the base class of the trees.

fit(X=None, y=None, X_ts=None, X_img=None, X_txt=None)[source]#

Validate input data before fitting.

Parameters:
  • X (array-like of shape (n_samples, n_features), default=None) – Tabular input data.

  • X_ts (array-like of shape (n_samples, ...), default=None) – Time-series input data.

  • X_img (array-like of shape (n_samples, ...), default=None) – Image input data.

  • X_txt (array-like of shape (n_samples, ...), default=None) – Text input data.

  • y (array-like of shape (n_samples,), default=None) – Target values.

Returns:

self – The validated estimator instance.

Return type:

RuleTreeBase

Raises:

ValueError – If no input container is provided, or if the provided containers and y do not have a consistent number of samples.

predict(X=None, X_ts=None, X_img=None, X_txt=None)[source]#

Validate input data before prediction.

Parameters:
  • X (array-like of shape (n_samples, n_features), default=None) – Tabular input data.

  • X_ts (array-like of shape (n_samples, ...), default=None) – Time-series input data.

  • X_img (array-like of shape (n_samples, ...), default=None) – Image input data.

  • X_txt (array-like of shape (n_samples, ...), default=None) – Text input data.

Raises:

ValueError – If no input container is provided, or if the provided containers do not have a consistent number of samples.