class_docstr: Matrix Profile transformation.
  
  Matrix Profile was originally presented in [1]_.
  
  Parameters
  ----------
  subsequence_length : int (default: 1)
      Length of the subseries (also called window size) to be used for
      subseries distance computations.
  
  implementation : str (default: "numpy")
      Matrix profile implementation to use.
      Defaults to "numpy" to use the pure numpy version.
      All the available implementations are ["numpy", "stump", "gpu_stump"].
  
      "stump" and "gpu_stump" are both implementations from the stumpy
      python library, the latter requiring a GPU.
      Stumpy is a library for efficiently computing the matrix profile which
      is optimized for speed, performance and memory.
      See [2]_ for the documentation.
      "numpy" is the default pure numpy implementation and does not require
      stumpy to be installed.
  
  scale: bool (default: True)
       Whether input data should be scaled for each feature of each time
       series to have zero mean and unit variance.
       Default for this parameter is set to `True` to match the standard
       matrix profile setup.
  
  Examples
  --------
  >>> time_series = [0., 1., 3., 2., 9., 1., 14., 15., 1., 2., 2., 10., 7.]
  >>> ds = [time_series]
  >>> mp = MatrixProfile(subsequence_length=4, scale=False)
  >>> mp.fit_transform(ds)[0, :, 0]  # doctest: +ELLIPSIS
  array([ 6.85...,  1.41...,  6.16...,  7.93..., 11.40...,
         13.56..., 18.  ..., 13.96...,  1.41...,  6.16...])
  
  References
  ----------
  .. [1] C. M. Yeh, Y. Zhu, L. Ulanova, N.Begum et al.
     Matrix Profile I: All Pairs Similarity Joins for Time Series: A
     Unifying View that Includes Motifs, Discords and Shapelets.
     ICDM 2016.
  
  .. [2] STUMPY documentation https://stumpy.readthedocs.io/en/latest/
class_docstr_tok: ["Matrix","Profile","transformation",".","Matrix","Profile","was","originally","presented","in","[","1","]","_.","Parameters","--","--","--","--","--","subsequence_length",":","int","(","default",":","1",")","Length","of","the","subseries","(","also","called","window","size",")","to","be","used","for","subseries","distance","computations",".","implementation",":","str","(","default",":","``","numpy","''",")","Matrix","profile","implementation","to","use",".","Defaults","to","``","numpy","''","to","use","the","pure","numpy","version",".","All","the","available","implementations","are","[","``","numpy","''",",","``","stump","''",",","``","gpu_stump","''","]",".","``","stump","''","and","``","gpu_stump","''","are","both","implementations","from","the","stumpy","python","library",",","the","latter","requiring","a","GPU",".","Stumpy","is","a","library","for","efficiently","computing","the","matrix","profile","which","is","optimized","for","speed",",","performance","and","memory",".","See","[","2","]","_","for","the","documentation",".","``","numpy","''","is","the","default","pure","numpy","implementation","and","does","not","require","stumpy","to","be","installed",".","scale",":","bool","(","default",":","True",")","Whether","input","data","should","be","scaled","for","each","feature","of","each","time","series","to","have","zero","mean","and","unit","variance",".","Default","for","this","parameter","is","set","to","`","True","`","to","match","the","standard","matrix","profile","setup",".","Examples","--","--","--","--",">",">",">","time_series","=","[","0.",",","1.",",","3.",",","2.",",","9.",",","1.",",","14.",",","15.",",","1.",",","2.",",","2.",",","10.",",","7",".","]",">",">",">","ds","=","[","time_series","]",">",">",">","mp","=","MatrixProfile","(","subsequence_length=4",",","scale=False",")",">",">",">","mp.fit_transform","(","ds",")","[","0",",",":",",","0","]","#","doctest",":","+ELLIPSIS","array","(","[","6.85","...",",","1.41","...",",","6.16","...",",","7.93","...",",","11.40","...",",","13.56","...",",","18",".","...",",","13.96","...",",","1.41","...",",","6.16","...","]",")","References","--","--","--","--","--","..","[","1","]","C.","M.","Yeh",",","Y.","Zhu",",","L.","Ulanova",",","N.Begum","et","al",".","Matrix","Profile","I",":","All","Pairs","Similarity","Joins","for","Time","Series",":","A","Unifying","View","that","Includes","Motifs",",","Discords","and","Shapelets",".","ICDM","2016",".","..","[","2","]","STUMPY","documentation","https",":","\/\/stumpy.readthedocs.io\/en\/latest\/"]
code: def _transform(self, X, y=None):
      n_ts, sz, d = X.shape
  
      if d > 1:
          raise NotImplementedError(
              "We currently don't support using "
              "multi-dimensional matrix profiles "
              "from the stumpy library."
          )
  
      output_size = sz - self.subsequence_length + 1
      X_transformed = np.empty((n_ts, output_size, 1))
  
      if self.implementation == "stump":
          if not STUMPY_INSTALLED:
              raise ImportError(stumpy_msg)
  
          for i_ts in range(n_ts):
              result = stumpy.stump(
                  T_A=X[i_ts, :, 0].ravel(), m=self.subsequence_length
              )
              X_transformed[i_ts, :, 0] = result[:, 0].astype(float)
  
      elif self.implementation == "gpu_stump":
          if not STUMPY_INSTALLED:
              raise ImportError(stumpy_msg)
  
          for i_ts in range(n_ts):
              result = stumpy.gpu_stump(
                  T_A=X[i_ts, :, 0].ravel(), m=self.subsequence_length
              )
              X_transformed[i_ts, :, 0] = result[:, 0].astype(float)
  
      elif self.implementation == "numpy":
          scaler = TimeSeriesScalerMeanVariance()
          band_width = int(np.ceil(self.subsequence_length / 4))
          for i_ts in range(n_ts):
              segments = _series_to_segments(
                  X[i_ts], self.subsequence_length
              )
              if self.scale:
                  segments = scaler.fit_transform(segments)
              n_segments = segments.shape[0]
              segments_2d = segments.reshape(
                  (-1, self.subsequence_length * d)
              )
              dists = squareform(pdist(segments_2d, "euclidean"))
              band = np.tri(
                  n_segments, n_segments, band_width, dtype=bool
              ) & ~np.tri(
                  n_segments, n_segments, -(band_width + 1), dtype=bool
              )
              dists[band] = np.inf
              X_transformed[i_ts] = dists.min(axis=1, keepdims=True)
  
      else:
          available_implementations = ["numpy", "stump", "gpu_stump"]
          raise ValueError(
              'This "{}" matrix profile implementation is not'
              " recognized. Available implementations are {}.".format(
                  self.implementation, available_implementations
              )
          )
  
      return X_transformed
  
imports: import numpy
  from numpy.lib.stride_tricks import as_strided
  from scipy.spatial.distance import pdist, squareform
  from sklearn.base import TransformerMixin
  from sklearn.utils.validation import check_array, check_is_fitted
  from tslearn.bases import BaseModelPackage, TimeSeriesBaseEstimator
  from tslearn.preprocessing import TimeSeriesScalerMeanVariance
  from tslearn.utils import check_dims
label_desc: Use image node_id 5 for calling the MatrixProfile obj's underlying member method code with example usage: obj._transform(X, y) and returns: X_transformed