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",">","`","_"]
code: def __init__(self, breakpoints, alpha=0.05, penalizer=0.0):
      super(PiecewiseExponentialRegressionFitter, self).__init__(
          alpha=alpha
      )
  
      breakpoints = np.sort(breakpoints)
      if len(breakpoints) and not (breakpoints[-1] < np.inf):
          raise ValueError("Do not add inf to the breakpoints.")
  
      if len(breakpoints) and breakpoints[0] < 0:
          raise ValueError("First breakpoint must be greater than 0.")
  
      self.breakpoints = breakpoints
      self.n_breakpoints = len(self.breakpoints)
  
      assert isinstance(
          self.penalizer, float
      ), "penalizer must be a float"
      self.penalizer = penalizer
      self._fitted_parameter_names = [
          "lambda_%d_" % i for i in range(self.n_breakpoints + 1)
      ]
  
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 1 to create a new PiecewiseExponentialRegressionFitter object from inherited base classes: ParametricRegressionFitter with example: obj = PiecewiseExponentialRegressionFitter(breakpoints, alpha, penalizer)