class_docstr: Learning Shapelets algorithm.
  
  This estimator consists of two steps: computing the distances between the
  shapelets and the time series, then computing a logistic regression using
  these distances as features. This algorithm learns the shapelets as well as
  the coefficients of the logistic regression.
  
  Parameters
  ----------
  n_shapelets_per_size : int or float (default = 0.2)
      Number of shapelets per size. If float, it represents
      a fraction of the number of timestamps and the number
      of shapelets per size is equal to
      ``ceil(n_shapelets_per_size * n_timestamps)``.
  
  min_shapelet_length : int or float (default = 0.1)
      Minimum length of the shapelets. If float, it represents
      a fraction of the number of timestamps and the minimum
      length of the shapelets per size is equal to
      ``ceil(min_shapelet_length * n_timestamps)``.
  
  shapelet_scale : int (default = 3)
      The different scales for the lengths of the shapelets.
      The lengths of the shapelets are equal to
      ``min_shapelet_length * np.arange(1, shapelet_scale + 1)``.
      The total number of shapelets (and features)
      is equal to ``n_shapelets_per_size * shapelet_scale``.
  
  penalty : 'l1' or 'l2' (default = 'l2')
      Used to specify the norm used in the penalization.
  
  tol : float (default = 1e-3)
      Tolerance for stopping criterion.
  
  C : float (default = 1000)
      Inverse of regularization strength. It must be a positive float.
      Smaller values specify stronger regularization.
  
  learning_rate : float (default = 1.)
      Learning rate for gradient descent optimization. It must be a positive
      float. Note that the learning rate will be automatically decreased
      if the loss function is not decreasing.
  
  max_iter : int (default = 1000)
      Maximum number of iterations for gradient descent algorithm.
  
  multi_class : {'multinomial', 'ovr', 'ovo'} (default = 'multinomial')
      Strategy for multiclass classification.
      'multinomial' stands for multinomial cross-entropy loss.
      'ovr' stands for one-vs-rest strategy.
      'ovo' stands for one-vs-one strategy.
      Ignored if the classification task is binary.
  
  alpha : float (default = -100)
      Scaling term in the softmin function. The lower, the more precised
      the soft minimum will be. Default value should be good for
      standardized time series.
  
  fit_intercept : bool (default = True)
      Specifies if a constant (a.k.a. bias or intercept) should be
      added to the decision function.
  
  intercept_scaling : float (default = 1.)
      Scaling of the intercept. Only used if ``fit_intercept=True``.
  
  class_weight : dict, None or 'balanced' (default = None)
      Weights associated with classes in the form ``{class_label: weight}``.
      If not given, all classes are supposed to have unit weight.
      The "balanced" mode uses the values of y to automatically adjust
      weights inversely proportional to class frequencies in the input data
      as ``n_samples / (n_classes * np.bincount(y))``.
  
  verbose : int (default = 0)
      Controls the verbosity. It must be a non-negative integer.
      If positive, loss at each iteration is printed.
  
  random_state : None, int or RandomState instance (default = None)
      The seed of the pseudo random number generator to use when shuffling
      the data. 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`.
  
  n_jobs : None or int (default = None)
      The number of jobs to use for the computation. Only used if
      ``multi_class`` is 'ovr' or 'ovo'.
  
  Attributes
  ----------
  classes_ : array, shape = (n_classes,)
      An array of class labels known to the classifier.
  
  shapelets_ : array shape = (n_tasks, n_shapelets)
      Learned shapelets. Each element of this array is a learned
      shapelet.
  
  coef_ : array, shape = (n_tasks, n_shapelets) or (n_classes, n_shapelets)
      Coefficients for each shapelet in the decision function.
  
  intercept_ : array, shape = (n_tasks,) or (n_classes,)
      Intercepts (a.k.a. biases) added to the decision function.
      If ``fit_intercept=False``, the intercepts are set to zero.
  
  n_iter_ : array, shape = (n_tasks,)
      Actual number of iterations.
  
  Notes
  -----
  The number of tasks (n_tasks) depends on the value of ``multi_class``
  and the number of classes. If there are two classes, the number of
  tasks is equal to 1. If there are more than two classes, the number
  of tasks is equal to:
  
      - 1 if ``multi_class='multinomial'``
      - n_classes if ``multi_class='ovr'``
      - n_classes * (n_classes - 1) / 2 if ``multi_class='ovo'``
  
  References
  ----------
  .. [1] J. Grabocka, N. Schilling, M. Wistuba and L. Schmidt-Thieme,
         "Learning Time-Series Shapelets". International Conference on Data
         Mining, 14, 392-401 (2014).
  
  Examples
  --------
  >>> from pyts.classification import LearningShapelets
  >>> X = [[1, 2, 2, 1, 2, 3, 2],
  ...      [0, 2, 0, 2, 0, 2, 3],
  ...      [0, 1, 2, 2, 1, 2, 2]]
  >>> y = [0, 1, 0]
  >>> clf = LearningShapelets(random_state=42, tol=0.01)
  >>> clf.fit(X, y)
  LearningShapelets(...)
  >>> clf.coef_.shape
  (1, 6)
class_docstr_tok: ["Learning","Shapelets","algorithm",".","This","estimator","consists","of","two","steps",":","computing","the","distances","between","the","shapelets","and","the","time","series",",","then","computing","a","logistic","regression","using","these","distances","as","features",".","This","algorithm","learns","the","shapelets","as","well","as","the","coefficients","of","the","logistic","regression",".","Parameters","--","--","--","--","--","n_shapelets_per_size",":","int","or","float","(","default","=","0.2",")","Number","of","shapelets","per","size",".","If","float",",","it","represents","a","fraction","of","the","number","of","timestamps","and","the","number","of","shapelets","per","size","is","equal","to","``","ceil","(","n_shapelets_per_size","*","n_timestamps",")","``",".","min_shapelet_length",":","int","or","float","(","default","=","0.1",")","Minimum","length","of","the","shapelets",".","If","float",",","it","represents","a","fraction","of","the","number","of","timestamps","and","the","minimum","length","of","the","shapelets","per","size","is","equal","to","``","ceil","(","min_shapelet_length","*","n_timestamps",")","``",".","shapelet_scale",":","int","(","default","=","3",")","The","different","scales","for","the","lengths","of","the","shapelets",".","The","lengths","of","the","shapelets","are","equal","to","``","min_shapelet_length","*","np.arange","(","1",",","shapelet_scale","+","1",")","``",".","The","total","number","of","shapelets","(","and","features",")","is","equal","to","``","n_shapelets_per_size","*","shapelet_scale","``",".","penalty",":","'l1","'","or","'l2","'","(","default","=","'l2","'",")","Used","to","specify","the","norm","used","in","the","penalization",".","tol",":","float","(","default","=","1e-3",")","Tolerance","for","stopping","criterion",".","C",":","float","(","default","=","1000",")","Inverse","of","regularization","strength",".","It","must","be","a","positive","float",".","Smaller","values","specify","stronger","regularization",".","learning_rate",":","float","(","default","=","1",".",")","Learning","rate","for","gradient","descent","optimization",".","It","must","be","a","positive","float",".","Note","that","the","learning","rate","will","be","automatically","decreased","if","the","loss","function","is","not","decreasing",".","max_iter",":","int","(","default","=","1000",")","Maximum","number","of","iterations","for","gradient","descent","algorithm",".","multi_class",":","{","'multinomial","'",",","'ovr","'",",","'ovo","'","}","(","default","=","'multinomial","'",")","Strategy","for","multiclass","classification",".","'multinomial","'","stands","for","multinomial","cross-entropy","loss",".","'ovr","'","stands","for","one-vs-rest","strategy",".","'ovo","'","stands","for","one-vs-one","strategy",".","Ignored","if","the","classification","task","is","binary",".","alpha",":","float","(","default","=","-100",")","Scaling","term","in","the","softmin","function",".","The","lower",",","the","more","precised","the","soft","minimum","will","be",".","Default","value","should","be","good","for","standardized","time","series",".","fit_intercept",":","bool","(","default","=","True",")","Specifies","if","a","constant","(","a.k.a",".","bias","or","intercept",")","should","be","added","to","the","decision","function",".","intercept_scaling",":","float","(","default","=","1",".",")","Scaling","of","the","intercept",".","Only","used","if","``","fit_intercept=True","``",".","class_weight",":","dict",",","None","or","'balanced","'","(","default","=","None",")","Weights","associated","with","classes","in","the","form","``","{","class_label",":","weight","}","``",".","If","not","given",",","all","classes","are","supposed","to","have","unit","weight",".","The","``","balanced","''","mode","uses","the","values","of","y","to","automatically","adjust","weights","inversely","proportional","to","class","frequencies","in","the","input","data","as","``","n_samples","\/","(","n_classes","*","np.bincount","(","y",")",")","``",".","verbose",":","int","(","default","=","0",")","Controls","the","verbosity",".","It","must","be","a","non-negative","integer",".","If","positive",",","loss","at","each","iteration","is","printed",".","random_state",":","None",",","int","or","RandomState","instance","(","default","=","None",")","The","seed","of","the","pseudo","random","number","generator","to","use","when","shuffling","the","data",".","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","`",".","n_jobs",":","None","or","int","(","default","=","None",")","The","number","of","jobs","to","use","for","the","computation",".","Only","used","if","``","multi_class","``","is","'ovr","'","or","'ovo","'",".","Attributes","--","--","--","--","--","classes_",":","array",",","shape","=","(","n_classes",",",")","An","array","of","class","labels","known","to","the","classifier",".","shapelets_",":","array","shape","=","(","n_tasks",",","n_shapelets",")","Learned","shapelets",".","Each","element","of","this","array","is","a","learned","shapelet",".","coef_",":","array",",","shape","=","(","n_tasks",",","n_shapelets",")","or","(","n_classes",",","n_shapelets",")","Coefficients","for","each","shapelet","in","the","decision","function",".","intercept_",":","array",",","shape","=","(","n_tasks",",",")","or","(","n_classes",",",")","Intercepts","(","a.k.a",".","biases",")","added","to","the","decision","function",".","If","``","fit_intercept=False","``",",","the","intercepts","are","set","to","zero",".","n_iter_",":","array",",","shape","=","(","n_tasks",",",")","Actual","number","of","iterations",".","Notes","--","--","-","The","number","of","tasks","(","n_tasks",")","depends","on","the","value","of","``","multi_class","``","and","the","number","of","classes",".","If","there","are","two","classes",",","the","number","of","tasks","is","equal","to","1",".","If","there","are","more","than","two","classes",",","the","number","of","tasks","is","equal","to",":","-","1","if","``","multi_class='multinomial","'","``","-","n_classes","if","``","multi_class='ovr","'","``","-","n_classes","*","(","n_classes","-","1",")","\/","2","if","``","multi_class='ovo","'","``","References","--","--","--","--","--","..","[","1","]","J.","Grabocka",",","N.","Schilling",",","M.","Wistuba","and","L.","Schmidt-Thieme",",","``","Learning","Time-Series","Shapelets","''",".","International","Conference","on","Data","Mining",",","14",",","392-401","(","2014",")",".","Examples","--","--","--","--",">",">",">","from","pyts.classification","import","LearningShapelets",">",">",">","X","=","[","[","1",",","2",",","2",",","1",",","2",",","3",",","2","]",",","...","[","0",",","2",",","0",",","2",",","0",",","2",",","3","]",",","...","[","0",",","1",",","2",",","2",",","1",",","2",",","2","]","]",">",">",">","y","=","[","0",",","1",",","0","]",">",">",">","clf","=","LearningShapelets","(","random_state=42",",","tol=0.01",")",">",">",">","clf.fit","(","X",",","y",")","LearningShapelets","(","...",")",">",">",">","clf.coef_.shape","(","1",",","6",")"]
docstr: Fit the model according to the given training data.
  
  Parameters
  ----------
  X : array-like, shape = (n_samples, n_timestamps)
      Training vector.
  
  y : array-like, shape = (n_samples,)
      Class labels for each data sample.
  
  sample_weight : None or array-like, shape = (n_samples,) (default = None)
      Array of weights that are assigned to individual samples.
      If not provided, then each sample is given unit weight.
  
  Returns
  -------
  self : object
docstr_tok: ["Fit","the","model","according","to","the","given","training","data",".","Parameters","--","--","--","--","--","X",":","array-like",",","shape","=","(","n_samples",",","n_timestamps",")","Training","vector",".","y",":","array-like",",","shape","=","(","n_samples",",",")","Class","labels","for","each","data","sample",".","sample_weight",":","None","or","array-like",",","shape","=","(","n_samples",",",")","(","default","=","None",")","Array","of","weights","that","are","assigned","to","individual","samples",".","If","not","provided",",","then","each","sample","is","given","unit","weight",".","Returns","--","--","--","-","self",":","object"]
code: def fit(self, X, y, sample_weight=None):
      """Fit the model according to the given training data.
  
      Parameters
      ----------
      X : array-like, shape = (n_samples, n_timestamps)
          Training vector.
  
      y : array-like, shape = (n_samples,)
          Class labels for each data sample.
  
      sample_weight : None or array-like, shape = (n_samples,) (default = None)
          Array of weights that are assigned to individual samples.
          If not provided, then each sample is given unit weight.
  
      Returns
      -------
      self : object
  
      """  # noqa: E501
      X, y = check_X_y(X, y)
      n_classes = len(LabelEncoder().fit(y).classes_)
      multi_class = self._check_params(n_classes)
      params = self.get_params()
      params.pop("n_jobs", None)
      params.pop("multi_class")
      clf = CrossEntropyLearningShapelets(**params)
      if multi_class == "ovr":
          clf = OneVsRestClassifier(clf, n_jobs=self.n_jobs)
      elif multi_class == "ovo":
          clf = OneVsOneClassifier(clf, n_jobs=self.n_jobs)
      clf.fit(X, y)
  
      self.classes_ = clf.classes_
      self._multi_class = multi_class
  
      if multi_class in ("ovr", "ovo"):
          self._estimators = clf.estimators_
          self.shapelets_ = np.array(
              [est.shapelets_ for est in clf.estimators_]
          )
          self.coef_ = np.squeeze(
              np.asarray([est.coef_ for est in clf.estimators_])
          )
          self.intercept_ = np.squeeze(
              np.array([est.intercept_ for est in clf.estimators_])
          )
          self.n_iter_ = np.array(
              [est.n_iter_ for est in clf.estimators_]
          )
      else:
          self._clf = clf
          self.shapelets_ = np.array([clf.shapelets_])
          self.coef_ = clf.coef_
          self.intercept_ = clf.intercept_
          self.n_iter_ = np.array([clf.n_iter_])
      return self
  
imports: from itertools import chain
  from math import ceil
  from numba import njit, prange
  import numpy
  from sklearn.base import BaseEstimator
  from sklearn.cluster import KMeans
  from sklearn.exceptions import ConvergenceWarning
  from sklearn.multiclass import OneVsOneClassifier, OneVsRestClassifier
  from sklearn.multiclass import _ovr_decision_function
  from sklearn.preprocessing import LabelBinarizer, LabelEncoder
  from sklearn.utils import compute_class_weight, check_array
  from sklearn.utils.validation import check_is_fitted, check_random_state, check_X_y, _check_sample_weight
  from sklearn.utils.multiclass import check_classification_targets
  import warnings
  from ..utils.utils import _windowed_view
  from ..base import UnivariateClassifierMixin
label_desc: Use image node_id 2 for calling the LearningShapelets obj's underlying member method code with example usage: obj.fit(X, y, sample_weight) and returns: self