RuleTree.base.RuleTreeBase.RuleTreeBase#
- class RuleTreeBase[source]#
Bases:
BaseEstimator,ABCBase class for RuleTree estimators.
RuleTree estimators may receive one input container for each supported data type:
Xfor tabular data,X_tsfor time series,X_imgfor images, andX_txtfor 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, andywhen available, refer to the same set of instances.Internally, the inputs are handled as a single dictionary
{data_type: array}(seeRuleTree.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.RuleTreethe base class of the trees.
- __init__()#
Methods
__init__()fit([X, y, X_ts, X_img, X_txt])Validate input data before fitting.
get_metadata_routing()Get metadata routing of this object.
get_params([deep])Get parameters for this estimator.
predict([X, X_ts, X_img, X_txt])Validate input data before prediction.
set_fit_request(*[, X_img, X_ts, X_txt])Configure whether metadata should be requested to be passed to the
fitmethod.set_params(**params)Set the parameters of this estimator.
set_predict_request(*[, X_img, X_ts, X_txt])Configure whether metadata should be requested to be passed to the
predictmethod.- 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:
- Raises:
ValueError – If no input container is provided, or if the provided containers and
ydo 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.
- set_fit_request(*, X_img: bool | None | str = '$UNCHANGED$', X_ts: bool | None | str = '$UNCHANGED$', X_txt: bool | None | str = '$UNCHANGED$') RuleTreeBase#
Configure whether metadata should be requested to be passed to the
fitmethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed tofitif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it tofit.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
- Parameters:
X_img (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
X_imgparameter infit.X_ts (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
X_tsparameter infit.X_txt (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
X_txtparameter infit.
- Returns:
self – The updated object.
- Return type:
- set_predict_request(*, X_img: bool | None | str = '$UNCHANGED$', X_ts: bool | None | str = '$UNCHANGED$', X_txt: bool | None | str = '$UNCHANGED$') RuleTreeBase#
Configure whether metadata should be requested to be passed to the
predictmethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed topredictif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it topredict.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
- Parameters:
X_img (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
X_imgparameter inpredict.X_ts (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
X_tsparameter inpredict.X_txt (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
X_txtparameter inpredict.
- Returns:
self – The updated object.
- Return type: