survive.nonparametric.NonparametricEstimator

class survive.nonparametric.NonparametricEstimator[source]

Abstract base class for nonparametric estimators.

Attributes:
conf_level

Confidence level of the confidence intervals.

conf_type

Type of confidence intervals to report.

data_

Survival data used to fit the estimator.

random_state

Seed for this model’s random number generator.

summary

Get a summary of this estimator.

tie_break

How to handle tied event times.

var_type

Type of variance estimate to compute.

Methods

check_fitted() Check whether this model is fitted.
fit(*args, **kwargs) Fit this model to data.
plot(*groups[, ci, ci_style, ci_kwargs, …]) Plot the estimates.
predict(time, *[, return_se, return_ci]) Compute estimates.
to_string([max_line_length]) String representation of this model.
check_fitted()[source]

Check whether this model is fitted. If not, raise an exception.

conf_level

Confidence level of the confidence intervals.

Returns:
conf_level : float

The confidence level.

conf_type

Type of confidence intervals to report.

Returns:
conf_type : str

The type of confidence interval.

data_

Survival data used to fit the estimator.

This property is only available after fitting.

Returns:
data : SurvivalData

The survive.SurvivalData instance used to fit the estimator.

fit(*args, **kwargs)[source]

Fit this model to data.

Returns:
self : Model

The Model being fitted.

plot(*groups, ci=True, ci_style='fill', ci_kwargs=None, mark_censor=True, mark_censor_kwargs=None, legend=True, legend_kwargs=None, colors=None, palette=None, ax=None, **kwargs)[source]

Plot the estimates.

Parameters:
*groups : list of group labels

Specify the groups whose curves should be plotted. If none are given, the curves for all groups are plotted.

ci : bool, optional

If True, draw pointwise confidence intervals.

ci_style : {“fill”, “lines”}, optional

Specify how to draw the confidence intervals. If ci_style is “fill”, the region between the lower and upper confidence interval curves will be filled. If ci_style is “lines”, only the lower and upper curves will be drawn (this is inspired by the style of confidence intervals drawn by plot.survfit in the R package survival).

ci_kwargs : dict, optional

Additional keyword parameters to pass to fill_between() (if ci_style is “fill”) or step() (if ci_style is “lines”) when plotting the pointwise confidence intervals.

mark_censor : bool, optional

If True, indicate the censored times by markers on the plot.

mark_censor_kwargs : dict, optional

Additional keyword parameters to pass to scatter() when marking censored times.

legend : bool, optional

Indicates whether to display a legend for the plot.

legend_kwargs : dict, optional

Keyword parameters to pass to legend().

colors : list or tuple or dict or str, optional

Colors for each group. This is ignored if palette is provided. This can be a sequence of valid matplotlib colors to cycle through, or a dictionary mapping group labels to matplotlib colors, or the name of a matplotlib colormap.

palette : str, optional

Name of a seaborn color palette. Requires seaborn to be installed. Setting a color palette overrides the colors parameter.

ax : matplotlib.axes.Axes, optional

The axes on which to plot. If this is not specified, the current axes will be used.

**kwargs : keyword arguments

Additional keyword arguments to pass to step() when plotting the estimates.

Returns:
matplotlib.axes.Axes

The Axes on which the plot was drawn.

predict(time, *, return_se=False, return_ci=False)[source]

Compute estimates.

Parameters:
time : array-like

One-dimensional array of times at which to make estimates.

return_se : bool, optional

If True, also return standard error estimates.

return_ci : bool, optional

If True, also return confidence intervals.

Returns:
estimate : pandas.DataFrame

DataFrame of estimates. Each columns represents a group, and each row represents an entry of time.

std_err : pandas.DataFrame, optional

Standard errors of the estimates. Same shape as estimate. Returned only if return_se is True.

lower : pandas.DataFrame, optional

Lower confidence interval bounds. Same shape as estimate. Returned only if return_ci is True.

upper : pandas.DataFrame, optional

Upper confidence interval bounds. Same shape as estimate. Returned only if return_ci is True.

random_state

Seed for this model’s random number generator. This may not be an numpy.random.RandomState instance. The internal RNG is not a public attribute and should not be used directly.

Returns:
random_state : object

The seed for this model’s RNG.

summary

Get a summary of this estimator.

Returns:
summary : NonparametricEstimatorSummary

The summary of this estimator.

tie_break

How to handle tied event times.

to_string(max_line_length=75)[source]

String representation of this model.

Parameters:
max_line_length : int, optional

Specifies the maximum length of a line. If None, everything will be on one line.

Returns:
model_string : str

A string representation of this model which should be able to be used to instantiate a new identical model.

var_type

Type of variance estimate to compute.