Ejemplo n.º 1
0
 def plot_survival_function(self, **kwargs):
     """Alias of ``plot``"""
     return _plot_estimate(
         self,
         estimate=self.survival_function_,
         confidence_intervals=self.confidence_interval_survival_function_,
         **kwargs)
Ejemplo n.º 2
0
 def plot_hazard(self, bandwidth=None, **kwargs):
     if bandwidth is None:
         raise ValueError(
             "Must specify a bandwidth parameter in the call to plot_hazard, e.g. `plot_hazard(bandwidth=1.0)`"
         )
     estimate = self.smoothed_hazard_(bandwidth)
     confidence_intervals = self.smoothed_hazard_confidence_intervals_(bandwidth, estimate.values[:, 0])
     return _plot_estimate(self, estimate, confidence_intervals=confidence_intervals, **kwargs)
 def plot_survival_function(self, **kwargs):
     """Alias of ``plot``"""
     return _plot_estimate(
         self,
         estimate=self.survival_function_,
         confidence_intervals=self.confidence_interval_survival_function_,
         **kwargs
     )
Ejemplo n.º 4
0
 def plot_survival_function(self, **kwargs):
     set_kwargs_drawstyle(kwargs, "default")
     return _plot_estimate(
         self,
         estimate=getattr(self, "survival_function_"),
         confidence_intervals=self.confidence_interval_survival_function_,
         **kwargs
     )
Ejemplo n.º 5
0
 def plot_survival_function(self, **kwargs):
     """Alias of ``plot``"""
     if not CensoringType.is_interval_censoring(self):
         return _plot_estimate(self, estimate="survival_function_", **kwargs)
     else:
         # hack for now.
         color = coalesce(kwargs.get("c"), kwargs.get("color"), "k")
         self.survival_function_.plot(drawstyle="steps-pre", color=color, **kwargs)
Ejemplo n.º 6
0
    def plot_cumulative_density(self, **kwargs):
        """
        Plots a pretty figure of the cumulative density function.

        Matplotlib plot arguments can be passed in inside the kwargs.

        Parameters
        -----------
        show_censors: bool
            place markers at censorship events. Default: False
        censor_styles: bool
            If show_censors, this dictionary will be passed into the plot call.
        ci_alpha: bool
            the transparency level of the confidence interval. Default: 0.3
        ci_force_lines: bool
            force the confidence intervals to be line plots (versus default shaded areas). Default: False
        ci_show: bool
            show confidence intervals. Default: True
        ci_legend: bool
            if ci_force_lines is True, this is a boolean flag to add the lines' labels to the legend. Default: False
        at_risk_counts: bool
            show group sizes at time points. See function ``add_at_risk_counts`` for details. Default: False
        loc: slice
            specify a time-based subsection of the curves to plot, ex:

            >>> model.plot(loc=slice(0.,10.))

            will plot the time values between t=0. and t=10.
        iloc: slice
            specify a location-based subsection of the curves to plot, ex:

            >>> model.plot(iloc=slice(0,10))

            will plot the first 10 time points.

        Returns
        -------
        ax:
            a pyplot axis object
        """
        if not CensoringType.is_interval_censoring(self):
            return _plot_estimate(self,
                                  estimate="cumulative_density_",
                                  **kwargs)
        else:
            # hack for now.
            color = coalesce(kwargs.get("c"), kwargs.get("color"), "k")
            self.cumulative_density_.plot(drawstyle="steps",
                                          color=color,
                                          **kwargs)
Ejemplo n.º 7
0
    def plot_survival_function(self, **kwargs):
        """Alias of ``plot``"""
        if not CensoringType.is_interval_censoring(self):
            return _plot_estimate(self, estimate="survival_function_", **kwargs)
        else:
            # hack for now.
            def safe_pop(dict, key):
                if key in dict:
                    return dict.pop(key)
                else:
                    return None

            color = coalesce(safe_pop(kwargs, "c"), safe_pop(kwargs, "color"), "k")
            self.survival_function_.plot(drawstyle="steps-pre", color=color, **kwargs)
    def plot_cumulative_density(self, **kwargs):
        """
        Plots a pretty figure of {0}.{1}

        Matplotlib plot arguments can be passed in inside the kwargs, plus

        Parameters
        -----------
        show_censors: bool
            place markers at censorship events. Default: False
        censor_styles: bool
            If show_censors, this dictionary will be passed into the plot call.
        ci_alpha: bool
            the transparency level of the confidence interval. Default: 0.3
        ci_force_lines: bool
            force the confidence intervals to be line plots (versus default shaded areas). Default: False
        ci_show: bool
            show confidence intervals. Default: True
        ci_legend: bool
            if ci_force_lines is True, this is a boolean flag to add the lines' labels to the legend. Default: False
        at_risk_counts: bool
            show group sizes at time points. See function ``add_at_risk_counts`` for details. Default: False
        loc: slice
            specify a time-based subsection of the curves to plot, ex:

            >>> model.plot(loc=slice(0.,10.))

            will plot the time values between t=0. and t=10.
        iloc: slice
            specify a location-based subsection of the curves to plot, ex:

            >>> model.plot(iloc=slice(0,10))

            will plot the first 10 time points.
        invert_y_axis: bool
            boolean to invert the y-axis, useful to show cumulative graphs instead of survival graphs. (Deprecated, use ``plot_cumulative_density()``)

        Returns
        -------
        ax:
            a pyplot axis object
        """
        return _plot_estimate(
            self,
            estimate=self.cumulative_density_,
            confidence_intervals=self.confidence_interval_cumulative_density_,
            **kwargs
        )
Ejemplo n.º 9
0
    def plot_cumulative_density(self, **kwargs):
        """
        Plots a pretty figure of {0}.{1}

        Matplotlib plot arguments can be passed in inside the kwargs, plus

        Parameters
        -----------
        show_censors: bool
            place markers at censorship events. Default: False
        censor_styles: bool
            If show_censors, this dictionary will be passed into the plot call.
        ci_alpha: bool
            the transparency level of the confidence interval. Default: 0.3
        ci_force_lines: bool
            force the confidence intervals to be line plots (versus default shaded areas). Default: False
        ci_show: bool
            show confidence intervals. Default: True
        ci_legend: bool
            if ci_force_lines is True, this is a boolean flag to add the lines' labels to the legend. Default: False
        at_risk_counts: bool
            show group sizes at time points. See function ``add_at_risk_counts`` for details. Default: False
        loc: slice
            specify a time-based subsection of the curves to plot, ex:

            >>> model.plot(loc=slice(0.,10.))

            will plot the time values between t=0. and t=10.
        iloc: slice
            specify a location-based subsection of the curves to plot, ex:

            >>> model.plot(iloc=slice(0,10))

            will plot the first 10 time points.
        invert_y_axis: bool
            boolean to invert the y-axis, useful to show cumulative graphs instead of survival graphs. (Deprecated, use ``plot_cumulative_density()``)

        Returns
        -------
        ax:
            a pyplot axis object
        """
        return _plot_estimate(
            self,
            estimate=self.cumulative_density_,
            confidence_intervals=self.confidence_interval_cumulative_density_,
            **kwargs
        )
Ejemplo n.º 10
0
 def plot_survival_function(self, **kwargs):
     """Alias of ``plot``"""
     return _plot_estimate(self, estimate="survival_function_", **kwargs)
Ejemplo n.º 11
0
 def plot_hazard(self, **kwargs):
     return _plot_estimate(
         self,
         estimate=getattr(self, "hazard_"),
         confidence_intervals=self.confidence_interval_hazard_,
         **kwargs)
Ejemplo n.º 12
0
 def plot_survival_function(self, **kwargs):
     return _plot_estimate(
         self,
         estimate=getattr(self, "survival_function_"),
         confidence_intervals=self.confidence_interval_survival_function_,
         **kwargs)
Ejemplo n.º 13
0
 def plot(self, **kwargs):
     return _plot_estimate(self,
                           estimate=getattr(self, self._estimate_name),
                           confidence_intervals=self.confidence_interval_,
                           **kwargs)
Ejemplo n.º 14
0
 def plot_hazard(self, **kwargs):
     set_kwargs_drawstyle(kwargs, "default")
     return _plot_estimate(
         self, estimate=getattr(self, "hazard_"), confidence_intervals=self.confidence_interval_hazard_, **kwargs
     )
Ejemplo n.º 15
0
 def plot(self, **kwargs):
     set_kwargs_drawstyle(kwargs, "default")
     return _plot_estimate(
         self, estimate=getattr(self, self._estimate_name), confidence_intervals=self.confidence_interval_, **kwargs
     )