ContinuousIntervalTree#
- class ContinuousIntervalTree(max_depth=9223372036854775807, thresholds=20, random_state=None)[source]#
Continuous interval tree (CIT) vector classifier (aka Time Series Tree).
The
Time Series Tree
described in the Time Series Forest (TSF) paper Deng et al (2013) [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
andDrCIF
.- Parameters:
- max_depthint, default=sys.maxsize
Maximum depth for the tree.
- thresholdsint, default=20
Number of thresholds to split continuous 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; IfRandomState
instance, random_state is the random number generator; IfNone
, the random number generator is theRandomState
instance used bynp.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_instances_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 sktime.classification.sklearn import ContinuousIntervalTree >>> from sktime.datasets import load_unit_test >>> from sktime.datatypes._panel._convert import from_nested_to_3d_numpy >>> X_train, y_train = load_unit_test(split="train", return_X_y=True) >>> X_test, y_test = load_unit_test(split="test", return_X_y=True) >>> X_train = from_nested_to_3d_numpy(X_train) >>> X_test = from_nested_to_3d_numpy(X_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 of this object.
get_params
([deep])Get parameters for this estimator.
predict
(X)Predict for all cases in X.
Probability estimates for each class for all cases in X.
set_params
(**params)Set the parameters of this estimator.
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_instances, n_attributes]
The training data.
- yarray-like, shape = [n_instances]
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_instances, n_attributes]
The data to make predictions for.
- Returns:
- yarray-like, shape = [n_instances]
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_instances, n_attributes]
The data to make predictions for.
- Returns:
- yarray-like, shape = [n_instances, n_classes_]
Predicted probabilities using the ordering in classes_.
- tree_node_splits_and_gain()[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.
- 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.