RotationForest
RotationForest
- class RotationForest(n_estimators=200, min_group=3, max_group=3, remove_proportion=0.5, base_estimator=None, time_limit_in_minutes=0.0, contract_max_n_estimators=500, save_transformed_data=False, n_jobs=1, random_state=None)[source]
A rotation forest (RotF) vector classifier.
Implementation of the Rotation Forest classifier described in Rodriguez et al (2013) [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 approaches such as ShapeletTransformClassifier, this sktime 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
DecisionTreeClassifierusing entropy as a splitting measure.- time_limit_in_minutesint, default=0
Time contract to limit build time in minutes, overriding
n_estimators. Default of0meansn_estimatorsis used.- contract_max_n_estimatorsint, default=500
Max number of estimators to build when
time_limit_in_minutesis set.- save_transformed_databool, default=False
Save the data transformed in fit in
transformed_data_for use in_get_train_probs.- n_jobsint, default=1
The number of jobs to run in parallel for both
fitandpredict.-1means using all processors.- random_stateint, RandomState instance or None, default=None
If
int, random_state is the seed used by the random number generator; IfRandomStateinstance, random_state is the random number generator; IfNone, the random number generator is theRandomStateinstance 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.
- transformed_data_list of shape (n_estimators) of ndarray
The transformed training dataset for all classifiers. Only saved when
save_transformed_dataisTrue.- estimators_list of shape (n_estimators) of BaseEstimator
The collections of estimators trained in fit.
See also
ShapeletTransformClassifierA shapelet-based classifier using Rotation Forest.
Notes
For the Java version, see tsml.
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 sklearn.datasets import load_iris >>> from sklearn.model_selection import train_test_split >>> from sktime.classification.sklearn import RotationForest >>> >>> X, y = load_iris(return_X_y=True, as_frame=True) >>> X_train, X_test, y_train, y_test = train_test_split(X, y) >>> >>> clf = RotationForest(n_estimators=10) >>> clf.fit(X_train, y_train) RotationForest(...) >>> y_pred = clf.predict(X_test)
Methods
fit(X, y)Fit a forest of trees 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 accuracy on provided data and labels.
set_params(**params)Set the parameters of this estimator.
set_score_request(*[, sample_weight])Configure whether metadata should be requested to be passed to the
scoremethod.

