class_docstr: Supervised Time Series Forest (STSF).
  
  An ensemble of decision trees built on intervals selected through a supervised
  process as described in _[1].
  Overview: Input n series length m
  For each tree
      - sample X using class-balanced bagging
      - sample intervals for all 3 representations and 7 features using supervised
      - method
      - find mean, median, std, slope, iqr, min and max using their corresponding
      - interval for each rperesentation, concatenate to form new data set
      - build decision tree on new data set
  Ensemble the trees with averaged probability estimates.
  
  Parameters
  ----------
  n_estimators : int, default=200
      Number of estimators to build for the ensemble.
  n_jobs : int, default=1
      The number of jobs to run in parallel for both `fit` and `predict`.
      ``-1`` means using all processors.
  random_state : int or None, default=None
      Seed for random number generation.
  
  Attributes
  ----------
  n_classes_ : int
      The number of classes.
  n_instances_ : int
      The number of train cases.
  series_length_ : int
      The length of each series.
  classes_ : list
      The classes labels.
  intervals : array-like of shape [n_estimators][3][7][n_intervals][2]
      Stores indexes of all start and end points for all estimators. Each estimator
      contains indexes for each representation and feature combination.
  estimators_ : list of shape (n_estimators) of DecisionTreeClassifier
      The collections of estimators trained in fit.
  
  Notes
  -----
  For the Java version, see
  `TSML <https://github.com/uea-machine-learning/tsml/blob/master/src/main/
   java/tsml/classifiers/interval_based/STSF.java>`_.
  
  References
  ----------
  .. [1] Cabello, Nestor, et al. "Fast and Accurate Time Series Classification
     Through Supervised Interval Search." IEEE ICDM 2020
  
  Examples
  --------
  >>> from sktime.classification.interval_based import SupervisedTimeSeriesForest
  >>> 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)
  >>> clf = SupervisedTimeSeriesForest(n_estimators=5)
  >>> clf.fit(X_train, y_train)
  SupervisedTimeSeriesForest(n_estimators=5)
  >>> y_pred = clf.predict(X_test)
docstr: Build a forest of trees from the training set (X, y).
  
  Uses supervised intervals and summary features
  
  Parameters
  ----------
  X : array-like or sparse matrix of shape = [n_instances,
  series_length] or shape = [n_instances,n_columns]
      The training input samples.  If a Pandas data frame is passed it
      must have a single column (i.e. univariate
      classification. STSF has no bespoke method for multivariate
      classification as yet.
  y : array-like, shape =  [n_instances]    The class labels.
  
  Returns
  -------
  self : object
docstr_tok: ["Build","a","forest","of","trees","from","the","training","set","(","X",",","y",")",".","Uses","supervised","intervals","and","summary","features","Parameters","--","--","--","--","--","X",":","array-like","or","sparse","matrix","of","shape","=","[","n_instances",",","series_length","]","or","shape","=","[","n_instances",",","n_columns","]","The","training","input","samples",".","If","a","Pandas","data","frame","is","passed","it","must","have","a","single","column","(","i.e",".","univariate","classification",".","STSF","has","no","bespoke","method","for","multivariate","classification","as","yet",".","y",":","array-like",",","shape","=","[","n_instances","]","The","class","labels",".","Returns","--","--","--","-","self",":","object"]
code: def _fit(self, X, y):
      """Build a forest of trees from the training set (X, y).
  
      Uses supervised intervals and summary features
  
      Parameters
      ----------
      X : array-like or sparse matrix of shape = [n_instances,
      series_length] or shape = [n_instances,n_columns]
          The training input samples.  If a Pandas data frame is passed it
          must have a single column (i.e. univariate
          classification. STSF has no bespoke method for multivariate
          classification as yet.
      y : array-like, shape =  [n_instances]    The class labels.
  
      Returns
      -------
      self : object
      """
      X = X.squeeze(1)
  
      self.n_instances_, self.series_length_ = X.shape
      rng = check_random_state(self.random_state)
      cls, class_counts = np.unique(y, return_counts=True)
  
      self.intervals_ = [
          [[] for _ in range(3)] for _ in range(self.n_estimators)
      ]
  
      _, X_p = signal.periodogram(X)
      X_d = np.diff(X, 1)
  
      balance_cases = np.zeros(0, dtype=np.int32)
      average = math.floor(self.n_instances_ / self.n_classes_)
      for i, c in enumerate(cls):
          if class_counts[i] < average:
              cls_idx = np.where(y == c)[0]
              balance_cases = np.concatenate(
                  (
                      rng.choice(
                          cls_idx, size=average - class_counts[i]
                      ),
                      balance_cases,
                  )
              )
  
      fit = Parallel(n_jobs=self._threads_to_use)(
          delayed(self._fit_estimator)(
              X,
              X_p,
              X_d,
              y,
              balance_cases,
              i,
          )
          for i in range(self.n_estimators)
      )
  
      self.estimators_, self.intervals_ = zip(*fit)
  
      return self
  
imports: import math
  import numpy
  from joblib import Parallel, delayed
  from scipy import signal, stats
  from sklearn.base import clone
  from sklearn.preprocessing import StandardScaler
  from sklearn.tree import DecisionTreeClassifier
  from sklearn.utils.validation import check_random_state
  from sktime.classification.base import BaseClassifier
  from sktime.utils.slope_and_trend import _slope
label_desc: Use image node_id 2 for calling the SupervisedTimeSeriesForest obj's underlying member method code with example usage: obj._fit(X, y) and returns: self