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",".","]","]",")","]"]
code: def __init__(self, n_lags, n_jobs=-1):
      LongitudinalPreprocessor.__init__(self, n_jobs=n_jobs)
      if not isinstance(n_lags, np.ndarray) or n_lags.dtype != "uint64":
          raise ValueError(
              "`n_lags` should be a numpy array of dtype uint64"
          )
      self.n_lags = n_lags
      self._n_init_features = None
      self._n_output_features = None
      self._n_intervals = None
      self._cpp_preprocessor = None
      self._fitted = False
  
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 1 to create a new LongitudinalFeaturesLagger object from inherited base classes: LongitudinalPreprocessor with example: obj = LongitudinalFeaturesLagger(n_lags, n_jobs)