class_docstr: A shapelet transform classifier (STC).
  
  Implementation of the binary shapelet transform classifier pipeline along the lines
  of [1][2] but with random shapelet sampling. Transforms the data using the
  configurable `RandomShapeletTransform` and then builds a `RotationForest`
  classifier.
  
  As some implementations and applications contract the transformation solely,
  contracting is available for the transform only and both classifier and transform.
  
  Parameters
  ----------
  n_shapelet_samples : int, default=10000
      The number of candidate shapelets to be considered for the final transform.
      Filtered down to ``<= max_shapelets``, keeping the shapelets with the most
      information gain.
  max_shapelets : int or None, default=None
      Max number of shapelets to keep for the final transform. Each class value will
      have its own max, set to ``n_classes_ / max_shapelets``. If `None`, uses the
      minimum between ``10 * n_instances_`` and `1000`.
  max_shapelet_length : int or None, default=None
      Lower bound on candidate shapelet lengths for the transform. If ``None``, no
      max length is used
  estimator : BaseEstimator or None, default=None
      Base estimator for the ensemble, can be supplied a sklearn `BaseEstimator`. If
      `None` a default `RotationForest` classifier is used.
  transform_limit_in_minutes : int, default=0
      Time contract to limit transform time in minutes for the shapelet transform,
      overriding `n_shapelet_samples`. A value of `0` means ``n_shapelet_samples``
      is used.
  time_limit_in_minutes : int, default=0
      Time contract to limit build time in minutes, overriding ``n_shapelet_samples``
      and ``transform_limit_in_minutes``. The ``estimator`` will only be contracted if
      a ``time_limit_in_minutes parameter`` is present. Default of `0` means
      ``n_shapelet_samples`` or ``transform_limit_in_minutes`` is used.
  contract_max_n_shapelet_samples : int, default=np.inf
      Max number of shapelets to extract when contracting the transform with
      ``transform_limit_in_minutes`` or ``time_limit_in_minutes``.
  save_transformed_data : bool, default=False
      Save the data transformed in fit in ``transformed_data_`` for use in
      ``_get_train_probs``.
  n_jobs : int, default=1
      The number of jobs to run in parallel for both ``fit`` and ``predict``.
      `-1` means using all processors.
  batch_size : int or None, default=100
      Number of shapelet candidates processed before being merged into the set of best
      shapelets in the transform.
  random_state : int, 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.
  fit_time_  : int
      The time (in milliseconds) for ``fit`` to run.
  n_instances_ : int
      The number of train cases in the training set.
  n_dims_ : int
      The number of dimensions per case in the training set.
  series_length_ : int
      The length of each series 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_data`` is `True`.
  
  See Also
  --------
  RandomShapeletTransform : The randomly sampled shapelet transform.
  RotationForest : The default rotation forest classifier used.
  
  Notes
  -----
  For the Java version, see
  `tsml <https://github.com/uea-machine-learning/tsml/blob/master/src/main/
  java/tsml/classifiers/shapelet_based/ShapeletTransformClassifier.java>`_.
  
  References
  ----------
  .. [1] Jon Hills et al., "Classification of time series by shapelet transformation",
     Data Mining and Knowledge Discovery, 28(4), 851--881, 2014.
  .. [2] A. Bostrom and A. Bagnall, "Binary Shapelet Transform for Multiclass Time
     Series Classification", Transactions on Large-Scale Data and Knowledge Centered
     Systems, 32, 2017.
  
  Examples
  --------
  >>> from sktime.classification.shapelet_based import ShapeletTransformClassifier
  >>> from sktime.classification.sklearn import RotationForest
  >>> from sktime.datasets import load_unit_test
  >>> 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) # doctest: +SKIP
  >>> clf = ShapeletTransformClassifier(
  ...     estimator=RotationForest(n_estimators=3),
  ...     n_shapelet_samples=100,
  ...     max_shapelets=10,
  ...     batch_size=20,
  ... ) # doctest: +SKIP
  >>> clf.fit(X_train, y_train) # doctest: +SKIP
  ShapeletTransformClassifier(...)
  >>> y_pred = clf.predict(X_test) # doctest: +SKIP
class_docstr_tok: ["A","shapelet","transform","classifier","(","STC",")",".","Implementation","of","the","binary","shapelet","transform","classifier","pipeline","along","the","lines","of","[","1","]","[","2","]","but","with","random","shapelet","sampling",".","Transforms","the","data","using","the","configurable","`","RandomShapeletTransform","`","and","then","builds","a","`","RotationForest","`","classifier",".","As","some","implementations","and","applications","contract","the","transformation","solely",",","contracting","is","available","for","the","transform","only","and","both","classifier","and","transform",".","Parameters","--","--","--","--","--","n_shapelet_samples",":","int",",","default=10000","The","number","of","candidate","shapelets","to","be","considered","for","the","final","transform",".","Filtered","down","to","``","<","=","max_shapelets","``",",","keeping","the","shapelets","with","the","most","information","gain",".","max_shapelets",":","int","or","None",",","default=None","Max","number","of","shapelets","to","keep","for","the","final","transform",".","Each","class","value","will","have","its","own","max",",","set","to","``","n_classes_","\/","max_shapelets","``",".","If","`","None","`",",","uses","the","minimum","between","``","10","*","n_instances_","``","and","`","1000","`",".","max_shapelet_length",":","int","or","None",",","default=None","Lower","bound","on","candidate","shapelet","lengths","for","the","transform",".","If","``","None","``",",","no","max","length","is","used","estimator",":","BaseEstimator","or","None",",","default=None","Base","estimator","for","the","ensemble",",","can","be","supplied","a","sklearn","`","BaseEstimator","`",".","If","`","None","`","a","default","`","RotationForest","`","classifier","is","used",".","transform_limit_in_minutes",":","int",",","default=0","Time","contract","to","limit","transform","time","in","minutes","for","the","shapelet","transform",",","overriding","`","n_shapelet_samples","`",".","A","value","of","`","0","`","means","``","n_shapelet_samples","``","is","used",".","time_limit_in_minutes",":","int",",","default=0","Time","contract","to","limit","build","time","in","minutes",",","overriding","``","n_shapelet_samples","``","and","``","transform_limit_in_minutes","``",".","The","``","estimator","``","will","only","be","contracted","if","a","``","time_limit_in_minutes","parameter","``","is","present",".","Default","of","`","0","`","means","``","n_shapelet_samples","``","or","``","transform_limit_in_minutes","``","is","used",".","contract_max_n_shapelet_samples",":","int",",","default=np.inf","Max","number","of","shapelets","to","extract","when","contracting","the","transform","with","``","transform_limit_in_minutes","``","or","``","time_limit_in_minutes","``",".","save_transformed_data",":","bool",",","default=False","Save","the","data","transformed","in","fit","in","``","transformed_data_","``","for","use","in","``","_get_train_probs","``",".","n_jobs",":","int",",","default=1","The","number","of","jobs","to","run","in","parallel","for","both","``","fit","``","and","``","predict","``",".","`","-1","`","means","using","all","processors",".","batch_size",":","int","or","None",",","default=100","Number","of","shapelet","candidates","processed","before","being","merged","into","the","set","of","best","shapelets","in","the","transform",".","random_state",":","int",",","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",".","fit_time_",":","int","The","time","(","in","milliseconds",")","for","``","fit","``","to","run",".","n_instances_",":","int","The","number","of","train","cases","in","the","training","set",".","n_dims_",":","int","The","number","of","dimensions","per","case","in","the","training","set",".","series_length_",":","int","The","length","of","each","series","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_data","``","is","`","True","`",".","See","Also","--","--","--","--","RandomShapeletTransform",":","The","randomly","sampled","shapelet","transform",".","RotationForest",":","The","default","rotation","forest","classifier","used",".","Notes","--","--","-","For","the","Java","version",",","see","`","tsml","<","https",":","\/\/github.com\/uea-machine-learning\/tsml\/blob\/master\/src\/main\/","java\/tsml\/classifiers\/shapelet_based\/ShapeletTransformClassifier.java",">","`","_",".","References","--","--","--","--","--","..","[","1","]","Jon","Hills","et","al.",",","``","Classification","of","time","series","by","shapelet","transformation","''",",","Data","Mining","and","Knowledge","Discovery",",","28","(","4",")",",","851","--","881",",","2014",".","..","[","2","]","A.","Bostrom","and","A.","Bagnall",",","``","Binary","Shapelet","Transform","for","Multiclass","Time","Series","Classification","''",",","Transactions","on","Large-Scale","Data","and","Knowledge","Centered","Systems",",","32",",","2017",".","Examples","--","--","--","--",">",">",">","from","sktime.classification.shapelet_based","import","ShapeletTransformClassifier",">",">",">","from","sktime.classification.sklearn","import","RotationForest",">",">",">","from","sktime.datasets","import","load_unit_test",">",">",">","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",")","#","doctest",":","+SKIP",">",">",">","clf","=","ShapeletTransformClassifier","(","...","estimator=RotationForest","(","n_estimators=3",")",",","...","n_shapelet_samples=100",",","...","max_shapelets=10",",","...","batch_size=20",",","...",")","#","doctest",":","+SKIP",">",">",">","clf.fit","(","X_train",",","y_train",")","#","doctest",":","+SKIP","ShapeletTransformClassifier","(","...",")",">",">",">","y_pred","=","clf.predict","(","X_test",")","#","doctest",":","+SKIP"]
docstr: Fit ShapeletTransformClassifier to training data.
  
  Parameters
  ----------
  X : 3D np.array of shape = [n_instances, n_dimensions, series_length]
      The training data.
  y : array-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 "_".
docstr_tok: ["Fit","ShapeletTransformClassifier","to","training","data",".","Parameters","--","--","--","--","--","X",":","3D","np.array","of","shape","=","[","n_instances",",","n_dimensions",",","series_length","]","The","training","data",".","y",":","array-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","``","_","''","."]
code: def _fit(self, X, y):
      """Fit ShapeletTransformClassifier to training data.
  
      Parameters
      ----------
      X : 3D np.array of shape = [n_instances, n_dimensions, series_length]
          The training data.
      y : array-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 "_".
      """
      self.n_instances_, self.n_dims_, self.series_length_ = X.shape
  
      if self.time_limit_in_minutes > 0:
          # contracting 2/3 transform (with 1/5 of that taken away for final
          # transform), 1/3 classifier
          third = self.time_limit_in_minutes / 3
          self._classifier_limit_in_minutes = third
          self._transform_limit_in_minutes = (third * 2) / 5 * 4
      elif self.transform_limit_in_minutes > 0:
          self._transform_limit_in_minutes = (
              self.transform_limit_in_minutes
          )
  
      self._transformer = RandomShapeletTransform(
          n_shapelet_samples=self.n_shapelet_samples,
          max_shapelets=self.max_shapelets,
          max_shapelet_length=self.max_shapelet_length,
          time_limit_in_minutes=self._transform_limit_in_minutes,
          contract_max_n_shapelet_samples=self.contract_max_n_shapelet_samples,
          n_jobs=self.n_jobs,
          batch_size=self.batch_size,
          random_state=self.random_state,
      )
  
      self._estimator = _clone_estimator(
          RotationForest()
          if self.estimator is None
          else self.estimator,
          self.random_state,
      )
  
      if isinstance(self._estimator, RotationForest):
          self._estimator.save_transformed_data = (
              self.save_transformed_data
          )
  
      m = getattr(self._estimator, "n_jobs", None)
      if m is not None:
          self._estimator.n_jobs = self._threads_to_use
  
      m = getattr(self._estimator, "time_limit_in_minutes", None)
      if m is not None and self.time_limit_in_minutes > 0:
          self._estimator.time_limit_in_minutes = (
              self._classifier_limit_in_minutes
          )
  
      X_t = self._transformer.fit_transform(X, y).to_numpy()
  
      if self.save_transformed_data:
          self.transformed_data_ = X_t
  
      self._estimator.fit(X_t, y)
  
      return self
  
file_path: sktime/sktime/classification/shapelet_based/_stc.py
imports: import numpy
  from sklearn.model_selection import cross_val_predict
  from sktime.base._base import _clone_estimator
  from sktime.classification.base import BaseClassifier
  from sktime.classification.sklearn import RotationForest
  from sktime.transformations.panel.shapelet_transform import RandomShapeletTransform
  from sktime.utils.validation.panel import check_X_y
label_desc: Use image node_id 2 for calling the ShapeletTransformClassifier obj's underlying member method code with example usage: obj._fit(X, y) and returns: self