ContinuousIntervalTree

class ContinuousIntervalTree(max_depth: int = 9223372036854775807, thresholds: int = 20, random_state: int | RandomState | None = None)[source]

Continuous interval tree (CIT) vector classifier (aka Time Series Tree).

The Time Series Tree described in the Time Series Forest (TSF) [1]. A simple information gain based tree for continuous attributes using a bespoke margin gain metric for tie breaking.

Implemented as a bade classifier for interval based time series classifiers such as CanonicalIntervalForest and DrCIF.

Parameters:
max_depthint, default=sys.maxsize

Maximum depth for the tree.

thresholdsint, default=20

Number of thresholds to split continous attributes on at tree nodes.

random_stateint, RandomState instance or None, default=None

If int, random_state is the seed used by the random number generator; If RandomState instance, random_state is the random number generator; If None, the random number generator is the RandomState instance used by np.random.

Attributes:
classes_list

The unique class labels in the training set.

n_classes_int

The number of unique classes in the training set.

n_cases_int

The number of train cases in the training set.

n_atts_int

The number of attributes in the training set.

See also

CanonicalIntervalForest
DrCIF

Notes

For the Java version, see tsml.

References

[1]

H.Deng, G.Runger, E.Tuv and M.Vladimir, “A time series forest for classification and feature extraction”,Information Sciences, 239, 2013

Examples

>>> from aeon.classification.sklearn import ContinuousIntervalTree
>>> from aeon.datasets import load_unit_test
>>> X_train, y_train = load_unit_test(split="train")
>>> X_test, y_test = load_unit_test(split="test")
>>> clf = ContinuousIntervalTree()
>>> clf.fit(X_train, y_train)
ContinuousIntervalTree(...)
>>> y_pred = clf.predict(X_test)

Methods

fit(X, y)

Fit a tree on cases (X,y), where y is the target variable.

get_metadata_routing()

Get metadata routing of this object.

get_params([deep])

Get parameters for this estimator.

predict(X)

Predict for all cases in X.

predict_proba(X)

Probability estimates for each class for all cases in X.

score(X, y[, sample_weight])

Return the mean accuracy on the given test data and labels.

set_params(**params)

Set the parameters of this estimator.

set_score_request(*[, sample_weight])

Request metadata passed to the score method.

tree_node_splits_and_gain()

Recursively find the split and information gain for each tree node.

fit(X, y)[source]

Fit a tree on cases (X,y), where y is the target variable.

Build an information gain based tree for continuous attributes using the margin gain metric for ties.

Parameters:
X2d ndarray or DataFrame of shape = [n_cases, n_attributes]

The training data.

yarray-like, shape = [n_cases]

The class labels.

Returns:
self

Reference to self.

Notes

Changes state by creating a fitted model that updates attributes ending in “_”.

predict(X)[source]

Predict for all cases in X. Built on top of predict_proba.

Parameters:
X2d ndarray or DataFrame of shape = [n_cases, n_attributes]

The data to make predictions for.

Returns:
yarray-like, shape = [n_cases]

Predicted class labels.

predict_proba(X)[source]

Probability estimates for each class for all cases in X.

Parameters:
X2d ndarray or DataFrame of shape = [n_cases, n_attributes]

The data to make predictions for.

Returns:
yarray-like, shape = [n_cases, n_classes_]

Predicted probabilities using the ordering in classes_.

tree_node_splits_and_gain() tuple[list[int], list[float]][source]

Recursively find the split and information gain for each tree node.

get_metadata_routing()[source]

Get metadata routing of this object.

Please check User Guide on how the routing mechanism works.

Returns:
routingMetadataRequest

A MetadataRequest encapsulating routing information.

get_params(deep=True)[source]

Get parameters for this estimator.

Parameters:
deepbool, default=True

If True, will return the parameters for this estimator and contained subobjects that are estimators.

Returns:
paramsdict

Parameter names mapped to their values.

score(X, y, sample_weight=None)[source]

Return the mean accuracy on the given test data and labels.

In multi-label classification, this is the subset accuracy which is a harsh metric since you require for each sample that each label set be correctly predicted.

Parameters:
Xarray-like of shape (n_samples, n_features)

Test samples.

yarray-like of shape (n_samples,) or (n_samples, n_outputs)

True labels for X.

sample_weightarray-like of shape (n_samples,), default=None

Sample weights.

Returns:
scorefloat

Mean accuracy of self.predict(X) w.r.t. y.

set_params(**params)[source]

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as Pipeline). The latter have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.

Parameters:
**paramsdict

Estimator parameters.

Returns:
selfestimator instance

Estimator instance.

set_score_request(*, sample_weight: bool | None | str = '$UNCHANGED$') ContinuousIntervalTree[source]

Request metadata passed to the score method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config). Please see User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to score if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to score.

  • 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.

Note

This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a Pipeline. Otherwise it has no effect.

Parameters:
sample_weightstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED

Metadata routing for sample_weight parameter in score.

Returns:
selfobject

The updated object.