class_docstr: Symbolic Aggregate approXimation (SAX) transformer.
  
  as described in
  Jessica Lin, Eamonn Keogh, Li Wei and Stefano Lonardi,
  "Experiencing SAX: a novel symbolic representation of time series"
  Data Mining and Knowledge Discovery, 15(2):107-144
  Overview: for each series:
      run a sliding window across the series
      for each window
          shorten the series with PAA (Piecewise Approximate Aggregation)
          discretise the shortened series into fixed bins
          form a word from these discrete values
  by default SAX produces a single word per series (window_size=0).
  SAX returns a pandas data frame where column 0 is the histogram (sparse
  pd.series)
  of each series.
  
  Parameters
  ----------
  word_length:         int, length of word to shorten window to (using
  PAA) (default 8)
  alphabet_size:       int, number of values to discretise each value
  to (default to 4)
  window_size:         int, size of window for sliding. Input series
  length for whole series transform (default to 12)
  remove_repeat_words: boolean, whether to use numerosity reduction (
  default False)
  save_words:          boolean, whether to use numerosity reduction (
  default False)
  
  return_pandas_data_series:          boolean, default = True
      set to true to return Pandas Series as a result of transform.
      setting to true reduces speed significantly but is required for
      automatic test.
  
  Attributes
  ----------
  words:      history = []
class_docstr_tok: ["Symbolic","Aggregate","approXimation","(","SAX",")","transformer",".","as","described","in","Jessica","Lin",",","Eamonn","Keogh",",","Li","Wei","and","Stefano","Lonardi",",","''","Experiencing","SAX",":","a","novel","symbolic","representation","of","time","series","''","Data","Mining","and","Knowledge","Discovery",",","15","(","2",")",":107-144","Overview",":","for","each","series",":","run","a","sliding","window","across","the","series","for","each","window","shorten","the","series","with","PAA","(","Piecewise","Approximate","Aggregation",")","discretise","the","shortened","series","into","fixed","bins","form","a","word","from","these","discrete","values","by","default","SAX","produces","a","single","word","per","series","(","window_size=0",")",".","SAX","returns","a","pandas","data","frame","where","column","0","is","the","histogram","(","sparse","pd.series",")","of","each","series",".","Parameters","--","--","--","--","--","word_length",":","int",",","length","of","word","to","shorten","window","to","(","using","PAA",")","(","default","8",")","alphabet_size",":","int",",","number","of","values","to","discretise","each","value","to","(","default","to","4",")","window_size",":","int",",","size","of","window","for","sliding",".","Input","series","length","for","whole","series","transform","(","default","to","12",")","remove_repeat_words",":","boolean",",","whether","to","use","numerosity","reduction","(","default","False",")","save_words",":","boolean",",","whether","to","use","numerosity","reduction","(","default","False",")","return_pandas_data_series",":","boolean",",","default","=","True","set","to","true","to","return","Pandas","Series","as","a","result","of","transform",".","setting","to","true","reduces","speed","significantly","but","is","required","for","automatic","test",".","Attributes","--","--","--","--","--","words",":","history","=","[","]"]
docstr: Transform data.
  
  Parameters
  ----------
  X : nested pandas DataFrame of shape [n_instances, 1]
      Nested dataframe with univariate time-series in cells.
  
  Returns
  -------
  dims: Pandas data frame with first dimension in column zero
docstr_tok: ["Transform","data",".","Parameters","--","--","--","--","--","X",":","nested","pandas","DataFrame","of","shape","[","n_instances",",","1","]","Nested","dataframe","with","univariate","time-series","in","cells",".","Returns","--","--","--","-","dims",":","Pandas","data","frame","with","first","dimension","in","column","zero"]
code: def _transform(self, X, y=None):
      """Transform data.
  
      Parameters
      ----------
      X : nested pandas DataFrame of shape [n_instances, 1]
          Nested dataframe with univariate time-series in cells.
  
      Returns
      -------
      dims: Pandas data frame with first dimension in column zero
      """
      X = X.squeeze(1)
  
      if self.alphabet_size < 2 or self.alphabet_size > 4:
          raise RuntimeError(
              "Alphabet size must be an integer between 2 and 4"
          )
      if self.word_length < 1 or self.word_length > 16:
          raise RuntimeError(
              "Word length must be an integer between 1 and 16"
          )
  
      breakpoints = self._generate_breakpoints()
      n_instances, series_length = X.shape
  
      bags = pd.DataFrame()
      dim = []
  
      for i in range(n_instances):
          bag = {}
          lastWord = -1
  
          words = []
  
          num_windows_per_inst = series_length - self.window_size + 1
          split = np.array(
              X[
                  i,
                  np.arange(self.window_size)[None, :]
                  + np.arange(num_windows_per_inst)[:, None],
              ]
          )
  
          split = scipy.stats.zscore(split, axis=1)
  
          paa = PAA(num_intervals=self.word_length)
          data = pd.DataFrame()
          data[0] = [pd.Series(x, dtype=np.float32) for x in split]
          patterns = paa.fit_transform(data)
          patterns = np.asarray([a.values for a in patterns.iloc[:, 0]])
  
          for n in range(patterns.shape[0]):
              pattern = patterns[n, :]
              word = self._create_word(pattern, breakpoints)
              words.append(word)
              lastWord = self._add_to_bag(bag, word, lastWord)
  
          if self.save_words:
              self.words.append(words)
  
          dim.append(
              pd.Series(bag) if self.return_pandas_data_series else bag
          )
  
      bags[0] = dim
  
      return bags
  
file_path: sktime/sktime/transformations/panel/dictionary_based/_sax.py
imports: import sys
  import numpy
  import pandas
  import scipy.stats
  from sktime.transformations.base import BaseTransformer
  from sktime.transformations.panel.dictionary_based import PAA
label_desc: Use image node_id 2 for calling the SAX obj's underlying member method code with example usage: obj._transform(X, y) and returns: bags