- fix for n > 2 groups in
multivariate_logrank_test
(again). - fix bug for when
event_observed
column was not boolean.
- fix for n > 2 groups in
multivariate_logrank_test
- fix weights in KaplanMeierFitter when using a pandas Series.
- Adds
baseline_cumulative_hazard_
andbaseline_survival_
toCoxTimeVaryingFitter
. Because of this, new prediction methods are available. - fixed a bug in
add_covariate_to_timeline
when usingcumulative_sum
with multiple columns. - Added
Likelihood ratio test
toCoxPHFitter.print_summary
andCoxTimeVaryingFitter.print_summary
- New checks in
CoxTimeVaryingFitter
that check for immediate deaths and redundant rows. - New
delay
parameter inadd_covariate_to_timeline
- removed
two_sided_z_test
fromstatistics
- fixes a bug when subtracting or dividing two
UnivariateFitters
with labels. - fixes an import error with using
CoxTimeVaryingFitter
predict methods. - adds a
column
argument toCoxTimeVaryingFitter
andCoxPHFitter
plot
method to plot only a subset of columns.
- some quality of life improvements for working with
CoxTimeVaryingFitter
including newpredict_
methods.
- fixed bug with using weights and strata in
CoxPHFitter
- fixed bug in using non-integer weights in
KaplanMeierFitter
- Performance optimizations in
CoxPHFitter
for up to 40% faster completion offit
.- even smarter
step_size
calculations for iterative optimizations. - simple code optimizations & cleanup in specific hot spots.
- even smarter
- Performance optimizations in
AalenAdditiveFitter
for up to 50% faster completion offit
for large dataframes, and up to 10% faster for small dataframes.
- adding
plot_covariate_groups
toCoxPHFitter
to visualize what happens to survival as we vary a covariate, all else being equal. utils
functions likeqth_survival_times
andmedian_survival_times
now return the transpose of the DataFrame compared to previous version of lifelines. The reason for this is that we often treat survival curves as columns in DataFrames, and functions of the survival curve as index (ex: KaplanMeierFitter.survival_function_ returns a survival curve at time t).KaplanMeierFitter.fit
andNelsonAalenFitter.fit
accept aweights
vector that can be used for pre-aggregated datasets. See this issue.- Convergence errors now return a custom
ConvergenceWarning
instead of aRuntimeWarning
- New checks for complete separation in the dataset for regressions.
- removes
is_significant
andtest_result
fromStatisticalResult
. Users can instead choose their significance level by comparing top_value
. The string representation of this class has changed aswell. CoxPHFitter
andAalenAdditiveFitter
now have ascore_
property that is the concordance-index of the dataset to the fitted model.CoxPHFitter
andAalenAdditiveFitter
no longer have thedata
property. It was an almost duplicate of the training data, but was causing the model to be very large when serialized.- Implements a new fitter
CoxTimeVaryingFitter
available under thelifelines
namespace. This model implements the Cox model for time-varying covariates. - Utils for creating time varying datasets available in
utils
. - less noisy check for complete separation.
- removed
datasets
namespace from the mainlifelines
namespace CoxPHFitter
has a slightly more intelligent (barely...) way to pick a step size, so convergence should generally be faster.CoxPHFitter.fit
now has accepts aweight_col
kwarg so one can pass in weights per observation. This is very useful if you have many subjects, and the space of covariates is not large. Thus you can group the same subjects together and give that observation a weight equal to the count. Altogether, this means a much faster regression.
- removes
include_likelihood
fromCoxPHFitter.fit
- it was not slowing things down much (empirically), and often I wanted it for debugging (I suppose others do too). It's also another exit condition, so we many exit from the NR iterations faster. - added
step_size
param toCoxPHFitter.fit
- the default is good, but for extremely large or small datasets this may want to be set manually. - added a warning to
CoxPHFitter
to check for complete seperation: https://stats.idre.ucla.edu/other/mult-pkg/faq/general/faqwhat-is-complete-or-quasi-complete-separation-in-logisticprobit-regression-and-how-do-we-deal-with-them/ - Additional functionality to
utils.survival_table_from_events
to bin the index to make the resulting table more readable.
- No longer support matplotlib 1.X
- Adding
times
argument toCoxPHFitter
'spredict_survival_function
andpredict_cumulative_hazard
to predict the estimates at, instead uses the default times of observation or censorship. - More accurate prediction methods parametrics univariate models.
- Changing liscense to valilla MIT.
- Speed up
NelsonAalenFitter.fit
considerably.
- Python3 fix for
CoxPHFitter.plot
.
- fixes regression in
KaplanMeierFitter.plot
when using Seaborn and lifelines. - introduce a new
.plot
function to a fittedCoxPHFitter
instance. This plots the hazard coefficients and their confidence intervals. - in all plot methods, the
ix
kwarg has been deprecated in favour of a newloc
kwarg. This is to align with Pandas deprecatingix
- fix in internal normalization for
CoxPHFitter
predict methods.
- corrected bug that was returning the wrong baseline survival and hazard values in
CoxPHFitter
whennormalize=True
. - removed
normalize
kwarg inCoxPHFitter
. This was causing lots of confusion for users, and added code complexity. It's really nice to be able to remove it. - correcting column name in
CoxPHFitter.baseline_survival_
CoxPHFitter.baseline_cumulative_hazard_
is always centered, to mimic R'sbasehaz
API.- new
predict_log_partial_hazards
toCoxPHFitter
- adding
plot_loglogs
toKaplanMeierFitter
- added a (correct) check to see if some columns in a dataset will cause convergence problems.
- removing
flat
argument inplot
methods. It was causing confusion. To replicate it, one can setci_force_lines=True
andshow_censors=True
. - adding
strata
keyword argument toCoxPHFitter
on initialization (ex:CoxPHFitter(strata=['v1', 'v2'])
. Why? Fitters initialized withstrata
can now be passed intok_fold_cross_validation
, plus it makes unit testingstrata
fitters easier. - If using
strata
inCoxPHFitter
, access to strata specific baseline hazards and survival functions are available (previously it was a blended valie). Prediction also uses the specific baseline hazards/survivals. - performance improvements in
CoxPHFitter
- should see at least a 10% speed improvement infit
.
- deprecates Pandas versions before 0.18.
- throw an error if no admissable pairs in the c-index calculation. Previously a NaN was returned.
- add two summary functions to Weibull and Exponential fitter, solves #224
- new prediction function in
CoxPHFitter
,predict_log_hazard_relative_to_mean
, that mimics what R'spredict.coxph
does. - removing the
predict
method in CoxPHFitter and AalenAdditiveFitter. This is because the choice ofpredict_median
as a default was causing too much confusion, and no other natual choice as a default was available. All otherpredict_
methods remain. - Default predict method in
k_fold_cross_validation
is nowpredict_expectation
- supports matplotlib 1.5.
- introduction of a param
nn_cumulative_hazards
in AalenAdditiveModel's__init__
(default True). This parameter will truncate all non-negative cumulative hazards in prediction methods to 0. - bug fixes including:
- fixed issue where the while loop in
_newton_rhaphson
would break too early causing a variable not to be set properly. - scaling of smooth hazards in NelsonAalenFitter was off by a factor of 0.5.
- fixed issue where the while loop in
- reorganized lifelines directories:
- moved test files out of main directory.
- moved
utils.py
into it's own directory. - moved all estimators
fitters
directory.
- added a
at_risk
column to the output ofgroup_survival_table_from_events
andsurvival_table_from_events
- added sample size and power calculations for statistical tests. See
lifeline.statistics. sample_size_necessary_under_cph
andlifelines.statistics. power_under_cph
. - fixed a bug when using KaplanMeierFitter for left-censored data.
- addition of a l2
penalizer
toCoxPHFitter
. - dropped Fortran implementation of efficient Python version. Lifelines is pure python once again!
- addition of
strata
keyword argument toCoxPHFitter
to allow for stratification of a single or set of categorical variables in your dataset. datetimes_to_durations
now accepts a list asna_values
, so multiple values can be checked.- fixed a bug in
datetimes_to_durations
wherefill_date
was not properly being applied. - Changed warning in
datetimes_to_durations
to be correct. - refactor each fitter into it's own submodule. For now, the tests are still in the same file. This will also not break the API.
- allow for multiple fitters to be passed into
k_fold_cross_validation
. - statistical tests in
lifelines.statistics
. now return aStatisticalResult
object with properties likep_value
,test_results
, andsummary
. - fixed a bug in how log-rank statistical tests are performed. The covariance matrix was not being correctly calculated. This resulted in slightly different p-values.
WeibullFitter
,ExponentialFitter
,KaplanMeierFitter
andBreslowFlemingHarringtonFitter
all have aconditional_time_to_event_
property that measures the median duration remaining until the death event, given survival up until time t.
- addition of
median_
property toWeibullFitter
andExponentialFitter
. WeibullFitter
andExponentialFitter
will use integer timelines instead of float provided bylinspace
. This is so if your work is to sum up the survival function (for expected values or something similar), it's more difficult to make a mistake.
- Inclusion of the univariate fitters
WeibullFitter
andExponentialFitter
. - Removing
BayesianFitter
from lifelines. - Added new penalization scheme to AalenAdditiveFitter. You can now add a smoothing penalizer
that will try to keep subsequent values of a hazard curve close together. The penalizing coefficient
is
smoothing_penalizer
. - Changed
penalizer
keyword arg tocoef_penalizer
in AalenAdditiveFitter. - new
ridge_regression
function inutils.py
to perform linear regression with l2 penalizer terms. - Matplotlib is no longer a mandatory dependency.
.predict(time)
method on univariate fitters can now accept a scalar (and returns a scalar) and an iterable (and returns a numpy array)- In
KaplanMeierFitter
,epsilon
has been renamed toprecision
.
- New API for
CoxPHFitter
andAalenAdditiveFitter
: the default arguments forevent_col
andduration_col
.duration_col
is now mandatory, andevent_col
now accepts a column, or by default,None
, which assumes all events are observed (non-censored). - Fix statistical tests.
- Allow negative durations in Fitters.
- New API in
survival_table_from_events
:min_observations
is replaced bybirth_times
(defaultNone
). - New API in
CoxPHFitter
for summary:summary
will return a dataframe with statistics,print_summary()
will print the dataframe (plus some other statistics) in a pretty manner. - Adding "At Risk" counts option to univariate fitter
plot
methods,.plot(at_risk_counts=True)
, and the functionlifelines.plotting.add_at_risk_counts
. - Fix bug Epanechnikov kernel.
- move testing to py.test
- refactor tests into smaller files
- make
test_pairwise_logrank_test_with_identical_data_returns_inconclusive
a better test - add test for summary()
- Alternate metrics can be used for
k_fold_cross_validation
.
- Lots of improvements to numerical stability (but something things still need work)
- Additions to
summary
in CoxPHFitter. - Make all prediction methods output a DataFrame
- Fixes bug in 1-d input not returning in CoxPHFitter
- Lots of new tests.
####0.4.3
- refactoring of
qth_survival_times
: it can now accept an iterable (or a scalar still) of probabilities in the q argument, and will return a DataFrame with these as columns. If len(q)==1 and a single survival function is given, will return a scalar, not a DataFrame. Also some good speed improvements. - KaplanMeierFitter and NelsonAalenFitter now have a
_label
property that is passed in during the fit. - KaplanMeierFitter/NelsonAalenFitter's inital
alpha
value is overwritten if a newalpha
value is passed in during thefit
. - New method for KaplanMeierFitter:
conditional_time_to
. This returns a DataFrame of the estimate: med(S(t | T>s)) - s, human readable: the estimated time left of living, given an individual is aged s. - Adds option
include_likelihood
to CoxPHFitter fit method to save the final log-likelihood value.
####0.4.2
- Massive speed improvements to CoxPHFitter.
- Additional prediction method:
predict_percentile
is available on CoxPHFitter and AalenAdditiveFitter. Given a percentile, p, this function returns the value t such that S(t | x) = p. It is a generalization ofpredict_median
. - Additional kwargs in
k_fold_cross_validation
that will accept different prediction methods (default ispredict_median
). - Bug fix in CoxPHFitter
predict_expectation
function. - Correct spelling mistake in newton-rhapson algorithm.
datasets
now contains functions for generating the respective datasets, ex:generate_waltons_dataset
.- Bumping up the number of samples in statistical tests to prevent them from failing so often (this a stop-gap)
- pep8 everything
####0.4.1.1
- Ability to specify default printing in statsitical tests with the
suppress_print
keyword argument (default False). - For the multivariate log rank test, the inverse step has been replaced with the generalized inverse. This seems to be what other packages use.
- Adding more robust cross validation scheme based on issue #67.
- fixing
regression_dataset
indatasets
.
####0.4.1
CoxFitter
is now known asCoxPHFitter
- refactoring some tests that used redundant data from
lifelines.datasets
. - Adding cross validation: in
utils
is a newk_fold_cross_validation
for model selection in regression problems. - Change CoxPHFitter's fit method's
display_output
toFalse
. - fixing bug in CoxPHFitter's
_compute_baseline_hazard
that errored when sending Series objects tosurvival_table_from_events
. - CoxPHFitter's
fit
now looks to columns with too low variance, and halts NR algorithm if a NaN is found. - Adding a Changelog.
- more sanitizing for the statistical tests =)
####0.4.0
CoxFitter
implements Cox Proportional Hazards model in lifelines.- lifelines moves the wheels distributions.
- tests in the
statistics
module now prints the summary (and still return the regular values) - new
BaseFitter
class is inherited from all fitters.