class_docstr: Takes a data set with a categorical target variable encoded as a time series and transforms it
  with run length encoding (RLE) of the target variable
  
  RLE finds contiguous runs of the same target value within the input data and derives the
  transformed data set from the amalgum of all contiguous runs of all target classes from all
  series in the input data.
  
  This is useful for generating "pure" series with no mixing of target variables from datasets
  that encode the target variable as a series (e.g. MHEALTH and PAMAP2)
  
  Note that ``seglearn`` can handle datasets with target variables encoded as a series natively
  (using ``SegmentXY``) and so this preprocessing is not required but may be helpful for some tasks.
  Effectively it will let you use ``SegmentX`` on datasets that would otherwise require ``SegmentXY``.
  
  Parameters
  ----------
  min_length : integer > 1
      minimum number of samples in a run for it to be included in the transformed data
class_docstr_tok: ["Takes","a","data","set","with","a","categorical","target","variable","encoded","as","a","time","series","and","transforms","it","with","run","length","encoding","(","RLE",")","of","the","target","variable","RLE","finds","contiguous","runs","of","the","same","target","value","within","the","input","data","and","derives","the","transformed","data","set","from","the","amalgum","of","all","contiguous","runs","of","all","target","classes","from","all","series","in","the","input","data",".","This","is","useful","for","generating","``","pure","''","series","with","no","mixing","of","target","variables","from","datasets","that","encode","the","target","variable","as","a","series","(","e.g",".","MHEALTH","and","PAMAP2",")","Note","that","``","seglearn","``","can","handle","datasets","with","target","variables","encoded","as","a","series","natively","(","using","``","SegmentXY","``",")","and","so","this","preprocessing","is","not","required","but","may","be","helpful","for","some","tasks",".","Effectively","it","will","let","you","use","``","SegmentX","``","on","datasets","that","would","otherwise","require","``","SegmentXY","``",".","Parameters","--","--","--","--","--","min_length",":","integer",">","1","minimum","number","of","samples","in","a","run","for","it","to","be","included","in","the","transformed","data"]
docstr: Transforms the time series data with run length encoding of the target variable
  Note this transformation changes the number of samples in the data
  If sample_weight is provided, it is transformed to align to the new target encoding
  
  
  Parameters
  ----------
  X : array-like, shape [n_series, ...]
     Time series data and (optionally) contextual data
  y : array-like shape [n_series, ...]
      target variable encoded as a time series
  sample_weight : array-like shape [n_series], default = None
      sample weights
  
  Returns
  -------
  Xt : array-like, shape [n_rle_series, ]
      transformed time series data
  yt : array-like, shape [n_rle_series]
      target values for each series
  sample_weight_new : array-like shape [n_rle_series]
      sample weights
docstr_tok: ["Transforms","the","time","series","data","with","run","length","encoding","of","the","target","variable","Note","this","transformation","changes","the","number","of","samples","in","the","data","If","sample_weight","is","provided",",","it","is","transformed","to","align","to","the","new","target","encoding","Parameters","--","--","--","--","--","X",":","array-like",",","shape","[","n_series",",","...","]","Time","series","data","and","(","optionally",")","contextual","data","y",":","array-like","shape","[","n_series",",","...","]","target","variable","encoded","as","a","time","series","sample_weight",":","array-like","shape","[","n_series","]",",","default","=","None","sample","weights","Returns","--","--","--","-","Xt",":","array-like",",","shape","[","n_rle_series",",","]","transformed","time","series","data","yt",":","array-like",",","shape","[","n_rle_series","]","target","values","for","each","series","sample_weight_new",":","array-like","shape","[","n_rle_series","]","sample","weights"]
code: def transform(self, X, y, sample_weight=None):
      """
      Transforms the time series data with run length encoding of the target variable
      Note this transformation changes the number of samples in the data
      If sample_weight is provided, it is transformed to align to the new target encoding
  
  
      Parameters
      ----------
      X : array-like, shape [n_series, ...]
         Time series data and (optionally) contextual data
      y : array-like shape [n_series, ...]
          target variable encoded as a time series
      sample_weight : array-like shape [n_series], default = None
          sample weights
  
      Returns
      -------
      Xt : array-like, shape [n_rle_series, ]
          transformed time series data
      yt : array-like, shape [n_rle_series]
          target values for each series
      sample_weight_new : array-like shape [n_rle_series]
          sample weights
      """
      check_ts_data_with_ts_target(X, y)
  
      Xt, Xc = get_ts_data_parts(X)
      N = len(Xt)  # number of time series
  
      # transformed data
      yt = []
      Xtt = []
      swt = sample_weight
      Nt = []
  
      for i in range(N):
          Xi, yi = self._transform(Xt[i], y[i])
          yt += yi
          Xtt += Xi
          Nt.append(len(yi))  # number of contiguous class instances
  
      if Xc is not None:
          Xct = expand_variables_to_segments(Xc, Nt)
          Xtt = TS_Data(Xtt, Xct)
  
      if sample_weight is not None:
          swt = expand_variables_to_segments(sample_weight, Nt)
  
      return Xtt, yt, swt
  
file_path: seglearn/seglearn/preprocessing.py
imports: import numpy
  from sklearn.base import BaseEstimator
  from .base import TS_Data
  from .util import get_ts_data_parts, check_ts_data_with_ts_target
  from .transform import XyTransformerMixin, expand_variables_to_segments
label_desc: Use image node_id 4 for calling the TargetRunLengthEncoder obj's underlying member method code with example usage: obj.transform(X, y, sample_weight) and returns: Xtt,  yt,  swt