class_docstr: Transforms longitudinal exposure features to add columns representing
  lagged features.
  
  This preprocessor transform an input list of `n_cases` numpy ndarrays or
  scipy.sparse.csr_matrices of shape `(n_intervals, n_features)` so as to
  add columns representing the lagged exposures. It outputs a list of
  `n_cases` numpy arrays or  csr_matrices of shape
  `(n_intervals, n_features + sum(n_lags + 1))`.
  
  Exposure can take two forms:
  - short repeated exposures: in that case, each column of the numpy arrays
  or csr matrices can contain multiple ones, each one representing an exposure
  for a particular time bucket.
  - infinite unique exposures: in that case, each column of the numpy arrays
  or csr matrices can only contain a single one, corresponding to the starting
  date of the exposure.
  
  Parameters
  ----------
  n_lags : `numpy.ndarray`, shape=(n_features,), dtype="uint64"
      Number of lags to compute: the preprocessor adds columns representing
      lag = 1, ..., n_lags[i] for each feature [i]. If `n_lags` is a null
      vector, this preprocessor does nothing. `n_lags` must be non-negative.
  
  Examples
  --------
  >>> import numpy as np
  >>> from scipy.sparse import csr_matrix
  >>> from tick.preprocessing.longitudinal_features_lagger import LongitudinalFeaturesLagger
  >>> features = [csr_matrix([[0, 1, 0],
  ...                         [0, 0, 0],
  ...                         [0, 0, 1]], dtype="float64"),
  ...             csr_matrix([[1, 1, 0],
  ...                         [0, 0, 1],
  ...                         [0, 0, 0]], dtype="float64")
  ...             ]
  >>> censoring = np.array([3, 2], dtype="uint64")
  >>> n_lags = np.array([2, 1, 0], dtype='uint64')
  >>> lfl = LongitudinalFeaturesLagger(n_lags)
  >>> product_features, _, _ = lfl.fit_transform(features)
  >>> # output comes as a list of sparse matrices or 2D numpy arrays
  >>> product_features.__class__
  <class 'list'>
  >>> [x.toarray() for x in product_features]
  [array([[0., 0., 0., 1., 0., 0.],
         [0., 0., 0., 0., 1., 0.],
         [0., 0., 0., 0., 0., 1.]]), array([[1., 0., 0., 1., 0., 0.],
         [0., 1., 0., 0., 1., 1.],
         [0., 0., 1., 0., 0., 0.]])]
class_docstr_tok: ["Transforms","longitudinal","exposure","features","to","add","columns","representing","lagged","features",".","This","preprocessor","transform","an","input","list","of","`","n_cases","`","numpy","ndarrays","or","scipy.sparse.csr_matrices","of","shape","`","(","n_intervals",",","n_features",")","`","so","as","to","add","columns","representing","the","lagged","exposures",".","It","outputs","a","list","of","`","n_cases","`","numpy","arrays","or","csr_matrices","of","shape","`","(","n_intervals",",","n_features","+","sum","(","n_lags","+","1",")",")","`",".","Exposure","can","take","two","forms",":","-","short","repeated","exposures",":","in","that","case",",","each","column","of","the","numpy","arrays","or","csr","matrices","can","contain","multiple","ones",",","each","one","representing","an","exposure","for","a","particular","time","bucket",".","-","infinite","unique","exposures",":","in","that","case",",","each","column","of","the","numpy","arrays","or","csr","matrices","can","only","contain","a","single","one",",","corresponding","to","the","starting","date","of","the","exposure",".","Parameters","--","--","--","--","--","n_lags",":","`","numpy.ndarray","`",",","shape=","(","n_features",",",")",",","dtype=","''","uint64","''","Number","of","lags","to","compute",":","the","preprocessor","adds","columns","representing","lag","=","1",",","...",",","n_lags","[","i","]","for","each","feature","[","i","]",".","If","`","n_lags","`","is","a","null","vector",",","this","preprocessor","does","nothing",".","`","n_lags","`","must","be","non-negative",".","Examples","--","--","--","--",">",">",">","import","numpy","as","np",">",">",">","from","scipy.sparse","import","csr_matrix",">",">",">","from","tick.preprocessing.longitudinal_features_lagger","import","LongitudinalFeaturesLagger",">",">",">","features","=","[","csr_matrix","(","[","[","0",",","1",",","0","]",",","...","[","0",",","0",",","0","]",",","...","[","0",",","0",",","1","]","]",",","dtype=","''","float64","''",")",",","...","csr_matrix","(","[","[","1",",","1",",","0","]",",","...","[","0",",","0",",","1","]",",","...","[","0",",","0",",","0","]","]",",","dtype=","''","float64","''",")","...","]",">",">",">","censoring","=","np.array","(","[","3",",","2","]",",","dtype=","''","uint64","''",")",">",">",">","n_lags","=","np.array","(","[","2",",","1",",","0","]",",","dtype='uint64","'",")",">",">",">","lfl","=","LongitudinalFeaturesLagger","(","n_lags",")",">",">",">","product_features",",","_",",","_","=","lfl.fit_transform","(","features",")",">",">",">","#","output","comes","as","a","list","of","sparse","matrices","or","2D","numpy","arrays",">",">",">","product_features.__class__","<","class","'list","'",">",">",">",">","[","x.toarray","(",")","for","x","in","product_features","]","[","array","(","[","[","0.",",","0.",",","0.",",","1.",",","0.",",","0",".","]",",","[","0.",",","0.",",","0.",",","0.",",","1.",",","0",".","]",",","[","0.",",","0.",",","0.",",","0.",",","0.",",","1",".","]","]",")",",","array","(","[","[","1.",",","0.",",","0.",",","1.",",","0.",",","0",".","]",",","[","0.",",","1.",",","0.",",","0.",",","1.",",","1",".","]",",","[","0.",",","0.",",","1.",",","0.",",","0.",",","0",".","]","]",")","]"]
docstr: Fit the feature lagger using the features matrices list.
  
  Parameters
  ----------
  features : `list` of `numpy.ndarray` or `list` of `scipy.sparse.csr_matrix`,
      list of length n_cases, each element of the list of
      shape=(n_intervals, n_features)
      The list of features matrices.
  
  censoring : `numpy.ndarray`, shape=(n_cases,), dtype="uint64"
      The censoring data. This array should contain integers in
      [1, n_intervals]. If the value i is equal to n_intervals, then there
      is no censoring for sample i. If censoring = c < n_intervals, then
      the observation of sample i is stopped at interval c, that is, the
      row c - 1 of the corresponding matrix. The last n_intervals - c rows
      are then set to 0.
  
  Returns
  -------
  output : `LongitudinalFeaturesLagger`
      The fitted current instance.
docstr_tok: ["Fit","the","feature","lagger","using","the","features","matrices","list",".","Parameters","--","--","--","--","--","features",":","`","list","`","of","`","numpy.ndarray","`","or","`","list","`","of","`","scipy.sparse.csr_matrix","`",",","list","of","length","n_cases",",","each","element","of","the","list","of","shape=","(","n_intervals",",","n_features",")","The","list","of","features","matrices",".","censoring",":","`","numpy.ndarray","`",",","shape=","(","n_cases",",",")",",","dtype=","''","uint64","''","The","censoring","data",".","This","array","should","contain","integers","in","[","1",",","n_intervals","]",".","If","the","value","i","is","equal","to","n_intervals",",","then","there","is","no","censoring","for","sample","i",".","If","censoring","=","c","<","n_intervals",",","then","the","observation","of","sample","i","is","stopped","at","interval","c",",","that","is",",","the","row","c","-","1","of","the","corresponding","matrix",".","The","last","n_intervals","-","c","rows","are","then","set","to","0",".","Returns","--","--","--","-","output",":","`","LongitudinalFeaturesLagger","`","The","fitted","current","instance","."]
code: def fit(self, features, labels=None, censoring=None):
      """Fit the feature lagger using the features matrices list.
  
      Parameters
      ----------
      features : `list` of `numpy.ndarray` or `list` of `scipy.sparse.csr_matrix`,
          list of length n_cases, each element of the list of
          shape=(n_intervals, n_features)
          The list of features matrices.
  
      censoring : `numpy.ndarray`, shape=(n_cases,), dtype="uint64"
          The censoring data. This array should contain integers in
          [1, n_intervals]. If the value i is equal to n_intervals, then there
          is no censoring for sample i. If censoring = c < n_intervals, then
          the observation of sample i is stopped at interval c, that is, the
          row c - 1 of the corresponding matrix. The last n_intervals - c rows
          are then set to 0.
  
      Returns
      -------
      output : `LongitudinalFeaturesLagger`
          The fitted current instance.
      """
      self._reset()
      base_shape = features[0].shape
      if base_shape[1] != len(self.n_lags):
          raise ValueError(
              "Number of columns from feature matrices differs"
              "from self.n_lags length."
          )
      features = check_longitudinal_features_consistency(
          features, base_shape, "float64"
      )
      n_intervals, n_init_features = base_shape
      self._set("_n_init_features", n_init_features)
      self._set("_n_intervals", n_intervals)
      self._set("_n_output_features", int((self.n_lags + 1).sum()))
      self._set(
          "_cpp_preprocessor",
          _LongitudinalFeaturesLagger(features, self.n_lags),
      )
      self._set("_fitted", True)
  
      return self
  
file_path: tick/tick/preprocessing/longitudinal_features_lagger.py
imports: import numpy
  import scipy.sparse
  from tick.preprocessing.base import LongitudinalPreprocessor
  from .build.preprocessing import LongitudinalFeaturesLagger
  from .utils import check_longitudinal_features_consistency, check_censoring_consistency
label_desc: Use image node_id 3 for calling the LongitudinalFeaturesLagger obj's underlying member method code with example usage: obj.fit(features, labels, censoring) and returns: self