RotationForestClassifier¶
- class RotationForestClassifier(n_estimators: int = 200, min_group: int = 3, max_group: int = 3, remove_proportion: float = 0.5, base_estimator: Type[BaseEstimator] | None = None, time_limit_in_minutes: int = 0.0, contract_max_n_estimators: int = 500, save_transformed_data: bool = 'deprecated', n_jobs: int = 1, random_state: int | Type[RandomState] | None = None)[source]¶
A rotation forest (RotF) vector classifier.
Implementation of the Rotation Forest classifier described [1]. Builds a forest of trees build on random portions of the data transformed using PCA.
Intended as a benchmark for time series data and a base classifier for transformation based appraoches such as ShapeletTransformClassifier, this aeon implementation only works with continuous attributes.
- Parameters:
- n_estimatorsint, default=200
Number of estimators to build for the ensemble.
- min_groupint, default=3
The minimum size of an attribute subsample group.
- max_groupint, default=3
The maximum size of an attribute subsample group.
- remove_proportionfloat, default=0.5
The proportion of cases to be removed per group.
- base_estimatorBaseEstimator or None, default=”None”
Base estimator for the ensemble. By default, uses the sklearn DecisionTreeClassifier using entropy as a splitting measure.
- time_limit_in_minutesint, default=0
Time contract to limit build time in minutes, overriding
n_estimators
. Default of 0 meansn_estimators
is used.- contract_max_n_estimatorsint, default=500
Max number of estimators to build when
time_limit_in_minutes
is set.- save_transformed_databool, default=False
Save the data transformed in fit.
Deprecated and will be removed in v0.10.0. Use fit_predict and fit_predict_proba to generate train estimates instead. transformed_data_ will also be removed.
- n_jobsint, default=1
The number of jobs to run in parallel for both
fit
andpredict
. -1 means using all processors.- 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.
- estimators_list of shape (n_estimators) of BaseEstimator
The collections of estimators trained in fit.
References
[1]Rodriguez, Juan José, Ludmila I. Kuncheva, and Carlos J. Alonso. “Rotation forest: A new classifier ensemble method.” IEEE transactions on pattern analysis and machine intelligence 28.10 (2006).
[2]Bagnall, A., et al. “Is rotation forest the best classifier for problems with continuous features?.” arXiv preprint arXiv:1809.06705 (2018).
Examples
>>> from aeon.classification.sklearn import RotationForestClassifier >>> from aeon.testing.utils.data_gen import make_example_2d_numpy >>> X, y = make_example_2d_numpy(n_cases=10, n_timepoints=12, random_state=0) >>> clf = RotationForestClassifier(n_estimators=10) >>> clf.fit(X, y) RotationForestClassifier(n_estimators=10) >>> clf.predict(X) array([0, 1, 0, 1, 0, 0, 1, 1, 1, 0])
Methods
fit
(X, y)Fit a forest of trees on cases (X,y), where y is the target variable.
fit_predict
(X, y)Fit a forest of trees and estimate predictions of the input.
fit_predict_proba
(X, y)Fit a forest of trees and estimate probabilities of the input.
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.
- fit(X, y)[source]¶
Fit a forest of trees on cases (X,y), where y is the target variable.
- 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) ndarray [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) ndarray [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_.
- fit_predict(X, y) ndarray [source]¶
Fit a forest of trees and estimate predictions of the input.
fit_predict produces prediction estimates using just the train data. The output is found using out-of-bag (OOB) estimates from the forest.
- Parameters:
- X2d ndarray or DataFrame of shape = [n_cases, n_attributes]
The training data.
- yarray-like, shape = [n_cases]
The class labels.
- Returns:
- yarray-like, shape = [n_cases]
Predicted class labels.
Notes
Changes state by creating a fitted model that updates attributes ending in “_”.
- fit_predict_proba(X, y) ndarray [source]¶
Fit a forest of trees and estimate probabilities of the input.
fit_predict produces prediction probability estimates using just the train data. The output is found using out-of-bag (OOB) estimates from the forest.
- Parameters:
- X2d ndarray or DataFrame of shape = [n_cases, n_attributes]
The training data.
- yarray-like, shape = [n_cases]
The class labels.
- Returns:
- yarray-like, shape = [n_cases, n_classes_]
Predicted probabilities using the ordering in classes_.
Notes
Changes state by creating a fitted model that updates attributes ending in “_”.
- 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.