class_docstr: Temporal Dictionary Ensemble (TDE).
  
  Implementation of the dictionary based Temporal Dictionary Ensemble as described
  in [1]_.
  
  Overview: Input "n" series length "m" with "d" dimensions
  TDE searches "k" parameter values selected using a Gaussian processes
  regressor, evaluating each with a LOOCV. It then retains "s"
  ensemble members.
  There are six primary parameters for individual classifiers:
          - alpha: alphabet size
          - w: window length
          - l: word length
          - p: normalise/no normalise
          - h: levels
          - b: MCB/IGB
  For any combination, an individual TDE classifier slides a window of
  length w along the series. The w length window is shortened to
  an l length word through taking a Fourier transform and keeping the
  first l/2 complex coefficients. These lcoefficients are then discretised
  into alpha possible values, to form a word length l using breakpoints
  found using b. A histogram of words for each series is formed and stored,
  using a spatial pyramid of h levels. For multivariate series, accuracy
  from a reduced histogram is used to select dimensions.
  
  fit involves finding n histograms.
  predict uses 1 nearest neighbour with a the histogram intersection
  distance function.
  
  Parameters
  ----------
  n_parameter_samples : int, default=250
      Number of parameter combinations to consider for the final ensemble.
  max_ensemble_size : int, default=50
      Maximum number of estimators in the ensemble.
  max_win_len_prop : float, default=1
      Maximum window length as a proportion of series length, must be between 0 and 1.
  min_window : int, default=10
      Minimum window length.
  randomly_selected_params: int, default=50
      Number of parameters randomly selected before the Gaussian process parameter
      selection is used.
  bigrams : boolean or None, default=None
      Whether to use bigrams, defaults to true for univariate data and false for
      multivariate data.
  dim_threshold : float, default=0.85
      Dimension accuracy threshold for multivariate data, must be between 0 and 1.
  max_dims : int, default=20
      Max number of dimensions per classifier for multivariate data.
  time_limit_in_minutes : int, default=0
      Time contract to limit build time in minutes, overriding n_parameter_samples.
      Default of 0 means n_parameter_samples is used.
  contract_max_n_parameter_samples : int, default=np.inf
      Max number of parameter combinations to consider when time_limit_in_minutes is
      set.
  typed_dict : bool, default=True
      Use a numba typed Dict to store word counts. May increase memory usage, but will
      be faster for larger datasets. As the Dict cannot be pickled currently, there
      will be some overhead converting it to a python dict with multiple threads and
      pickling.
  save_train_predictions : bool, default=False
      Save the ensemble member train predictions in fit for use in _get_train_probs
      leave-one-out cross-validation.
  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.
  classes_ : list
      The classes labels.
  n_instances_ : int
      The number of train cases.
  n_dims_ : int
      The number of dimensions per case.
  series_length_ : int
      The length of each series.
  n_estimators_ : int
      The final number of classifiers used (<= max_ensemble_size)
  estimators_ : list of shape (n_estimators) of IndividualTDE
      The collections of estimators trained in fit.
  weights_ : list of shape (n_estimators) of float
      Weight of each estimator in the ensemble.
  
  See Also
  --------
  IndividualTDE, ContractableBOSS
  
  Notes
  -----
  For the Java version, see
  `TSML <https://github.com/uea-machine-learning/tsml/blob/master/src/main/java/
  tsml/classifiers/dictionary_based/TDE.java>`_.
  
  References
  ----------
  ..  [1] Matthew Middlehurst, James Large, Gavin Cawley and Anthony Bagnall
      "The Temporal Dictionary Ensemble (TDE) Classifier for Time Series
      Classification", in proceedings of the European Conference on Machine Learning
      and Principles and Practice of Knowledge Discovery in Databases, 2020.
  
  Examples
  --------
  >>> from sktime.classification.dictionary_based import TemporalDictionaryEnsemble
  >>> 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 = TemporalDictionaryEnsemble(
  ...     n_parameter_samples=10,
  ...     max_ensemble_size=3,
  ...     randomly_selected_params=5,
  ... ) # doctest: +SKIP
  >>> clf.fit(X_train, y_train) # doctest: +SKIP
  TemporalDictionaryEnsemble(...)
  >>> y_pred = clf.predict(X_test) # doctest: +SKIP
class_docstr_tok: ["Temporal","Dictionary","Ensemble","(","TDE",")",".","Implementation","of","the","dictionary","based","Temporal","Dictionary","Ensemble","as","described","in","[","1","]","_.","Overview",":","Input","``","n","''","series","length","``","m","''","with","``","d","''","dimensions","TDE","searches","``","k","''","parameter","values","selected","using","a","Gaussian","processes","regressor",",","evaluating","each","with","a","LOOCV",".","It","then","retains","``","s","''","ensemble","members",".","There","are","six","primary","parameters","for","individual","classifiers",":","-","alpha",":","alphabet","size","-","w",":","window","length","-","l",":","word","length","-","p",":","normalise\/no","normalise","-","h",":","levels","-","b",":","MCB\/IGB","For","any","combination",",","an","individual","TDE","classifier","slides","a","window","of","length","w","along","the","series",".","The","w","length","window","is","shortened","to","an","l","length","word","through","taking","a","Fourier","transform","and","keeping","the","first","l\/2","complex","coefficients",".","These","lcoefficients","are","then","discretised","into","alpha","possible","values",",","to","form","a","word","length","l","using","breakpoints","found","using","b",".","A","histogram","of","words","for","each","series","is","formed","and","stored",",","using","a","spatial","pyramid","of","h","levels",".","For","multivariate","series",",","accuracy","from","a","reduced","histogram","is","used","to","select","dimensions",".","fit","involves","finding","n","histograms",".","predict","uses","1","nearest","neighbour","with","a","the","histogram","intersection","distance","function",".","Parameters","--","--","--","--","--","n_parameter_samples",":","int",",","default=250","Number","of","parameter","combinations","to","consider","for","the","final","ensemble",".","max_ensemble_size",":","int",",","default=50","Maximum","number","of","estimators","in","the","ensemble",".","max_win_len_prop",":","float",",","default=1","Maximum","window","length","as","a","proportion","of","series","length",",","must","be","between","0","and","1.","min_window",":","int",",","default=10","Minimum","window","length",".","randomly_selected_params",":","int",",","default=50","Number","of","parameters","randomly","selected","before","the","Gaussian","process","parameter","selection","is","used",".","bigrams",":","boolean","or","None",",","default=None","Whether","to","use","bigrams",",","defaults","to","true","for","univariate","data","and","false","for","multivariate","data",".","dim_threshold",":","float",",","default=0.85","Dimension","accuracy","threshold","for","multivariate","data",",","must","be","between","0","and","1.","max_dims",":","int",",","default=20","Max","number","of","dimensions","per","classifier","for","multivariate","data",".","time_limit_in_minutes",":","int",",","default=0","Time","contract","to","limit","build","time","in","minutes",",","overriding","n_parameter_samples",".","Default","of","0","means","n_parameter_samples","is","used",".","contract_max_n_parameter_samples",":","int",",","default=np.inf","Max","number","of","parameter","combinations","to","consider","when","time_limit_in_minutes","is","set",".","typed_dict",":","bool",",","default=True","Use","a","numba","typed","Dict","to","store","word","counts",".","May","increase","memory","usage",",","but","will","be","faster","for","larger","datasets",".","As","the","Dict","can","not","be","pickled","currently",",","there","will","be","some","overhead","converting","it","to","a","python","dict","with","multiple","threads","and","pickling",".","save_train_predictions",":","bool",",","default=False","Save","the","ensemble","member","train","predictions","in","fit","for","use","in","_get_train_probs","leave-one-out","cross-validation",".","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",".","classes_",":","list","The","classes","labels",".","n_instances_",":","int","The","number","of","train","cases",".","n_dims_",":","int","The","number","of","dimensions","per","case",".","series_length_",":","int","The","length","of","each","series",".","n_estimators_",":","int","The","final","number","of","classifiers","used","(","<","=","max_ensemble_size",")","estimators_",":","list","of","shape","(","n_estimators",")","of","IndividualTDE","The","collections","of","estimators","trained","in","fit",".","weights_",":","list","of","shape","(","n_estimators",")","of","float","Weight","of","each","estimator","in","the","ensemble",".","See","Also","--","--","--","--","IndividualTDE",",","ContractableBOSS","Notes","--","--","-","For","the","Java","version",",","see","`","TSML","<","https",":","\/\/github.com\/uea-machine-learning\/tsml\/blob\/master\/src\/main\/java\/","tsml\/classifiers\/dictionary_based\/TDE.java",">","`","_",".","References","--","--","--","--","--","..","[","1","]","Matthew","Middlehurst",",","James","Large",",","Gavin","Cawley","and","Anthony","Bagnall","``","The","Temporal","Dictionary","Ensemble","(","TDE",")","Classifier","for","Time","Series","Classification","''",",","in","proceedings","of","the","European","Conference","on","Machine","Learning","and","Principles","and","Practice","of","Knowledge","Discovery","in","Databases",",","2020",".","Examples","--","--","--","--",">",">",">","from","sktime.classification.dictionary_based","import","TemporalDictionaryEnsemble",">",">",">","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","=","TemporalDictionaryEnsemble","(","...","n_parameter_samples=10",",","...","max_ensemble_size=3",",","...","randomly_selected_params=5",",","...",")","#","doctest",":","+SKIP",">",">",">","clf.fit","(","X_train",",","y_train",")","#","doctest",":","+SKIP","TemporalDictionaryEnsemble","(","...",")",">",">",">","y_pred","=","clf.predict","(","X_test",")","#","doctest",":","+SKIP"]
code: def _get_train_probs(
      self, X, y, train_estimate_method="loocv"
  ) -> np.ndarray:
      self.check_is_fitted()
      X, y = check_X_y(X, y, coerce_to_numpy=True)
  
      n_instances, n_dims, series_length = X.shape
  
      if (
          n_instances != self.n_instances_
          or n_dims != self.n_dims_
          or series_length != self.series_length_
      ):
          raise ValueError(
              "n_instances, n_dims, series_length mismatch. X should be "
              "the same as the training data used in fit for generating train "
              "probabilities."
          )
  
      results = np.zeros((n_instances, self.n_classes_))
      divisors = np.zeros(n_instances)
  
      if train_estimate_method.lower() == "loocv":
          for i, clf in enumerate(self.estimators_):
              subsample = clf._subsample
              preds = (
                  clf._train_predictions
                  if self.save_train_predictions
                  else Parallel(
                      n_jobs=self._threads_to_use, prefer="threads"
                  )(
                      delayed(clf._train_predict)(
                          i,
                      )
                      for i in range(len(subsample))
                  )
              )
  
              for n, pred in enumerate(preds):
                  results[subsample[n]][
                      self._class_dictionary[pred]
                  ] += self.weights_[i]
                  divisors[subsample[n]] += self.weights_[i]
      elif train_estimate_method.lower() == "oob":
          indices = range(n_instances)
          for i, clf in enumerate(self.estimators_):
              oob = [n for n in indices if n not in clf._subsample]
  
              if len(oob) == 0:
                  continue
  
              preds = clf.predict(X[oob])
  
              for n, pred in enumerate(preds):
                  results[oob[n]][
                      self._class_dictionary[pred]
                  ] += self.weights_[i]
                  divisors[oob[n]] += self.weights_[i]
      else:
          raise ValueError(
              "Invalid train_estimate_method. Available options: loocv, oob"
          )
  
      for i in range(n_instances):
          results[i] = (
              np.ones(self.n_classes_) * (1 / self.n_classes_)
              if divisors[i] == 0
              else results[i] / (np.ones(self.n_classes_) * divisors[i])
          )
  
      return results
  
imports: import math
  import time
  from collections import defaultdict
  import numpy
  from joblib import Parallel, delayed
  from sklearn import preprocessing
  from sklearn.kernel_ridge import KernelRidge
  from sklearn.utils import check_random_state
  from sktime.classification.base import BaseClassifier
  from sktime.transformations.panel.dictionary_based import SFA
  from sktime.utils.validation.panel import check_X_y
  from sktime.utils.warnings import warn
label_desc: Use image node_id 7 for calling the TemporalDictionaryEnsemble obj's underlying member method code with example usage: obj._get_train_probs(X, y, train_estimate_method) and returns: results