class_docstr: This implements a piecewise constant-hazard model at pre-specified break points.
  
  
  .. math::  h(t) = \begin{cases}
                      1/\lambda_0(x)  & \text{if $t \le \tau_0$} \\
                      1/\lambda_1(x) & \text{if $\tau_0 < t \le \tau_1$} \\
                      1/\lambda_2(x) & \text{if $\tau_1 < t \le \tau_2$} \\
                      ...
                    \end{cases}
  
  where :math:`\lambda_i(x) = \exp{\beta_i x}`.
  
  Parameters
  -----------
  breakpoints: list
      a list of times when a new exponential model is constructed.
  penalizer: float
      penalize the variance of the :math:`\lambda_i`. See blog post below.
  alpha: float, optional (default=0.05)
      the level in the confidence intervals.
  
  Examples
  ----------
  See blog post `here <https://dataorigami.net/blogs/napkin-folding/churn>`_ and
  paper replication `here <https://github.com/CamDavidsonPilon/lifelines-replications/blob/master/replications/Friedman_1982.ipynb>`_
class_docstr_tok: ["This","implements","a","piecewise","constant-hazard","model","at","pre-specified","break","points",".","..","math",":",":","h","(","t",")","=","\\begin","{","cases","}","1\/\\lambda_0","(","x",")","&","\\text","{","if","$","t","\\le","\\tau_0","$","}","\\\\","1\/\\lambda_1","(","x",")","&","\\text","{","if","$","\\tau_0","<","t","\\le","\\tau_1","$","}","\\\\","1\/\\lambda_2","(","x",")","&","\\text","{","if","$","\\tau_1","<","t","\\le","\\tau_2","$","}","\\\\","...","\\end","{","cases","}","where",":","math",":","`","\\lambda_i","(","x",")","=","\\exp","{","\\beta_i","x","}","`",".","Parameters","--","--","--","--","--","-","breakpoints",":","list","a","list","of","times","when","a","new","exponential","model","is","constructed",".","penalizer",":","float","penalize","the","variance","of","the",":","math",":","`","\\lambda_i","`",".","See","blog","post","below",".","alpha",":","float",",","optional","(","default=0.05",")","the","level","in","the","confidence","intervals",".","Examples","--","--","--","--","--","See","blog","post","`","here","<","https",":","\/\/dataorigami.net\/blogs\/napkin-folding\/churn",">","`","_","and","paper","replication","`","here","<","https",":","\/\/github.com\/CamDavidsonPilon\/lifelines-replications\/blob\/master\/replications\/Friedman_1982.ipynb",">","`","_"]
docstr: Return the cumulative hazard rate of subjects in X at time points.
  
  Parameters
  ----------
  X: numpy array or DataFrame
      a (n,d) covariate numpy array or DataFrame. If a DataFrame, columns
      can be in any order. If a numpy array, columns must be in the
      same order as the training data.
  times: iterable, optional
      an iterable of increasing times to predict the cumulative hazard at. Default
      is the set of all durations (observed and unobserved). Uses a linear interpolation if
      points in time are not in the index.
  
  Returns
  -------
  cumulative_hazard_ : DataFrame
      the cumulative hazard of individuals over the timeline
docstr_tok: ["Return","the","cumulative","hazard","rate","of","subjects","in","X","at","time","points",".","Parameters","--","--","--","--","--","X",":","numpy","array","or","DataFrame","a","(","n",",","d",")","covariate","numpy","array","or","DataFrame",".","If","a","DataFrame",",","columns","can","be","in","any","order",".","If","a","numpy","array",",","columns","must","be","in","the","same","order","as","the","training","data",".","times",":","iterable",",","optional","an","iterable","of","increasing","times","to","predict","the","cumulative","hazard","at",".","Default","is","the","set","of","all","durations","(","observed","and","unobserved",")",".","Uses","a","linear","interpolation","if","points","in","time","are","not","in","the","index",".","Returns","--","--","--","-","cumulative_hazard_",":","DataFrame","the","cumulative","hazard","of","individuals","over","the","timeline"]
code: def predict_cumulative_hazard(
      self, df, times=None, conditional_after=None
  ) -> pd.DataFrame:
      """
      Return the cumulative hazard rate of subjects in X at time points.
  
      Parameters
      ----------
      X: numpy array or DataFrame
          a (n,d) covariate numpy array or DataFrame. If a DataFrame, columns
          can be in any order. If a numpy array, columns must be in the
          same order as the training data.
      times: iterable, optional
          an iterable of increasing times to predict the cumulative hazard at. Default
          is the set of all durations (observed and unobserved). Uses a linear interpolation if
          points in time are not in the index.
  
      Returns
      -------
      cumulative_hazard_ : DataFrame
          the cumulative hazard of individuals over the timeline
      """
  
      if isinstance(df, pd.Series):
          return self.predict_cumulative_hazard(df.to_frame().T)
  
      if conditional_after is not None:
          raise NotImplementedError()
  
      times = np.atleast_1d(coalesce(times, self.timeline)).astype(
          float
      )
      n = times.shape[0]
      times = times.reshape((n, 1))
  
      lambdas_ = self._prep_inputs_for_prediction_and_return_parameters(
          df
      )
  
      bp = np.append(self.breakpoints, [np.inf])
      M = np.minimum(np.tile(bp, (n, 1)), times)
      M = np.hstack([M[:, tuple([0])], np.diff(M, axis=1)])
  
      return pd.DataFrame(
          np.dot(M, (1 / lambdas_)),
          columns=_get_index(df),
          index=times[:, 0],
      )
  
file_path: lifelines/lifelines/fitters/piecewise_exponential_regression_fitter.py
imports: import autograd.numpy
  import pandas
  from lifelines.utils import coalesce, _get_index, CensoringType
  from lifelines.fitters import ParametricRegressionFitter
  from lifelines.utils.safe_exp import safe_exp
label_desc: Use image node_id 5 for calling the PiecewiseExponentialRegressionFitter obj's underlying member method code with example usage: obj.predict_cumulative_hazard(df, times, conditional_after) and returns: pd, self