- some improvements to the output of
check_assumptions.show_plotsis turned toFalseby default now. It only showsrankandkmp-values now. - some performance improvements to
qth_survival_time.
- added new plotting methods to parametric univariate models:
plot_survival_function,plot_hazardandplot_cumulative_hazard. The last one is an alias forplot. - added new properties to parametric univarite models:
confidence_interval_survival_function_,confidence_interval_hazard_,confidence_interval_cumulative_hazard_. The last one is an alias forconfidence_interval_. - Fixed some overflow issues with
AalenJohansenFitter's variance calculations when using large datasets. - Fixed an edgecase in
AalenJohansenFitterthat causing some datasets with to be jittered too often. - Add a new kwarg to
AalenJohansenFitter,calculate_variancethat can be used to turn off variance calculations since this can take a long time for large datasets. Thanks @pzivich!
- fixed confidence intervals in cumulative hazards for parametric univarite models. They were previously serverly depressed.
- adding left-truncation support to parametric univarite models with the
entrykwarg in.fit
- Some performance improvements to parametric univariate models.
- Suppressing some irrelevant NumPy and autograd warnings, so lifeline warnings are more noticeable.
- Improved some warning and error messages.
- New univariate fitter
PiecewiseExponentialFitterfor creating a stepwise hazard model. See docs online. - Ability to create novel parametric univariate models using the new
ParametericUnivariateFittersuper class. See docs online for how to do this. - Unfortunately, parametric univariate fitters are not serializable with
pickle. The librarydillis still useable. - Complete overhaul of all internals for parametric univariate fitters. Moved them all (most) to use
autograd. LogNormalFitterno longer modelslog_sigma.
- bug fixes in
LogNormalFittervariance estimates - improve convergence of
LogNormalFitter. We now model the log of sigma internally, but still expose sigma externally. - use the
autogradlib to help with gradients. - New
LogLogisticFitterunivariate fitter available.
LogNormalFitteris a new univariate fitter you can use.WeibullFitternow correctly returns the confidence intervals (previously returned only NaNs)WeibullFitter.print_summary()displays p-values associated with its parameters not equal to 1.0 - previously this was (implicitly) comparing against 0, which is trivially always true (the parameters must be greater than 0)ExponentialFitter.print_summary()displays p-values associated with its parameters not equal to 1.0 - previously this was (implicitly) comparing against 0, which is trivially always true (the parameters must be greater than 0)ExponentialFitter.plotnow displays the cumulative hazard, instead of the survival function. This is to make it easier to compare toWeibullFitterandLogNormalFitter- Univariate fitters'
cumulative_hazard_at_times,hazard_at_times,survival_function_at_timesreturn pandas Series now (use to be numpy arrays) - remove
alphakeyword from all statistical functions. This was never being used. - Gone are astericks and dots in
print_summaryfunctions that represent signficance thresholds. - In models'
summary(includingprint_summary), thelog(p)term has changed to-log2(p). This is known as the s-value. See https://lesslikely.com/statistics/s-values/ - introduce new statistical tests between univariate datasets:
survival_difference_at_fixed_point_in_time_test,... - new warning message when Cox models detects possible non-unique solutions to maximum likelihood.
- Generally: clean up lifelines exception handling. Ex: catch
LinAlgError: Matrix is singular.and report back to the user advice.
- more bugs in
plot_covariate_groupsfixed when using non-numeric strata.
- Fix bug in
plot_covariate_groupsthat wasn't allowing for strata to be used. - change name of
multicenter_aids_cohort_studytoload_multicenter_aids_cohort_study groupsis now calledvaluesinCoxPHFitter.plot_covariate_groups
- Fix in
compute_residualswhen usingschoenfeldand the minumum duration has only censored subjects.
- Another round of serious performance improvements for the Cox models. Up to 2x faster for CoxPHFitter and CoxTimeVaryingFitter. This was mostly the result of using NumPy's
einsumto simplify a previousforloop. The downside is the code is more esoteric now. I've added comments as necessary though 🤞
- adding bottleneck as a dependency. This library is highly-recommended by Pandas, and in lifelines we see some nice performance improvements with it too. (~15% for
CoxPHFitter) - There was a small bug in
CoxPHFitterwhen usingbatch_modethat was causing coefficients to deviate from their MLE value. This bug eluded tests, which means that it's discrepancy was less than 0.0001 difference. It's fixed now, and even more accurate tests are added. - Faster
CoxPHFitter._compute_likelihood_ratio_test() - Fixes a Pandas performance warning in
CoxTimeVaryingFitter. - Performances improvements to
CoxTimeVaryingFitter.
- corrected behaviour in
CoxPHFitterwherescore_was not being refreshed on every newfit. - Reimplentation of
AalenAdditiveFitter. There were significant changes to it:- implementation is at least 10x faster, and possibly up to 100x faster for some datasets.
- memory consumption is way down
- removed the time-varying component from
AalenAdditiveFitter. This will return in a future release. - new
print_summary weights_colis addednn_cumulative_hazardis removed (may add back)
- some plotting improvemnts to
plotting.plot_lifetimes
- More
CoxPHFitterperformance improvements. Up to a 40% reduction vs 0.16.2 for some datasets.
- Fixed
CoxTimeVaryingFitterto allow more than one variable to be stratafied - Significant performance improvements for
CoxPHFitterwith dataset has lots of duplicate times. See CamDavidsonPilon#591
- Fixed py2 division error in
concordancemethod.
- Drop Python 3.4 support.
- introduction of residual calculations in
CoxPHFitter.compute_residuals. Residuals include "schoenfeld", "score", "delta_beta", "deviance", "martingale", and "scaled_schoenfeld". - removes
estimationnamespace for fitters. Should be usingfrom lifelines import xFitternow. Thanks @usmanatron - removes
predict_log_hazard_relative_to_meanfrom Cox model. Thanks @usmanatron StatisticalResulthas be generalized to allow for multiple results (ex: from pairwise comparisons). This means a slightly changed API that is mostly backwards compatible. See doc string for how to use it.statistics.pairwise_logrank_testnow returns aStatisticalResultobject instead of a nasty NxN DataFrame 💗- Display log(p-values) as well as p-values in
print_summary. Also, p-values below thesholds will be truncated. The orignal p-values are still recoverable using.summary. - Floats
print_summaryis now displayed to 2 decimal points. This can be changed using thedecimalkwarg. - removed
standardizedfromCoxmodel plotting. It was confusing. - visual improvements to Cox models
.plot print_summarymethods accepts kwargs to also be displayed.CoxPHFitterhas a new human-readable method,check_assumptions, to check the assumptions of your Cox proportional hazard model.- A new helper util to "expand" static datasets into long-form:
lifelines.utils.to_episodic_format. CoxTimeVaryingFitternow acceptsstrata.
- bug fix for the Cox model likelihood ratio test when using non-trivial weights.
- Only allow matplotlib less than 3.0.
- API changes to
plotting.plot_lifetimes cluster_colandstratacan be used together inCoxPHFitter- removed
entryfromExponentialFitterandWeibullFitteras it was doing nothing.
- Bug fixes for v0.15.0
- Raise NotImplementedError if the
robustflag is used inCoxTimeVaryingFitter- that's not ready yet.
- adding
robustparams toCoxPHFitter'sfit. This enables atleast i) using non-integer weights in the model (these could be sampling weights like IPTW), and ii) mis-specified models (ex: non-proportional hazards). Under the hood it's a sandwich estimator. This does not handle ties, so if there are high number of ties, results may significantly differ from other software. standard_errors_is now a property on fittedCoxPHFitterwhich describes the standard errors of the coefficients.variance_matrix_is now a property on fittedCoxPHFitterwhich describes the variance matrix of the coefficients.- new criteria for convergence of
CoxPHFitterandCoxTimeVaryingFittercalled the Newton-decrement. Tests show it is as accurate (w.r.t to previous coefficients) and typically shaves off a single step, resulting in generally faster convergence. See https://www.cs.cmu.edu/~pradeepr/convexopt/Lecture_Slides/Newton_methods.pdf. Details about the Newton-decrement are added to theshow_progressstatements. - Minimum suppport for scipy is 1.0
- Convergence errors in models that use Newton-Rhapson methods now throw a
ConvergenceError, instead of aValueError(the former is a subclass of the latter, however). AalenAdditiveModelraisesConvergenceWarninginstead of printing a warning.KaplanMeierFitternow has a cumulative plot option. Examplekmf.plot(invert_y_axis=True)- a
weights_coloption has been added toCoxTimeVaryingFitterthat allows for time-varying weights. WeibullFitterhas a newshow_progressparam and additional information if the convergence fails.CoxPHFitter,ExponentialFitter,WeibullFitterandCoxTimeVaryFittermethodprint_summaryis updated with new fields.WeibullFitterhas renamed the incorrect_jacobianto_hessian_.variance_matrix_is now a property on fittedWeibullFitterwhich describes the variance matrix of the parameters.- The default
WeibullFitter().timelinehas changed from integers between the min and max duration to n floats between the max and min durations, where n is the number of observations. - Performance improvements for
CoxPHFitter(~20% faster) - Performance improvements for
CoxTimeVaryingFitter(~100% faster) - In Python3, Univariate models are now serialisable with
pickle. Thanks @dwilson1988 for the contribution. For Python2,dillis still the preferred method. baseline_cumulative_hazard_(and derivatives of that) onCoxPHFitternow correctly incorporate theweights_col.- Fixed a bug in
KaplanMeierFitterwhen late entry times lined up with death events. Thanks @pzivich - Adding
cluster_colargument toCoxPHFitterso users can specify groups of subjects/rows that may be correlated. - Shifting the "signficance codes" for p-values down an order of magnitude. (Example, p-values between 0.1 and 0.05 are not noted at all and p-values between 0.05 and 0.1 are noted with
., etc.). This deviates with how they are presented in other software. There is an argument to be made to remove p-values from lifelines altogether (become the changes you want to see in the world lol), but I worry that people could compute the p-values by hand incorrectly, a worse outcome I think. So, this is my stance. P-values between 0.1 and 0.05 offer very little information, so they are removed. There is a growing movement in statistics to shift "signficant" findings to p-values less than 0.01 anyways. - New fitter for cumulative incidence of multiple risks
AalenJohansenFitter. Thanks @pzivich! See "Methodologic Issues When Estimating Risks in Pharmacoepidemiology" for a nice overview of the model.
- fix for n > 2 groups in
multivariate_logrank_test(again). - fix bug for when
event_observedcolumn 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_timelinewhen usingcumulative_sumwith multiple columns. - Added
Likelihood ratio testtoCoxPHFitter.print_summaryandCoxTimeVaryingFitter.print_summary - New checks in
CoxTimeVaryingFitterthat check for immediate deaths and redundant rows. - New
delayparameter inadd_covariate_to_timeline - removed
two_sided_z_testfromstatistics
- fixes a bug when subtracting or dividing two
UnivariateFitterswith labels. - fixes an import error with using
CoxTimeVaryingFitterpredict methods. - adds a
columnargument toCoxTimeVaryingFitterandCoxPHFitterplotmethod to plot only a subset of columns.
- some quality of life improvements for working with
CoxTimeVaryingFitterincluding newpredict_methods.
- fixed bug with using weights and strata in
CoxPHFitter - fixed bug in using non-integer weights in
KaplanMeierFitter - Performance optimizations in
CoxPHFitterfor up to 40% faster completion offit.- even smarter
step_sizecalculations for iterative optimizations. - simple code optimizations & cleanup in specific hot spots.
- even smarter
- Performance optimizations in
AalenAdditiveFitterfor up to 50% faster completion offitfor large dataframes, and up to 10% faster for small dataframes.
- adding
plot_covariate_groupstoCoxPHFitterto visualize what happens to survival as we vary a covariate, all else being equal. utilsfunctions likeqth_survival_timesandmedian_survival_timesnow 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.fitandNelsonAalenFitter.fitaccept aweightsvector that can be used for pre-aggregated datasets. See this issue.- Convergence errors now return a custom
ConvergenceWarninginstead of aRuntimeWarning - New checks for complete separation in the dataset for regressions.
- removes
is_significantandtest_resultfromStatisticalResult. Users can instead choose their significance level by comparing top_value. The string representation of this class has changed aswell. CoxPHFitterandAalenAdditiveFitternow have ascore_property that is the concordance-index of the dataset to the fitted model.CoxPHFitterandAalenAdditiveFitterno longer have thedataproperty. It was an almost duplicate of the training data, but was causing the model to be very large when serialized.- Implements a new fitter
CoxTimeVaryingFitteravailable under thelifelinesnamespace. 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
datasetsnamespace from the mainlifelinesnamespace CoxPHFitterhas a slightly more intelligent (barely...) way to pick a step size, so convergence should generally be faster.CoxPHFitter.fitnow has accepts aweight_colkwarg 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_likelihoodfromCoxPHFitter.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_sizeparam toCoxPHFitter.fit- the default is good, but for extremely large or small datasets this may want to be set manually. - added a warning to
CoxPHFitterto 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_eventsto bin the index to make the resulting table more readable.
- No longer support matplotlib 1.X
- Adding
timesargument toCoxPHFitter'spredict_survival_functionandpredict_cumulative_hazardto 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.fitconsiderably.
- Python3 fix for
CoxPHFitter.plot.
- fixes regression in
KaplanMeierFitter.plotwhen using Seaborn and lifelines. - introduce a new
.plotfunction to a fittedCoxPHFitterinstance. This plots the hazard coefficients and their confidence intervals. - in all plot methods, the
ixkwarg has been deprecated in favour of a newlockwarg. This is to align with Pandas deprecatingix
- fix in internal normalization for
CoxPHFitterpredict methods.
- corrected bug that was returning the wrong baseline survival and hazard values in
CoxPHFitterwhennormalize=True. - removed
normalizekwarg 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'sbasehazAPI.- new
predict_log_partial_hazardstoCoxPHFitter
- adding
plot_loglogstoKaplanMeierFitter - added a (correct) check to see if some columns in a dataset will cause convergence problems.
- removing
flatargument inplotmethods. It was causing confusion. To replicate it, one can setci_force_lines=Trueandshow_censors=True. - adding
stratakeyword argument toCoxPHFitteron initialization (ex:CoxPHFitter(strata=['v1', 'v2']). Why? Fitters initialized withstratacan now be passed intok_fold_cross_validation, plus it makes unit testingstratafitters easier. - If using
stratainCoxPHFitter, 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.coxphdoes. - removing the
predictmethod in CoxPHFitter and AalenAdditiveFitter. This is because the choice ofpredict_medianas 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_validationis nowpredict_expectation
- supports matplotlib 1.5.
- introduction of a param
nn_cumulative_hazardsin 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_rhaphsonwould 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.pyinto it's own directory. - moved all estimators
fittersdirectory.
- added a
at_riskcolumn to the output ofgroup_survival_table_from_eventsandsurvival_table_from_events - added sample size and power calculations for statistical tests. See
lifeline.statistics. sample_size_necessary_under_cphandlifelines.statistics. power_under_cph. - fixed a bug when using KaplanMeierFitter for left-censored data.
- addition of a l2
penalizertoCoxPHFitter. - dropped Fortran implementation of efficient Python version. Lifelines is pure python once again!
- addition of
stratakeyword argument toCoxPHFitterto allow for stratification of a single or set of categorical variables in your dataset. datetimes_to_durationsnow accepts a list asna_values, so multiple values can be checked.- fixed a bug in
datetimes_to_durationswherefill_datewas not properly being applied. - Changed warning in
datetimes_to_durationsto 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 aStatisticalResultobject 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,KaplanMeierFitterandBreslowFlemingHarringtonFitterall 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 toWeibullFitterandExponentialFitter. WeibullFitterandExponentialFitterwill 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
WeibullFitterandExponentialFitter. - Removing
BayesianFitterfrom 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
penalizerkeyword arg tocoef_penalizerin AalenAdditiveFitter. - new
ridge_regressionfunction inutils.pyto 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,epsilonhas been renamed toprecision.
- New API for
CoxPHFitterandAalenAdditiveFitter: the default arguments forevent_colandduration_col.duration_colis now mandatory, andevent_colnow 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_observationsis replaced bybirth_times(defaultNone). - New API in
CoxPHFitterfor summary:summarywill 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
plotmethods,.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_inconclusivea 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
summaryin CoxPHFitter. - Make all prediction methods output a DataFrame
- Fixes bug in 1-d input not returning in CoxPHFitter
- Lots of new tests.
- 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
_labelproperty that is passed in during the fit. - KaplanMeierFitter/NelsonAalenFitter's inital
alphavalue is overwritten if a newalphavalue 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_likelihoodto CoxPHFitter fit method to save the final log-likelihood value.
- Massive speed improvements to CoxPHFitter.
- Additional prediction method:
predict_percentileis 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_validationthat will accept different prediction methods (default ispredict_median). - Bug fix in CoxPHFitter
predict_expectationfunction. - Correct spelling mistake in newton-rhapson algorithm.
datasetsnow 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
- Ability to specify default printing in statsitical tests with the
suppress_printkeyword 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_datasetindatasets.
CoxFitteris now known asCoxPHFitter- refactoring some tests that used redundant data from
lifelines.datasets. - Adding cross validation: in
utilsis a newk_fold_cross_validationfor model selection in regression problems. - Change CoxPHFitter's fit method's
display_outputtoFalse. - fixing bug in CoxPHFitter's
_compute_baseline_hazardthat errored when sending Series objects tosurvival_table_from_events. - CoxPHFitter's
fitnow 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 =)
CoxFitterimplements Cox Proportional Hazards model in lifelines.- lifelines moves the wheels distributions.
- tests in the
statisticsmodule now prints the summary (and still return the regular values) - new
BaseFitterclass is inherited from all fitters.