diff --git a/.github/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md index 7bd9eac9d..9a461c54f 100644 --- a/.github/CODE_OF_CONDUCT.md +++ b/.github/CODE_OF_CONDUCT.md @@ -1,5 +1,7 @@ # Contributor Code of Conduct +**If you support or allow fascism, racism, or misogyny: don’t use this code, don’t open issues, don’t ask for help.** + As contributors and maintainers of this project, and in the interest of fostering an open and welcoming community, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 000000000..6175277e3 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,29 @@ +name: CI + +on: [pull_request, push, workflow_dispatch] + +jobs: + test: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: true + matrix: + os: ["ubuntu-latest"] + python-version: ["3.9", "3.10"] + + steps: + - name: Checkout source + uses: actions/checkout@v2 + + - name: Setup python + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + - name: Install + run: | + pip install -e . + pip install -r reqs/dev-requirements.txt + + - name: Run tests + run: pytest lifelines/tests/ -vv diff --git a/CHANGELOG.md b/CHANGELOG.md index 33bba058f..c82f44e17 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ ## Changelog +#### 0.27.1 - 2022-03-15 + +##### New features + - all `fit_` methods now accept a `fit_options` dict that allows one to pass kwargs to the underlying fitting algorithm. + + +##### API Changes + - `step_size` is removed from Cox models `fit`. See `fit_options` above. + +##### Bug fixes + - fixed Cox models when "trival" matrix was passed in (one with no covariates) + #### 0.27.0 - 2022-03-15 Dropping Python3.6 support. diff --git a/README.md b/README.md index 79e0794b1..a1b446eb6 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,6 @@ [![PyPI version](https://badge.fury.io/py/lifelines.svg)](https://badge.fury.io/py/lifelines) [![Anaconda-Server Badge](https://anaconda.org/conda-forge/lifelines/badges/installer/conda.svg)](https://conda.anaconda.org/conda-forge) -[![Build Status](https://travis-ci.org/CamDavidsonPilon/lifelines.svg?branch=master)](https://travis-ci.org/CamDavidsonPilon/lifelines) -[![Coverage Status](https://coveralls.io/repos/github/CamDavidsonPilon/lifelines/badge.svg?branch=master)](https://coveralls.io/github/CamDavidsonPilon/lifelines?branch=master) [![DOI](https://zenodo.org/badge/12420595.svg)](https://zenodo.org/badge/latestdoi/12420595) @@ -28,9 +26,6 @@ If you are new to survival analysis, wondering why it is useful, or are interest - Some users have posted common questions at [stats.stackexchange.com](https://stats.stackexchange.com/search?tab=votes&q=%22lifelines%22%20is%3aquestion) - creating an issue in the [Github repository](https://github.com/camdavidsonpilon/lifelines). -## Roadmap -You can find the roadmap for lifelines [here](https://www.notion.so/camdp/6e2965207f564eb2a3e48b5937873c14?v=47edda47ab774ca2ac7532bb0c750559). - ## Development See our [Contributing](https://github.com/CamDavidsonPilon/lifelines/blob/master/.github/CONTRIBUTING.md) guidelines. diff --git a/docs/Changelog.rst b/docs/Changelog.rst index d28b6f3b8..1a488662c 100644 --- a/docs/Changelog.rst +++ b/docs/Changelog.rst @@ -1,16 +1,43 @@ Changelog ========= +0.27.1 - 2022-03-15 +------------------- + +New features +~~~~~~~~~~~~ + +- all ``fit_`` methods now accept a ``fit_options`` dict that allows + one to pass kwargs to the underlying fitting algorithm. + +API Changes +~~~~~~~~~~~ + +- ``step_size`` is removed from Cox models ``fit``. See ``fit_options`` + above. + +Bug fixes +~~~~~~~~~ + +- fixed Cox models when “trival” matrix was passed in (one with no + covariates) + +.. _section-1: + 0.27.0 - 2022-03-15 ------------------- Dropping Python3.6 support. +.. _bug-fixes-1: + Bug fixes ~~~~~~~~~ - Fix late entry in ``add_at_risk_counts``. +.. _new-features-1: + New features ~~~~~~~~~~~~ @@ -19,6 +46,8 @@ New features - new column in fitter’s ``summary`` that display the number the parameter is being compared against. +.. _api-changes-1: + API Changes ~~~~~~~~~~~ @@ -27,43 +56,43 @@ API Changes “time observed for”. These interpretations are different when there is late entry. -.. _section-1: +.. _section-2: 0.26.4 - 2021-11-30 ------------------- -.. _new-features-1: +.. _new-features-2: New features ~~~~~~~~~~~~ - adding ``weights`` to log rank functions -.. _section-2: +.. _section-3: 0.26.3 - 2021-09-16 ------------------- -.. _bug-fixes-1: +.. _bug-fixes-2: Bug fixes ~~~~~~~~~ - Fix using formulas with ``CoxPHFitter.score`` -.. _section-3: +.. _section-4: 0.26.2 - 2021-09-15 ------------------- Error in v0.26.1 deployment -.. _section-4: +.. _section-5: 0.26.1 - 2021-09-15 ------------------- -.. _api-changes-1: +.. _api-changes-2: API Changes ~~~~~~~~~~~ @@ -73,7 +102,7 @@ API Changes - update ``status`` column in ``lifelines.datasets.load_lung`` to be more standard coding: 0 is censored, 1 is event. -.. _bug-fixes-2: +.. _bug-fixes-3: Bug fixes ~~~~~~~~~ @@ -82,12 +111,12 @@ Bug fixes ``AalenAdditiveFitter.predict_cumulative_hazard`` - Fix using formulas with ``CoxPHFitter.score`` -.. _section-5: +.. _section-6: 0.26.0 - 2021-05-26 ------------------- -.. _new-features-2: +.. _new-features-3: New features ~~~~~~~~~~~~ @@ -102,7 +131,7 @@ New features summary: the API for estimates doesn’t change depending on what your censoring your dataset is. -.. _bug-fixes-3: +.. _bug-fixes-4: Bug fixes ~~~~~~~~~ @@ -114,12 +143,12 @@ Bug fixes - Fixed regression bug when using an array as a penalizer in Cox models. -.. _section-6: +.. _section-7: 0.25.11 - 2021-04-06 -------------------- -.. _bug-fixes-4: +.. _bug-fixes-5: Bug fixes ~~~~~~~~~ @@ -130,12 +159,12 @@ Bug fixes - Bug fix in the elastic-net penalty for Cox models that wasn’t weighting the terms correctly. -.. _section-7: +.. _section-8: 0.25.10 - 2021-03-03 -------------------- -.. _new-features-3: +.. _new-features-4: New features ~~~~~~~~~~~~ @@ -143,14 +172,14 @@ New features - Better appearance when using a single row to show in ``add_at_risk_table``. -.. _section-8: +.. _section-9: 0.25.9 - 2021-02-04 ------------------- Small bump in dependencies. -.. _section-9: +.. _section-10: 0.25.8 - 2021-01-22 ------------------- @@ -159,7 +188,7 @@ Important: we dropped Patsy as our formula framework, and adopted Formulaic. Will the latter is less mature than Patsy, we feel the core capabilities are satisfactory and it provides new opportunities. -.. _new-features-4: +.. _new-features-5: New features ~~~~~~~~~~~~ @@ -168,19 +197,19 @@ New features - a ``_scipy_callback`` function is available to use in fitting algorithms. -.. _section-10: +.. _section-11: 0.25.7 - 2020-12-09 ------------------- -.. _api-changes-2: +.. _api-changes-3: API Changes ~~~~~~~~~~~ - Adding ``cumulative_hazard_at_times`` to NelsonAalenFitter -.. _bug-fixes-5: +.. _bug-fixes-6: Bug fixes ~~~~~~~~~ @@ -190,12 +219,12 @@ Bug fixes - Fixed ``concordance_index_`` when no events observed - Fixed label being overwritten in ParametricUnivariate models -.. _section-11: +.. _section-12: 0.25.6 - 2020-10-26 ------------------- -.. _new-features-5: +.. _new-features-6: New features ~~~~~~~~~~~~ @@ -203,7 +232,7 @@ New features - Parametric Cox models can now handle left and interval censoring datasets. -.. _bug-fixes-6: +.. _bug-fixes-7: Bug fixes ~~~~~~~~~ @@ -215,12 +244,12 @@ Bug fixes - Fix bug in ``KaplanMeierFitter``\ ’s interval censoring where max(lower bound) < min(upper bound). -.. _section-12: +.. _section-13: 0.25.5 - 2020-09-23 ------------------- -.. _api-changes-3: +.. _api-changes-4: API Changes ~~~~~~~~~~~ @@ -228,7 +257,7 @@ API Changes - ``check_assumptions`` now returns a list of list of axes that can be manipulated -.. _bug-fixes-7: +.. _bug-fixes-8: Bug fixes ~~~~~~~~~ @@ -240,12 +269,12 @@ Bug fixes parametric models - ``weights`` wasn’t being applied properly in NPMLE -.. _section-13: +.. _section-14: 0.25.4 - 2020-08-26 ------------------- -.. _new-features-6: +.. _new-features-7: New features ~~~~~~~~~~~~ @@ -255,19 +284,19 @@ New features ``log_likelihood_ratio_test()`` and ``print_summary()`` - Better step-size defaults for Cox model -> more robust convergence. -.. _bug-fixes-8: +.. _bug-fixes-9: Bug fixes ~~~~~~~~~ - fix ``check_assumptions`` when using formulas. -.. _section-14: +.. _section-15: 0.25.3 - 2020-08-24 ------------------- -.. _new-features-7: +.. _new-features-8: New features ~~~~~~~~~~~~ @@ -276,7 +305,7 @@ New features fitters instead of raw data, meaning that you can use this function on left, right or interval censored data. -.. _api-changes-4: +.. _api-changes-5: API Changes ~~~~~~~~~~~ @@ -284,7 +313,7 @@ API Changes - See note on ``survival_difference_at_fixed_point_in_time_test`` above. -.. _bug-fixes-9: +.. _bug-fixes-10: Bug fixes ~~~~~~~~~ @@ -293,19 +322,19 @@ Bug fixes - fix Python error when calling ``plot_covariate_groups`` - fix dtype mismatches in ``plot_partial_effects_on_outcome``. -.. _section-15: +.. _section-16: 0.25.2 - 2020-08-08 ------------------- -.. _new-features-8: +.. _new-features-9: New features ~~~~~~~~~~~~ - Spline ``CoxPHFitter`` can now use ``strata``. -.. _api-changes-5: +.. _api-changes-6: API Changes ~~~~~~~~~~~ @@ -318,7 +347,7 @@ API Changes the author.). So add 2 to ``n_baseline_knots`` to recover the identical model as previously. -.. _bug-fixes-10: +.. _bug-fixes-11: Bug fixes ~~~~~~~~~ @@ -327,12 +356,12 @@ Bug fixes - fix some exception imports I missed. - fix log-likelihood p-value in splines ``CoxPHFitter`` -.. _section-16: +.. _section-17: 0.25.1 - 2020-08-01 ------------------- -.. _bug-fixes-11: +.. _bug-fixes-12: Bug fixes ~~~~~~~~~ @@ -343,12 +372,12 @@ Bug fixes - put ``patsy`` as a proper dependency. - suppress some Pandas 1.1 warnings. -.. _section-17: +.. _section-18: 0.25.0 - 2020-07-27 ------------------- -.. _new-features-9: +.. _new-features-10: New features ~~~~~~~~~~~~ @@ -366,7 +395,7 @@ New features on the terminal. - ``add_at_risk_counts`` now follows the cool new KMunicate suggestions -.. _api-changes-6: +.. _api-changes-7: API Changes ~~~~~~~~~~~ @@ -405,7 +434,7 @@ API Changes `here `__. - all exceptions and warnings have moved to ``lifelines.exceptions`` -.. _bug-fixes-12: +.. _bug-fixes-13: Bug fixes ~~~~~~~~~ @@ -421,12 +450,12 @@ Bug fixes - fixed NaN bug in ``survival_table_from_events`` with intervals when no events would occur in a interval. -.. _section-18: +.. _section-19: 0.24.16 - 2020-07-09 -------------------- -.. _new-features-10: +.. _new-features-11: New features ~~~~~~~~~~~~ @@ -434,19 +463,19 @@ New features - improved algorithm choice for large DataFrames for Cox models. Should see a significant performance boost. -.. _bug-fixes-13: +.. _bug-fixes-14: Bug fixes ~~~~~~~~~ - fixed ``utils.median_survival_time`` not accepting Pandas Series. -.. _section-19: +.. _section-20: 0.24.15 - 2020-07-07 -------------------- -.. _bug-fixes-14: +.. _bug-fixes-15: Bug fixes ~~~~~~~~~ @@ -457,12 +486,12 @@ Bug fixes - fixed bug where using ``conditional_after`` and ``times`` in ``CoxPHFitter("spline")`` prediction methods would be ignored. -.. _section-20: +.. _section-21: 0.24.14 - 2020-07-02 -------------------- -.. _bug-fixes-15: +.. _bug-fixes-16: Bug fixes ~~~~~~~~~ @@ -474,12 +503,12 @@ Bug fixes - fixed a bug where some columns would not be displayed in ``print_summary`` -.. _section-21: +.. _section-22: 0.24.13 - 2020-06-22 -------------------- -.. _bug-fixes-16: +.. _bug-fixes-17: Bug fixes ~~~~~~~~~ @@ -489,24 +518,24 @@ Bug fixes - fixed a bug where ``CoxPHFitter`` would fail with working with ``sklearn_adapter`` -.. _section-22: +.. _section-23: 0.24.12 - 2020-06-20 -------------------- -.. _new-features-11: +.. _new-features-12: New features ~~~~~~~~~~~~ - improved convergence of ``GeneralizedGamma(Regression)Fitter``. -.. _section-23: +.. _section-24: 0.24.11 - 2020-06-17 -------------------- -.. _new-features-12: +.. _new-features-13: New features ~~~~~~~~~~~~ @@ -520,7 +549,7 @@ New features and the integrated calibration index (ICI) for survival models” by P. Austin, F. Harrell, and D. van Klaveren. -.. _api-changes-7: +.. _api-changes-8: API Changes ~~~~~~~~~~~ @@ -529,12 +558,12 @@ API Changes penalized by ``penalizer`` - we now penalizing everything except intercept terms in linear relationships. -.. _section-24: +.. _section-25: 0.24.10 - 2020-06-16 -------------------- -.. _new-features-13: +.. _new-features-14: New features ~~~~~~~~~~~~ @@ -543,7 +572,7 @@ New features offer much better prediction and baseline-hazard estimation, including extrapolation and interpolation. -.. _api-changes-8: +.. _api-changes-9: API Changes ~~~~~~~~~~~ @@ -551,7 +580,7 @@ API Changes - Related to above: the fitted spline parameters are now available in the ``.summary`` and ``.print_summary`` methods. -.. _bug-fixes-17: +.. _bug-fixes-18: Bug fixes ~~~~~~~~~ @@ -559,12 +588,12 @@ Bug fixes - fixed a bug in initialization of some interval-censoring models -> better convergence. -.. _section-25: +.. _section-26: 0.24.9 - 2020-06-05 ------------------- -.. _new-features-14: +.. _new-features-15: New features ~~~~~~~~~~~~ @@ -574,7 +603,7 @@ New features ``tarone-ware``, ``peto``, ``fleming-harrington``. Thanks @sean-reed - new interval censored dataset: ``lifelines.datasets.load_mice`` -.. _bug-fixes-18: +.. _bug-fixes-19: Bug fixes ~~~~~~~~~ @@ -582,12 +611,12 @@ Bug fixes - Cleared up some mislabeling in ``plot_loglogs``. Thanks @sean-reed! - tuples are now able to be used as input in univariate models. -.. _section-26: +.. _section-27: 0.24.8 - 2020-05-17 ------------------- -.. _new-features-15: +.. _new-features-16: New features ~~~~~~~~~~~~ @@ -596,12 +625,12 @@ New features Not all edge cases are fully checked, and some features are missing. Try it under ``KaplanMeierFitter.fit_interval_censoring`` -.. _section-27: +.. _section-28: 0.24.7 - 2020-05-17 ------------------- -.. _new-features-16: +.. _new-features-17: New features ~~~~~~~~~~~~ @@ -617,12 +646,12 @@ New features - some convergence tweaks which should help recent performance regressions. -.. _section-28: +.. _section-29: 0.24.6 - 2020-05-05 ------------------- -.. _new-features-17: +.. _new-features-18: New features ~~~~~~~~~~~~ @@ -632,7 +661,7 @@ New features - New ``lifelines.plotting.plot_interval_censored_lifetimes`` for plotting interval censored data - thanks @sean-reed! -.. _bug-fixes-19: +.. _bug-fixes-20: Bug fixes ~~~~~~~~~ @@ -640,19 +669,19 @@ Bug fixes - fixed bug where ``cdf_plot`` and ``qq_plot`` were not factoring in the weights correctly. -.. _section-29: +.. _section-30: 0.24.5 - 2020-05-01 ------------------- -.. _new-features-18: +.. _new-features-19: New features ~~~~~~~~~~~~ - ``plot_lifetimes`` accepts pandas Series. -.. _bug-fixes-20: +.. _bug-fixes-21: Bug fixes ~~~~~~~~~ @@ -662,12 +691,12 @@ Bug fixes - Improved ``at_risk_counts`` for subplots. - More data validation checks for ``CoxTimeVaryingFitter`` -.. _section-30: +.. _section-31: 0.24.4 - 2020-04-13 ------------------- -.. _bug-fixes-21: +.. _bug-fixes-22: Bug fixes ~~~~~~~~~ @@ -676,12 +705,12 @@ Bug fixes - setting a dataframe in ``ancillary_df`` works for interval censoring - ``.score`` works for interval censored models -.. _section-31: +.. _section-32: 0.24.3 - 2020-03-25 ------------------- -.. _new-features-19: +.. _new-features-20: New features ~~~~~~~~~~~~ @@ -691,7 +720,7 @@ New features the hazard ratio would be at previous times. This is useful because the final hazard ratio is some weighted average of these. -.. _bug-fixes-22: +.. _bug-fixes-23: Bug fixes ~~~~~~~~~ @@ -699,12 +728,12 @@ Bug fixes - Fixed error in HTML printer that was hiding concordance index information. -.. _section-32: +.. _section-33: 0.24.2 - 2020-03-15 ------------------- -.. _bug-fixes-23: +.. _bug-fixes-24: Bug fixes ~~~~~~~~~ @@ -716,12 +745,12 @@ Bug fixes - Fixed a keyword bug in ``plot_covariate_groups`` for parametric models. -.. _section-33: +.. _section-34: 0.24.1 - 2020-03-05 ------------------- -.. _new-features-20: +.. _new-features-21: New features ~~~~~~~~~~~~ @@ -729,14 +758,14 @@ New features - Stability improvements for GeneralizedGammaRegressionFitter and CoxPHFitter with spline estimation. -.. _bug-fixes-24: +.. _bug-fixes-25: Bug fixes ~~~~~~~~~ - Fixed bug with plotting hazards in NelsonAalenFitter. -.. _section-34: +.. _section-35: 0.24.0 - 2020-02-20 ------------------- @@ -745,7 +774,7 @@ This version and future versions of lifelines no longer support py35. Pandas 1.0 is fully supported, along with previous versions. Minimum Scipy has been bumped to 1.2.0. -.. _new-features-21: +.. _new-features-22: New features ~~~~~~~~~~~~ @@ -769,7 +798,7 @@ New features - new ``lifelines.fitters.mixins.ProportionalHazardMixin`` that implements proportional hazard checks. -.. _api-changes-9: +.. _api-changes-10: API Changes ~~~~~~~~~~~ @@ -797,7 +826,7 @@ API Changes to ``scoring_method``. - removed ``_score_`` and ``path`` from Cox model. -.. _bug-fixes-25: +.. _bug-fixes-26: Bug fixes ~~~~~~~~~ @@ -810,12 +839,12 @@ Bug fixes - Cox models now incorporate any penalizers in their ``log_likelihood_`` -.. _section-35: +.. _section-36: 0.23.9 - 2020-01-28 ------------------- -.. _bug-fixes-26: +.. _bug-fixes-27: Bug fixes ~~~~~~~~~ @@ -826,12 +855,12 @@ Bug fixes of ``GeneralizedGammaRegressionFitter`` and any custom regression models should update their code as soon as possible. -.. _section-36: +.. _section-37: 0.23.8 - 2020-01-21 ------------------- -.. _bug-fixes-27: +.. _bug-fixes-28: Bug fixes ~~~~~~~~~ @@ -842,19 +871,19 @@ Bug fixes ``GeneralizedGammaRegressionFitter`` and any custom regression models should update their code as soon as possible. -.. _section-37: +.. _section-38: 0.23.7 - 2020-01-14 ------------------- Bug fixes for py3.5. -.. _section-38: +.. _section-39: 0.23.6 - 2020-01-07 ------------------- -.. _new-features-22: +.. _new-features-23: New features ~~~~~~~~~~~~ @@ -868,12 +897,12 @@ New features - custom parametric regression models can now do left and interval censoring. -.. _section-39: +.. _section-40: 0.23.5 - 2020-01-05 ------------------- -.. _new-features-23: +.. _new-features-24: New features ~~~~~~~~~~~~ @@ -882,7 +911,7 @@ New features - New lymph node cancer dataset, originally from *H.F. for the German Breast Cancer Study Group (GBSG) (1994)* -.. _bug-fixes-28: +.. _bug-fixes-29: Bug fixes ~~~~~~~~~ @@ -892,26 +921,26 @@ Bug fixes - fixed bug where large exponential numbers in ``print_summary`` were not being suppressed correctly. -.. _section-40: +.. _section-41: 0.23.4 - 2019-12-15 ------------------- - Bug fix for PyPI -.. _section-41: +.. _section-42: 0.23.3 - 2019-12-11 ------------------- -.. _new-features-24: +.. _new-features-25: New features ~~~~~~~~~~~~ - ``StatisticalResult.print_summary`` supports html output. -.. _bug-fixes-29: +.. _bug-fixes-30: Bug fixes ~~~~~~~~~ @@ -919,12 +948,12 @@ Bug fixes - fix import in ``printer.py`` - fix html printing with Univariate models. -.. _section-42: +.. _section-43: 0.23.2 - 2019-12-07 ------------------- -.. _new-features-25: +.. _new-features-26: New features ~~~~~~~~~~~~ @@ -936,7 +965,7 @@ New features - performance improvements on regression models’ preprocessing. Should make datasets with high number of columns more performant. -.. _bug-fixes-30: +.. _bug-fixes-31: Bug fixes ~~~~~~~~~ @@ -945,12 +974,12 @@ Bug fixes - fixed repr for ``sklearn_adapter`` classes. - fixed ``conditional_after`` in Cox model with strata was used. -.. _section-43: +.. _section-44: 0.23.1 - 2019-11-27 ------------------- -.. _new-features-26: +.. _new-features-27: New features ~~~~~~~~~~~~ @@ -960,7 +989,7 @@ New features - performance improvements for ``CoxPHFitter`` - up to 30% performance improvements for some datasets. -.. _bug-fixes-31: +.. _bug-fixes-32: Bug fixes ~~~~~~~~~ @@ -972,12 +1001,12 @@ Bug fixes - fixed bug when using ``print_summary`` with left censored models. - lots of minor bug fixes. -.. _section-44: +.. _section-45: 0.23.0 - 2019-11-17 ------------------- -.. _new-features-27: +.. _new-features-28: New features ~~~~~~~~~~~~ @@ -986,7 +1015,7 @@ New features Jupyter notebooks! - silenced some warnings. -.. _bug-fixes-32: +.. _bug-fixes-33: Bug fixes ~~~~~~~~~ @@ -996,7 +1025,7 @@ Bug fixes now fixed. - fixed a NaN error in confidence intervals for KaplanMeierFitter -.. _api-changes-10: +.. _api-changes-11: API Changes ~~~~~~~~~~~ @@ -1008,7 +1037,7 @@ API Changes - ``left_censorship`` in ``fit`` has been removed in favour of ``fit_left_censoring``. -.. _section-45: +.. _section-46: 0.22.10 - 2019-11-08 -------------------- @@ -1016,7 +1045,7 @@ API Changes The tests were re-factored to be shipped with the package. Let me know if this causes problems. -.. _bug-fixes-33: +.. _bug-fixes-34: Bug fixes ~~~~~~~~~ @@ -1026,12 +1055,12 @@ Bug fixes - fixed bug in plot_covariate_groups for AFT models when >1d arrays were used for values arg. -.. _section-46: +.. _section-47: 0.22.9 - 2019-10-30 ------------------- -.. _bug-fixes-34: +.. _bug-fixes-35: Bug fixes ~~~~~~~~~ @@ -1043,12 +1072,12 @@ Bug fixes - ``CoxPHFitter`` now displays correct columns values when changing alpha param. -.. _section-47: +.. _section-48: 0.22.8 - 2019-10-06 ------------------- -.. _new-features-28: +.. _new-features-29: New features ~~~~~~~~~~~~ @@ -1058,19 +1087,19 @@ New features - ``conditional_after`` now available in ``CoxPHFitter.predict_median`` - Suppressed some unimportant warnings. -.. _bug-fixes-35: +.. _bug-fixes-36: Bug fixes ~~~~~~~~~ - fixed initial_point being ignored in AFT models. -.. _section-48: +.. _section-49: 0.22.7 - 2019-09-29 ------------------- -.. _new-features-29: +.. _new-features-30: New features ~~~~~~~~~~~~ @@ -1078,7 +1107,7 @@ New features - new ``ApproximationWarning`` to tell you if the package is making an potentially mislead approximation. -.. _bug-fixes-36: +.. _bug-fixes-37: Bug fixes ~~~~~~~~~ @@ -1087,7 +1116,7 @@ Bug fixes - realigned values in ``print_summary``. - fixed bug in ``survival_difference_at_fixed_point_in_time_test`` -.. _api-changes-11: +.. _api-changes-12: API Changes ~~~~~~~~~~~ @@ -1097,24 +1126,24 @@ API Changes - Some previous ``StatisticalWarnings`` have been replaced by ``ApproximationWarning`` -.. _section-49: +.. _section-50: 0.22.6 - 2019-09-25 ------------------- -.. _new-features-30: +.. _new-features-31: New features ~~~~~~~~~~~~ - ``conditional_after`` works for ``CoxPHFitter`` prediction models 😅 -.. _bug-fixes-37: +.. _bug-fixes-38: Bug fixes ~~~~~~~~~ -.. _api-changes-12: +.. _api-changes-13: API Changes ~~~~~~~~~~~ @@ -1125,12 +1154,12 @@ API Changes - ``utils.dataframe_interpolate_at_times`` renamed to ``utils.interpolate_at_times_and_return_pandas``. -.. _section-50: +.. _section-51: 0.22.5 - 2019-09-20 ------------------- -.. _new-features-31: +.. _new-features-32: New features ~~~~~~~~~~~~ @@ -1139,7 +1168,7 @@ New features weights. - Better support for predicting on Pandas Series -.. _bug-fixes-38: +.. _bug-fixes-39: Bug fixes ~~~~~~~~~ @@ -1148,7 +1177,7 @@ Bug fixes - Fixed an issue with ``AalenJohansenFitter`` failing to plot confidence intervals. -.. _api-changes-13: +.. _api-changes-14: API Changes ~~~~~~~~~~~ @@ -1156,12 +1185,12 @@ API Changes - ``_get_initial_value`` in parametric univariate models is renamed ``_create_initial_point`` -.. _section-51: +.. _section-52: 0.22.4 - 2019-09-04 ------------------- -.. _new-features-32: +.. _new-features-33: New features ~~~~~~~~~~~~ @@ -1172,7 +1201,7 @@ New features - new ``utils.restricted_mean_survival_time`` that approximates the RMST using numerical integration against survival functions. -.. _api-changes-14: +.. _api-changes-15: API changes ~~~~~~~~~~~ @@ -1180,7 +1209,7 @@ API changes - ``KaplanMeierFitter.survival_function_``\ ‘s’ index is no longer given the name “timeline”. -.. _bug-fixes-39: +.. _bug-fixes-40: Bug fixes ~~~~~~~~~ @@ -1188,12 +1217,12 @@ Bug fixes - Fixed issue where ``concordance_index`` would never exit if NaNs in dataset. -.. _section-52: +.. _section-53: 0.22.3 - 2019-08-08 ------------------- -.. _new-features-33: +.. _new-features-34: New features ~~~~~~~~~~~~ @@ -1206,7 +1235,7 @@ New features - smarter initial conditions for parametric regression models. - New regression model: ``GeneralizedGammaRegressionFitter`` -.. _api-changes-15: +.. _api-changes-16: API changes ~~~~~~~~~~~ @@ -1217,7 +1246,7 @@ API changes gains only in Cox models, and only a small fraction of the API was being used. -.. _bug-fixes-40: +.. _bug-fixes-41: Bug fixes ~~~~~~~~~ @@ -1229,19 +1258,19 @@ Bug fixes - Fixed an error in the ``predict_percentile`` of ``LogLogisticAFTFitter``. New tests have been added around this. -.. _section-53: +.. _section-54: 0.22.2 - 2019-07-25 ------------------- -.. _new-features-34: +.. _new-features-35: New features ~~~~~~~~~~~~ - lifelines is now compatible with scipy>=1.3.0 -.. _bug-fixes-41: +.. _bug-fixes-42: Bug fixes ~~~~~~~~~ @@ -1252,12 +1281,12 @@ Bug fixes errors when using the library. The correctly numpy has been pinned (to 1.14.0+) -.. _section-54: +.. _section-55: 0.22.1 - 2019-07-14 ------------------- -.. _new-features-35: +.. _new-features-36: New features ~~~~~~~~~~~~ @@ -1272,7 +1301,7 @@ New features right censoring) - improvements to ``lifelines.utils.gamma`` -.. _api-changes-16: +.. _api-changes-17: API changes ~~~~~~~~~~~ @@ -1285,7 +1314,7 @@ API changes ``.print_summary`` includes confidence intervals for the exponential of the value. -.. _bug-fixes-42: +.. _bug-fixes-43: Bug fixes ~~~~~~~~~ @@ -1295,12 +1324,12 @@ Bug fixes - fixed an overflow bug in ``KaplanMeierFitter`` confidence intervals - improvements in data validation for ``CoxTimeVaryingFitter`` -.. _section-55: +.. _section-56: 0.22.0 - 2019-07-03 ------------------- -.. _new-features-36: +.. _new-features-37: New features ~~~~~~~~~~~~ @@ -1312,7 +1341,7 @@ New features - for parametric univariate models, the ``conditional_time_to_event_`` is now exact instead of an approximation. -.. _api-changes-17: +.. _api-changes-18: API changes ~~~~~~~~~~~ @@ -1334,7 +1363,7 @@ API changes could set ``fit_intercept`` to False and not have to set ``ancillary_df`` - now one must specify a DataFrame. -.. _bug-fixes-43: +.. _bug-fixes-44: Bug fixes ~~~~~~~~~ @@ -1343,21 +1372,21 @@ Bug fixes is now exact instead of an approximation. - fixed a name error bug in ``CoxTimeVaryingFitter.plot`` -.. _section-56: +.. _section-57: 0.21.5 - 2019-06-22 ------------------- I’m skipping 0.21.4 version because of deployment issues. -.. _new-features-37: +.. _new-features-38: New features ~~~~~~~~~~~~ - ``scoring_method`` now a kwarg on ``sklearn_adapter`` -.. _bug-fixes-44: +.. _bug-fixes-45: Bug fixes ~~~~~~~~~ @@ -1367,12 +1396,12 @@ Bug fixes - fixed visual bug that misaligned x-axis ticks and at-risk counts. Thanks @christopherahern! -.. _section-57: +.. _section-58: 0.21.3 - 2019-06-04 ------------------- -.. _new-features-38: +.. _new-features-39: New features ~~~~~~~~~~~~ @@ -1386,19 +1415,19 @@ New features - ``CoxPHFitter.check_assumptions`` now accepts a ``columns`` parameter to specify only checking a subset of columns. -.. _bug-fixes-45: +.. _bug-fixes-46: Bug fixes ~~~~~~~~~ - ``covariates_from_event_matrix`` handle nulls better -.. _section-58: +.. _section-59: 0.21.2 - 2019-05-16 ------------------- -.. _new-features-39: +.. _new-features-40: New features ~~~~~~~~~~~~ @@ -1410,7 +1439,7 @@ New features that computes, you guessed it, the log-likelihood ratio test. Previously this was an internal API that is being exposed. -.. _api-changes-18: +.. _api-changes-19: API changes ~~~~~~~~~~~ @@ -1422,17 +1451,17 @@ API changes - removing ``_compute_likelihood_ratio_test`` on regression models. Use ``log_likelihood_ratio_test`` now. -.. _bug-fixes-46: +.. _bug-fixes-47: Bug fixes ~~~~~~~~~ -.. _section-59: +.. _section-60: 0.21.1 - 2019-04-26 ------------------- -.. _new-features-40: +.. _new-features-41: New features ~~~~~~~~~~~~ @@ -1441,7 +1470,7 @@ New features ``add_covariate_to_timeline`` - PiecewiseExponentialFitter now allows numpy arrays as breakpoints -.. _api-changes-19: +.. _api-changes-20: API changes ~~~~~~~~~~~ @@ -1449,19 +1478,19 @@ API changes - output of ``survival_table_from_events`` when collapsing rows to intervals now removes the “aggregate” column multi-index. -.. _bug-fixes-47: +.. _bug-fixes-48: Bug fixes ~~~~~~~~~ - fixed bug in CoxTimeVaryingFitter when ax is provided, thanks @j-i-l! -.. _section-60: +.. _section-61: 0.21.0 - 2019-04-12 ------------------- -.. _new-features-41: +.. _new-features-42: New features ~~~~~~~~~~~~ @@ -1475,7 +1504,7 @@ New features - a new interval censored dataset is available under ``lifelines.datasets.load_diabetes`` -.. _api-changes-20: +.. _api-changes-21: API changes ~~~~~~~~~~~ @@ -1486,7 +1515,7 @@ API changes - ``entries`` property in multivariate parametric models has a new Series name: ``entry`` -.. _bug-fixes-48: +.. _bug-fixes-49: Bug fixes ~~~~~~~~~ @@ -1496,19 +1525,19 @@ Bug fixes - Fixed an error that didn’t let users use Numpy arrays in prediction for AFT models -.. _section-61: +.. _section-62: 0.20.5 - 2019-04-08 ------------------- -.. _new-features-42: +.. _new-features-43: New features ~~~~~~~~~~~~ - performance improvements for ``print_summary``. -.. _api-changes-21: +.. _api-changes-22: API changes ~~~~~~~~~~~ @@ -1518,7 +1547,7 @@ API changes - in ``AalenJohansenFitter``, the ``variance`` parameter is renamed to ``variance_`` to align with the usual lifelines convention. -.. _bug-fixes-49: +.. _bug-fixes-50: Bug fixes ~~~~~~~~~ @@ -1527,12 +1556,12 @@ Bug fixes test when using strata. - Fixed some plotting bugs with ``AalenJohansenFitter`` -.. _section-62: +.. _section-63: 0.20.4 - 2019-03-27 ------------------- -.. _new-features-43: +.. _new-features-44: New features ~~~~~~~~~~~~ @@ -1543,7 +1572,7 @@ New features generating piecewise exp. data - Faster ``print_summary`` for AFT models. -.. _api-changes-22: +.. _api-changes-23: API changes ~~~~~~~~~~~ @@ -1551,7 +1580,7 @@ API changes - Pandas is now correctly pinned to >= 0.23.0. This was always the case, but not specified in setup.py correctly. -.. _bug-fixes-50: +.. _bug-fixes-51: Bug fixes ~~~~~~~~~ @@ -1560,12 +1589,12 @@ Bug fixes - ``PiecewiseExponentialFitter`` is available with ``from lifelines import *``. -.. _section-63: +.. _section-64: 0.20.3 - 2019-03-23 ------------------- -.. _new-features-44: +.. _new-features-45: New features ~~~~~~~~~~~~ @@ -1578,12 +1607,12 @@ New features ``plot_survival_function`` and ``confidence_interval_survival_function_``. -.. _section-64: +.. _section-65: 0.20.2 - 2019-03-21 ------------------- -.. _new-features-45: +.. _new-features-46: New features ~~~~~~~~~~~~ @@ -1598,7 +1627,7 @@ New features - add a ``lifelines.plotting.qq_plot`` for univariate parametric models that handles censored data. -.. _api-changes-23: +.. _api-changes-24: API changes ~~~~~~~~~~~ @@ -1607,7 +1636,7 @@ API changes @vpolimenov! - The ``C`` column in ``load_lcd`` dataset is renamed to ``E``. -.. _bug-fixes-51: +.. _bug-fixes-52: Bug fixes ~~~~~~~~~ @@ -1623,7 +1652,7 @@ Bug fixes the q parameter was below the truncation limit. This should have been ``-np.inf`` -.. _section-65: +.. _section-66: 0.20.1 - 2019-03-16 ------------------- @@ -1637,7 +1666,7 @@ Bug fixes decades of development. - suppressed unimportant warnings -.. _api-changes-24: +.. _api-changes-25: API changes ~~~~~~~~~~~ @@ -1647,7 +1676,7 @@ API changes This is no longer the case. A 0 will still be added if there is a duration (observed or not) at 0 occurs however. -.. _section-66: +.. _section-67: 0.20.0 - 2019-03-05 ------------------- @@ -1656,7 +1685,7 @@ API changes recent installs where Py3. - Updated minimum dependencies, specifically Matplotlib and Pandas. -.. _new-features-46: +.. _new-features-47: New features ~~~~~~~~~~~~ @@ -1664,7 +1693,7 @@ New features - smarter initialization for AFT models which should improve convergence. -.. _api-changes-25: +.. _api-changes-26: API changes ~~~~~~~~~~~ @@ -1676,19 +1705,19 @@ API changes transposed now (previous parameters where columns, now parameters are rows). -.. _bug-fixes-52: +.. _bug-fixes-53: Bug fixes ~~~~~~~~~ - Fixed a bug with plotting and ``check_assumptions``. -.. _section-67: +.. _section-68: 0.19.5 - 2019-02-26 ------------------- -.. _new-features-47: +.. _new-features-48: New features ~~~~~~~~~~~~ @@ -1698,24 +1727,24 @@ New features features or categorical variables. - Convergence improvements for AFT models. -.. _section-68: +.. _section-69: 0.19.4 - 2019-02-25 ------------------- -.. _bug-fixes-53: +.. _bug-fixes-54: Bug fixes ~~~~~~~~~ - remove some bad print statements in ``CoxPHFitter``. -.. _section-69: +.. _section-70: 0.19.3 - 2019-02-25 ------------------- -.. _new-features-48: +.. _new-features-49: New features ~~~~~~~~~~~~ @@ -1727,12 +1756,12 @@ New features - Performance increase to ``print_summary`` in the ``CoxPHFitter`` and ``CoxTimeVaryingFitter`` model. -.. _section-70: +.. _section-71: 0.19.2 - 2019-02-22 ------------------- -.. _new-features-49: +.. _new-features-50: New features ~~~~~~~~~~~~ @@ -1740,7 +1769,7 @@ New features - ``ParametricUnivariateFitters``, like ``WeibullFitter``, have smoothed plots when plotting (vs stepped plots) -.. _bug-fixes-54: +.. _bug-fixes-55: Bug fixes ~~~~~~~~~ @@ -1750,12 +1779,12 @@ Bug fixes - Univariate fitters are more flexiable and can allow 2-d and DataFrames as inputs. -.. _section-71: +.. _section-72: 0.19.1 - 2019-02-21 ------------------- -.. _new-features-50: +.. _new-features-51: New features ~~~~~~~~~~~~ @@ -1763,7 +1792,7 @@ New features - improved stability of ``LogNormalFitter`` - Matplotlib for Python3 users are not longer forced to use 2.x. -.. _api-changes-26: +.. _api-changes-27: API changes ~~~~~~~~~~~ @@ -1772,12 +1801,12 @@ API changes ``PiecewiseExponential`` to the same as ``ExponentialFitter`` (from ``\lambda * t`` to ``t / \lambda``). -.. _section-72: +.. _section-73: 0.19.0 - 2019-02-20 ------------------- -.. _new-features-51: +.. _new-features-52: New features ~~~~~~~~~~~~ @@ -1790,7 +1819,7 @@ New features - ``CoxPHFitter`` performance improvements (about 10%) - ``CoxTimeVaryingFitter`` performance improvements (about 10%) -.. _api-changes-27: +.. _api-changes-28: API changes ~~~~~~~~~~~ @@ -1816,7 +1845,7 @@ API changes means that the *default* for alpha is set to 0.05 in the latest lifelines, instead of 0.95 in previous versions. -.. _bug-fixes-55: +.. _bug-fixes-56: Bug Fixes ~~~~~~~~~ @@ -1833,7 +1862,7 @@ Bug Fixes models. Thanks @airanmehr! - Fixed some Pandas <0.24 bugs. -.. _section-73: +.. _section-74: 0.18.6 - 2019-02-13 ------------------- @@ -1843,7 +1872,7 @@ Bug Fixes ``rank`` and ``km`` p-values now. - some performance improvements to ``qth_survival_time``. -.. _section-74: +.. _section-75: 0.18.5 - 2019-02-11 ------------------- @@ -1864,7 +1893,7 @@ Bug Fixes that can be used to turn off variance calculations since this can take a long time for large datasets. Thanks @pzivich! -.. _section-75: +.. _section-76: 0.18.4 - 2019-02-10 ------------------- @@ -1874,7 +1903,7 @@ Bug Fixes - adding left-truncation support to parametric univarite models with the ``entry`` kwarg in ``.fit`` -.. _section-76: +.. _section-77: 0.18.3 - 2019-02-07 ------------------- @@ -1884,7 +1913,7 @@ Bug Fixes warnings are more noticeable. - Improved some warning and error messages. -.. _section-77: +.. _section-78: 0.18.2 - 2019-02-05 ------------------- @@ -1900,7 +1929,7 @@ Bug Fixes Moved them all (most) to use ``autograd``. - ``LogNormalFitter`` no longer models ``log_sigma``. -.. _section-78: +.. _section-79: 0.18.1 - 2019-02-02 ------------------- @@ -1911,7 +1940,7 @@ Bug Fixes - use the ``autograd`` lib to help with gradients. - New ``LogLogisticFitter`` univariate fitter available. -.. _section-79: +.. _section-80: 0.18.0 - 2019-01-31 ------------------- @@ -1948,7 +1977,7 @@ Bug Fixes ``LinAlgError: Matrix is singular.`` and report back to the user advice. -.. _section-80: +.. _section-81: 0.17.5 - 2019-01-25 ------------------- @@ -1956,7 +1985,7 @@ Bug Fixes - more bugs in ``plot_covariate_groups`` fixed when using non-numeric strata. -.. _section-81: +.. _section-82: 0.17.4 -2019-01-25 ------------------ @@ -1968,7 +1997,7 @@ Bug Fixes - ``groups`` is now called ``values`` in ``CoxPHFitter.plot_covariate_groups`` -.. _section-82: +.. _section-83: 0.17.3 - 2019-01-24 ------------------- @@ -1976,7 +2005,7 @@ Bug Fixes - Fix in ``compute_residuals`` when using ``schoenfeld`` and the minumum duration has only censored subjects. -.. _section-83: +.. _section-84: 0.17.2 2019-01-22 ----------------- @@ -1987,7 +2016,7 @@ Bug Fixes ``for`` loop. The downside is the code is more esoteric now. I’ve added comments as necessary though 🤞 -.. _section-84: +.. _section-85: 0.17.1 - 2019-01-20 ------------------- @@ -2004,7 +2033,7 @@ Bug Fixes - Fixes a Pandas performance warning in ``CoxTimeVaryingFitter``. - Performances improvements to ``CoxTimeVaryingFitter``. -.. _section-85: +.. _section-86: 0.17.0 - 2019-01-11 ------------------- @@ -2025,7 +2054,7 @@ Bug Fixes - some plotting improvemnts to ``plotting.plot_lifetimes`` -.. _section-86: +.. _section-87: 0.16.3 - 2019-01-03 ------------------- @@ -2033,7 +2062,7 @@ Bug Fixes - More ``CoxPHFitter`` performance improvements. Up to a 40% reduction vs 0.16.2 for some datasets. -.. _section-87: +.. _section-88: 0.16.2 - 2019-01-02 ------------------- @@ -2044,14 +2073,14 @@ Bug Fixes has lots of duplicate times. See https://github.com/CamDavidsonPilon/lifelines/issues/591 -.. _section-88: +.. _section-89: 0.16.1 - 2019-01-01 ------------------- - Fixed py2 division error in ``concordance`` method. -.. _section-89: +.. _section-90: 0.16.0 - 2019-01-01 ------------------- @@ -2087,7 +2116,7 @@ Bug Fixes ``lifelines.utils.to_episodic_format``. - ``CoxTimeVaryingFitter`` now accepts ``strata``. -.. _section-90: +.. _section-91: 0.15.4 ------ @@ -2095,14 +2124,14 @@ Bug Fixes - bug fix for the Cox model likelihood ratio test when using non-trivial weights. -.. _section-91: +.. _section-92: 0.15.3 - 2018-12-18 ------------------- - Only allow matplotlib less than 3.0. -.. _section-92: +.. _section-93: 0.15.2 - 2018-11-23 ------------------- @@ -2113,7 +2142,7 @@ Bug Fixes - removed ``entry`` from ``ExponentialFitter`` and ``WeibullFitter`` as it was doing nothing. -.. _section-93: +.. _section-94: 0.15.1 - 2018-11-23 ------------------- @@ -2122,7 +2151,7 @@ Bug Fixes - Raise NotImplementedError if the ``robust`` flag is used in ``CoxTimeVaryingFitter`` - that’s not ready yet. -.. _section-94: +.. _section-95: 0.15.0 - 2018-11-22 ------------------- @@ -2193,7 +2222,7 @@ Bug Fixes When Estimating Risks in Pharmacoepidemiology” for a nice overview of the model. -.. _section-95: +.. _section-96: 0.14.6 - 2018-07-02 ------------------- @@ -2201,7 +2230,7 @@ Bug Fixes - fix for n > 2 groups in ``multivariate_logrank_test`` (again). - fix bug for when ``event_observed`` column was not boolean. -.. _section-96: +.. _section-97: 0.14.5 - 2018-06-29 ------------------- @@ -2209,7 +2238,7 @@ Bug Fixes - fix for n > 2 groups in ``multivariate_logrank_test`` - fix weights in KaplanMeierFitter when using a pandas Series. -.. _section-97: +.. _section-98: 0.14.4 - 2018-06-14 ------------------- @@ -2226,7 +2255,7 @@ Bug Fixes - New ``delay`` parameter in ``add_covariate_to_timeline`` - removed ``two_sided_z_test`` from ``statistics`` -.. _section-98: +.. _section-99: 0.14.3 - 2018-05-24 ------------------- @@ -2238,7 +2267,7 @@ Bug Fixes - adds a ``column`` argument to ``CoxTimeVaryingFitter`` and ``CoxPHFitter`` ``plot`` method to plot only a subset of columns. -.. _section-99: +.. _section-100: 0.14.2 - 2018-05-18 ------------------- @@ -2246,7 +2275,7 @@ Bug Fixes - some quality of life improvements for working with ``CoxTimeVaryingFitter`` including new ``predict_`` methods. -.. _section-100: +.. _section-101: 0.14.1 - 2018-04-01 ------------------- @@ -2264,7 +2293,7 @@ Bug Fixes faster completion of ``fit`` for large dataframes, and up to 10% faster for small dataframes. -.. _section-101: +.. _section-102: 0.14.0 - 2018-03-03 ------------------- @@ -2286,7 +2315,7 @@ Bug Fixes of a ``RuntimeWarning`` - New checks for complete separation in the dataset for regressions. -.. _section-102: +.. _section-103: 0.13.0 - 2017-12-22 ------------------- @@ -2315,7 +2344,7 @@ Bug Fixes group the same subjects together and give that observation a weight equal to the count. Altogether, this means a much faster regression. -.. _section-103: +.. _section-104: 0.12.0 ------ @@ -2332,7 +2361,7 @@ Bug Fixes - Additional functionality to ``utils.survival_table_from_events`` to bin the index to make the resulting table more readable. -.. _section-104: +.. _section-105: 0.11.3 ------ @@ -2344,7 +2373,7 @@ Bug Fixes observation or censorship. - More accurate prediction methods parametrics univariate models. -.. _section-105: +.. _section-106: 0.11.2 ------ @@ -2352,14 +2381,14 @@ Bug Fixes - Changing liscense to valilla MIT. - Speed up ``NelsonAalenFitter.fit`` considerably. -.. _section-106: +.. _section-107: 0.11.1 - 2017-06-22 ------------------- - Python3 fix for ``CoxPHFitter.plot``. -.. _section-107: +.. _section-108: 0.11.0 - 2017-06-21 ------------------- @@ -2373,14 +2402,14 @@ Bug Fixes of a new ``loc`` kwarg. This is to align with Pandas deprecating ``ix`` -.. _section-108: +.. _section-109: 0.10.1 - 2017-06-05 ------------------- - fix in internal normalization for ``CoxPHFitter`` predict methods. -.. _section-109: +.. _section-110: 0.10.0 ------ @@ -2395,7 +2424,7 @@ Bug Fixes mimic R’s ``basehaz`` API. - new ``predict_log_partial_hazards`` to ``CoxPHFitter`` -.. _section-110: +.. _section-111: 0.9.4 ----- @@ -2418,7 +2447,7 @@ Bug Fixes - performance improvements in ``CoxPHFitter`` - should see at least a 10% speed improvement in ``fit``. -.. _section-111: +.. _section-112: 0.9.2 ----- @@ -2427,7 +2456,7 @@ Bug Fixes - throw an error if no admissable pairs in the c-index calculation. Previously a NaN was returned. -.. _section-112: +.. _section-113: 0.9.1 ----- @@ -2435,7 +2464,7 @@ Bug Fixes - add two summary functions to Weibull and Exponential fitter, solves #224 -.. _section-113: +.. _section-114: 0.9.0 ----- @@ -2451,7 +2480,7 @@ Bug Fixes - Default predict method in ``k_fold_cross_validation`` is now ``predict_expectation`` -.. _section-114: +.. _section-115: 0.8.1 - 2015-08-01 ------------------ @@ -2468,7 +2497,7 @@ Bug Fixes - scaling of smooth hazards in NelsonAalenFitter was off by a factor of 0.5. -.. _section-115: +.. _section-116: 0.8.0 ----- @@ -2487,7 +2516,7 @@ Bug Fixes ``lifelines.statistics. power_under_cph``. - fixed a bug when using KaplanMeierFitter for left-censored data. -.. _section-116: +.. _section-117: 0.7.1 ----- @@ -2506,7 +2535,7 @@ Bug Fixes - 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. -.. _section-117: +.. _section-118: 0.7.0 - 2015-03-01 ------------------ @@ -2525,7 +2554,7 @@ Bug Fixes duration remaining until the death event, given survival up until time t. -.. _section-118: +.. _section-119: 0.6.1 ----- @@ -2537,7 +2566,7 @@ Bug Fixes your work is to sum up the survival function (for expected values or something similar), it’s more difficult to make a mistake. -.. _section-119: +.. _section-120: 0.6.0 - 2015-02-04 ------------------ @@ -2560,7 +2589,7 @@ Bug Fixes - In ``KaplanMeierFitter``, ``epsilon`` has been renamed to ``precision``. -.. _section-120: +.. _section-121: 0.5.1 - 2014-12-24 ------------------ @@ -2581,7 +2610,7 @@ Bug Fixes ``lifelines.plotting.add_at_risk_counts``. - Fix bug Epanechnikov kernel. -.. _section-121: +.. _section-122: 0.5.0 - 2014-12-07 ------------------ @@ -2594,7 +2623,7 @@ Bug Fixes - add test for summary() - Alternate metrics can be used for ``k_fold_cross_validation``. -.. _section-122: +.. _section-123: 0.4.4 - 2014-11-27 ------------------ @@ -2606,7 +2635,7 @@ Bug Fixes - Fixes bug in 1-d input not returning in CoxPHFitter - Lots of new tests. -.. _section-123: +.. _section-124: 0.4.3 - 2014-07-23 ------------------ @@ -2627,7 +2656,7 @@ Bug Fixes - Adds option ``include_likelihood`` to CoxPHFitter fit method to save the final log-likelihood value. -.. _section-124: +.. _section-125: 0.4.2 - 2014-06-19 ------------------ @@ -2647,7 +2676,7 @@ Bug Fixes from failing so often (this a stop-gap) - pep8 everything -.. _section-125: +.. _section-126: 0.4.1.1 ------- @@ -2660,7 +2689,7 @@ Bug Fixes - Adding more robust cross validation scheme based on issue #67. - fixing ``regression_dataset`` in ``datasets``. -.. _section-126: +.. _section-127: 0.4.1 - 2014-06-11 ------------------ @@ -2679,7 +2708,7 @@ Bug Fixes - Adding a Changelog. - more sanitizing for the statistical tests =) -.. _section-127: +.. _section-128: 0.4.0 - 2014-06-08 ------------------ diff --git a/docs/Survival Regression.rst b/docs/Survival Regression.rst index 9f06cbf0a..5bf6cbb90 100644 --- a/docs/Survival Regression.rst +++ b/docs/Survival Regression.rst @@ -509,9 +509,12 @@ Below we compare the non-parametric and the fully parametric baseline survivals: cph_semi = CoxPHFitter().fit(rossi, 'week', event_col='arrest') cph_piecewise = CoxPHFitter(baseline_estimation_method="piecewise", breakpoints=[20, 35]).fit(rossi, 'week', event_col='arrest') - ax = cph_spline.baseline_cumulative_hazard_.plot() - cph_semi.baseline_cumulative_hazard_.plot(ax=ax, drawstyle="steps-post") - cph_piecewise.baseline_cumulative_hazard_.plot(ax=ax) + bch_key = "baseline cumulative hazard" + + ax = cph_spline.baseline_cumulative_hazard_[bch_key].plot(label="spline") + cph_semi.baseline_cumulative_hazard_[bch_key].plot(ax=ax, drawstyle="steps-post", label="semi") + cph_piecewise.baseline_cumulative_hazard_[bch_key].plot(ax=ax, label="peicewise[20,35]") + plt.legend() .. figure:: images/spline_and_semi.png @@ -1015,13 +1018,13 @@ two individual columns: a *duration* column and a boolean *event occurred* colum .. code:: python - X['T'] = data['duration'] - X['E'] = data['observed'] + df['T'] = data['duration'] + df['E'] = data['observed'] .. code:: python - aaf.fit(X, 'T', event_col='E', formula='un_continent_name + regime + start_year') + aaf.fit(df, 'T', event_col='E', formula='un_continent_name + regime + start_year') After fitting, the instance exposes a :attr:`~lifelines.fitters.aalen_additive_fitter.AalenAdditiveFitter.cumulative_hazards_` DataFrame @@ -1054,7 +1057,7 @@ containing the estimates of :math:`\int_0^t b_i(s) \; ds`: .. code:: python - aaf.plot(columns=['regime[T.Presidential Dem]', 'baseline', 'un_continent_name[T.Europe]'], iloc=slice(1,15)) + aaf.plot(columns=['regime[T.Presidential Dem]', 'Intercept', 'un_continent_name[T.Europe]'], iloc=slice(1,15)) .. image:: images/survival_regression_aaf.png @@ -1070,7 +1073,7 @@ Prime Minister Stephen Harper. .. code:: python ix = (data['ctryname'] == 'Canada') & (data['start_year'] == 2006) - harper = X.loc[ix] + harper = df.loc[ix] print("Harper's unique data point:") print(harper) diff --git a/docs/Survival analysis with lifelines.rst b/docs/Survival analysis with lifelines.rst index 28375fb7b..7e6d6ca27 100644 --- a/docs/Survival analysis with lifelines.rst +++ b/docs/Survival analysis with lifelines.rst @@ -809,7 +809,7 @@ Another situation with left-truncation occurs when subjects are exposed before e df = load_multicenter_aids_cohort_study() plot_lifetimes( - df["T"] - df["W"], + df["T"], event_observed=df["D"], entry=df["W"], event_observed_color="#383838", diff --git a/docs/images/spline_and_semi.png b/docs/images/spline_and_semi.png index 7ea3903be..167d263b8 100644 Binary files a/docs/images/spline_and_semi.png and b/docs/images/spline_and_semi.png differ diff --git a/examples/SaaS churn and piecewise regression models.ipynb b/examples/SaaS churn and piecewise regression models.ipynb index 6a1e8de88..a9427d07c 100644 --- a/examples/SaaS churn and piecewise regression models.ipynb +++ b/examples/SaaS churn and piecewise regression models.ipynb @@ -10,6 +10,7 @@ "%config InlineBackend.figure_format = 'retina'\n", "\n", "import numpy as np\n", + "import matplotlib.pyplot as plt\n", "import pandas as pd\n", "from lifelines.fitters.piecewise_exponential_regression_fitter import PiecewiseExponentialRegressionFitter\n", "from lifelines import *\n", diff --git a/lifelines/fitters/__init__.py b/lifelines/fitters/__init__.py index 642a40340..13fa93ded 100644 --- a/lifelines/fitters/__init__.py +++ b/lifelines/fitters/__init__.py @@ -524,7 +524,7 @@ def _create_initial_point(self, *args) -> np.ndarray: # *args has terms like Ts, E, entry, weights return np.array(list(self._initial_values_from_bounds())) - def _fit_model(self, Ts, E, entry, weights, show_progress=True): + def _fit_model(self, Ts, E, entry, weights, fit_options: dict, show_progress=True): if utils.CensoringType.is_left_censoring(self): negative_log_likelihood = self._negative_log_likelihood_left_censoring @@ -539,7 +539,7 @@ def _fit_model(self, Ts, E, entry, weights, show_progress=True): minimizing_results, previous_results, minimizing_ll = None, None, np.inf for method, option in zip( ["Nelder-Mead", self._scipy_fit_method], - [{"maxiter": 100}, {**{"disp": show_progress}, **self._scipy_fit_options}], + [{"maxiter": 100}, {**{"disp": show_progress}, **self._scipy_fit_options, **fit_options}], ): initial_value = self._initial_values if previous_results is None else utils._to_1d_array(previous_results.x) @@ -713,6 +713,7 @@ def fit( entry=None, weights=None, initial_point=None, + fit_options: Optional[dict] = None, ) -> ParametricUnivariateFitter: # pylint: disable=too-many-arguments """ Parameters @@ -740,6 +741,8 @@ def fit( initial_point: (d,) numpy array, optional initialize the starting point of the iterative algorithm. Default is the zero vector. + fit_options: dict, optional + pass kwargs into the underlying minimization algorithm, like ``tol``, etc. Returns ------- @@ -763,6 +766,7 @@ def fit( entry=entry, weights=weights, initial_point=initial_point, + fit_options=fit_options, ) @utils.CensoringType.left_censoring @@ -778,6 +782,7 @@ def fit_left_censoring( entry=None, weights=None, initial_point=None, + fit_options: Optional[dict] = None, ) -> ParametricUnivariateFitter: # pylint: disable=too-many-arguments """ Fit the model to a left-censored dataset @@ -807,6 +812,8 @@ def fit_left_censoring( initial_point: (d,) numpy array, optional initialize the starting point of the iterative algorithm. Default is the zero vector. + fit_options: dict, optional + pass kwargs into the underlying minimization algorithm, like ``tol``, etc. Returns ------- @@ -828,6 +835,7 @@ def fit_left_censoring( entry=entry, weights=weights, initial_point=initial_point, + fit_options=fit_options, ) @utils.CensoringType.interval_censoring @@ -844,6 +852,7 @@ def fit_interval_censoring( entry=None, weights=None, initial_point=None, + fit_options: Optional[dict] = None, ) -> ParametricUnivariateFitter: # pylint: disable=too-many-arguments """ Fit the model to an interval censored dataset. @@ -876,6 +885,8 @@ def fit_interval_censoring( initial_point: (d,) numpy array, optional initialize the starting point of the iterative algorithm. Default is the zero vector. + fit_options: dict, optional + pass kwargs into the underlying minimization algorithm, like ``tol``, etc. Returns ------- @@ -911,6 +922,7 @@ def fit_interval_censoring( entry=entry, weights=weights, initial_point=initial_point, + fit_options=fit_options, ) def _fit( @@ -925,6 +937,7 @@ def _fit( entry=None, weights=None, initial_point=None, + fit_options=None, ) -> ParametricUnivariateFitter: n = len(utils.coalesce(*Ts)) @@ -946,6 +959,7 @@ def _fit( self._label = utils.coalesce(label, self._label, self._class_name.replace("Fitter", "") + "_estimate") self._ci_labels = ci_labels self.alpha = utils.coalesce(alpha, self.alpha) + fit_options = utils.coalesce(fit_options, dict()) # create some initial values, and test them in the hazard. self._initial_values = utils.coalesce( @@ -961,7 +975,7 @@ def _fit( # estimation self._fitted_parameters_, self.log_likelihood_, self._hessian_ = self._fit_model( - Ts, self.event_observed.astype(bool), self.entry, self.weights, show_progress=show_progress + Ts, self.event_observed.astype(bool), self.entry, self.weights, show_progress=show_progress, fit_options=fit_options ) if not self._KNOWN_MODEL: @@ -1453,6 +1467,7 @@ def fit_left_censoring( robust=False, initial_point=None, entry_col=None, + fit_options: Optional[dict] = None, ) -> ParametricRegressionFitter: """ Fit the regression model to a left-censored dataset. @@ -1500,6 +1515,9 @@ def fit_left_censoring( specify a column in the DataFrame that denotes any late-entries (left truncation) that occurred. See the docs on `left truncation `__ + fit_options: dict, optional + pass kwargs into the underlying minimization algorithm, like ``tol``, etc. + Returns ------- self with additional new properties ``print_summary``, ``params_``, ``confidence_intervals_`` and more @@ -1524,6 +1542,7 @@ def fit_left_censoring( robust=robust, initial_point=initial_point, entry_col=entry_col, + fit_options=fit_options, ) return self @@ -1543,6 +1562,7 @@ def fit_interval_censoring( robust=False, initial_point=None, entry_col=None, + fit_options: Optional[dict] = None, ) -> ParametricRegressionFitter: """ Fit the regression model to a interval-censored dataset. @@ -1593,6 +1613,9 @@ def fit_interval_censoring( specify a column in the DataFrame that denotes any late-entries (left truncation) that occurred. See the docs on `left truncation `__ + fit_options: dict, optional + pass kwargs into the underlying minimization algorithm, like ``tol``, etc. + Returns ------- self with additional new properties: ``print_summary``, ``params_``, ``confidence_intervals_`` and more @@ -1630,6 +1653,7 @@ def fit_interval_censoring( robust=robust, initial_point=initial_point, entry_col=entry_col, + fit_options=fit_options, ) return self @@ -1647,6 +1671,7 @@ def fit( robust=False, initial_point=None, entry_col=None, + fit_options: Optional[dict] = None, ) -> ParametricRegressionFitter: """ Fit the regression model to a right-censored dataset. @@ -1694,6 +1719,9 @@ def fit( specify a column in the DataFrame that denotes any late-entries (left truncation) that occurred. See the docs on `left truncation `__ + fit_options: dict, optional + pass kwargs into the underlying minimization algorithm, like ``tol``, etc. + Returns ------- self with additional new properties: ``print_summary``, ``params_``, ``confidence_intervals_`` and more @@ -1718,6 +1746,7 @@ def fit( robust=robust, initial_point=initial_point, entry_col=entry_col, + fit_options=fit_options, ) return self @@ -1735,6 +1764,7 @@ def _fit( robust=False, initial_point=None, entry_col=None, + fit_options: Optional[dict] = None, ) -> ParametricRegressionFitter: self._time_fit_was_called = datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S") + " UTC" @@ -1794,6 +1824,7 @@ def _fit( _norm_std[_norm_std < 1e-8] = 1.0 self._pre_fit_model(Ts, E, Xs) + _params, self.log_likelihood_, self._hessian_ = self._fit_model( log_likelihood_function, Ts, @@ -1801,6 +1832,7 @@ def _fit( E.values, weights.values, entries.values, + fit_options=utils.coalesce(fit_options, dict()), show_progress=show_progress, user_supplied_initial_point=initial_point, ) @@ -1881,7 +1913,9 @@ def _prepare_initial_points(self, user_supplied_initial_point, Ts, E, entries, w initial_point_arrays = [flatten(initial_point_dict)[0] for initial_point_dict in self._initial_point_dicts] return initial_point_arrays, unflatten - def _fit_model(self, likelihood, Ts, Xs, E, weights, entries, show_progress=False, user_supplied_initial_point=None): + def _fit_model( + self, likelihood, Ts, Xs, E, weights, entries, fit_options, show_progress=False, user_supplied_initial_point=None + ): inital_points_as_arrays, unflatten_array_to_dict = self._prepare_initial_points( user_supplied_initial_point, Ts, E, entries, weights, Xs ) @@ -1908,7 +1942,7 @@ def _fit_model(self, likelihood, Ts, Xs, E, weights, entries, show_progress=Fals method=self._scipy_fit_method, jac=True, args=(Ts, E, weights, entries, utils.DataframeSlicer(Xs)), - options={**{"disp": show_progress}, **self._scipy_fit_options}, + options={**{"disp": show_progress}, **self._scipy_fit_options, **fit_options}, callback=self._scipy_fit_callback, ) @@ -2691,6 +2725,7 @@ def fit( initial_point=None, entry_col=None, formula: str = None, + fit_options: Optional[dict] = None, ) -> ParametericAFTRegressionFitter: """ Fit the accelerated failure time model to a right-censored dataset. @@ -2718,6 +2753,8 @@ def fit( formula: string Use an R-style formula for modeling the dataset. See formula syntax: https://matthewwardrop.github.io/formulaic/basic/grammar/ + If a formula is not provided, all variables in the dataframe are used (minus those used for other purposes like event_col, etc.) + ancillary: None, boolean, str, or DataFrame, optional (default=None) Choose to model the ancillary parameters. @@ -2746,6 +2783,9 @@ def fit( specify a column in the DataFrame that denotes any late-entries (left truncation) that occurred. See the docs on `left truncation `__ + fit_options: dict, optional + pass kwargs into the underlying minimization algorithm, like ``tol``, etc. + Returns ------- self with additional new properties ``print_summary``, ``params_``, ``confidence_intervals_`` and more @@ -2830,6 +2870,7 @@ def fit( robust=robust, initial_point=initial_point, entry_col=entry_col, + fit_options=fit_options, ) return self @@ -2849,6 +2890,7 @@ def fit_interval_censoring( initial_point=None, entry_col=None, formula=None, + fit_options: Optional[dict] = None, ) -> ParametericAFTRegressionFitter: """ Fit the accelerated failure time model to a interval-censored dataset. @@ -2873,6 +2915,7 @@ def fit_interval_censoring( formula: string Use an R-style formula for modeling the dataset. See formula syntax: https://matthewwardrop.github.io/formulaic/basic/grammar/ + If a formula is not provided, all variables in the dataframe are used (minus those used for other purposes like event_col, etc.) ancillary: None, boolean, str, or DataFrame, optional (default=None) Choose to model the ancillary parameters. @@ -2905,6 +2948,8 @@ def fit_interval_censoring( specify a column in the DataFrame that denotes any late-entries (left truncation) that occurred. See the docs on `left truncation `__ + fit_options: dict, optional + pass kwargs into the underlying minimization algorithm, like ``tol``, etc. Returns ------- @@ -3009,6 +3054,7 @@ def fit_interval_censoring( robust=robust, initial_point=initial_point, entry_col=entry_col, + fit_options=fit_options, ) return self @@ -3027,6 +3073,7 @@ def fit_left_censoring( initial_point=None, entry_col=None, formula: str = None, + fit_options: Optional[dict] = None, ) -> ParametericAFTRegressionFitter: """ Fit the accelerated failure time model to a left-censored dataset. @@ -3050,6 +3097,7 @@ def fit_left_censoring( formula: string Use an R-style formula for modeling the dataset. See formula syntax: https://matthewwardrop.github.io/formulaic/basic/grammar/ + If a formula is not provided, all variables in the dataframe are used (minus those used for other purposes like event_col, etc.) ancillary: None, boolean, str, or DataFrame, optional (default=None) Choose to model the ancillary parameters. @@ -3082,6 +3130,8 @@ def fit_left_censoring( specify a column in the DataFrame that denotes any late-entries (left truncation) that occurred. See the docs on `left truncation `__ + fit_options: dict, optional + pass kwargs into the underlying minimization algorithm, like ``tol``, etc. Returns ------- @@ -3166,6 +3216,7 @@ def fit_left_censoring( robust=robust, initial_point=initial_point, entry_col=entry_col, + fit_options=fit_options, ) return self diff --git a/lifelines/fitters/breslow_fleming_harrington_fitter.py b/lifelines/fitters/breslow_fleming_harrington_fitter.py index 81491ef53..07b21e5f5 100644 --- a/lifelines/fitters/breslow_fleming_harrington_fitter.py +++ b/lifelines/fitters/breslow_fleming_harrington_fitter.py @@ -28,9 +28,19 @@ class BreslowFlemingHarringtonFitter(NonParametricUnivariateFitter): @CensoringType.right_censoring def fit( - self, durations, event_observed=None, timeline=None, entry=None, label=None, alpha=None, ci_labels=None, weights=None + self, + durations, + event_observed=None, + timeline=None, + entry=None, + label=None, + alpha=None, + ci_labels=None, + weights=None, + fit_options=None, ): # pylint: disable=too-many-arguments """ + Parameters ---------- durations: an array, or pd.Series, of length n @@ -50,7 +60,8 @@ def fit( alpha for this call to fit only. ci_labels: iterable add custom column names to the generated confidence intervals as a length-2 list: [, ]. Default: