Skip to content

Commit

Permalink
small doc changes
Browse files Browse the repository at this point in the history
  • Loading branch information
CamDavidsonPilon committed Jun 12, 2019
1 parent 81f051a commit a91113f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
10 changes: 6 additions & 4 deletions docs/Compatibility with scikit-learn.rst
Expand Up @@ -8,8 +8,7 @@ Compatibility with scikit-learn

New to lifelines in version 0.21.3 is a wrapper that allows you to use lifeline's regression models with scikit-learn's APIs.

.. note:: The X variable still needs to be a DataFrame, and should contains the event-occurred column (``event_col``) if it exists.

.. note:: the API and functionality is still experimental. Please report any bugs or features on our Github issue list.


.. code:: python
Expand All @@ -19,7 +18,7 @@ New to lifelines in version 0.21.3 is a wrapper that allows you to use lifeline'
from lifelines import CoxPHFitter
from lifelines.datasets import load_rossi
X = load_rossi().drop('week', axis=1)
X = load_rossi().drop('week', axis=1) # keep as a dataframe
Y = load_rossi().pop('week')
CoxRegression = sklearn_adapter(CoxPHFitter, event_col='arrest')
Expand All @@ -30,13 +29,16 @@ New to lifelines in version 0.21.3 is a wrapper that allows you to use lifeline'
print(sk_cph)
"""
CoxPHFitter(alpha=0.05, penalizer=1.0, strata=None, tie_method='Efron')
SkLearnCoxPHFitter(alpha=0.05, penalizer=1.0, strata=None, tie_method='Efron')
"""
sk_cph.predict(X)
sk_cph.score(X, Y)
.. note:: The X variable still needs to be a DataFrame, and should contains the event-occurred column (``event_col``) if it exists.


If needed, the original lifeline's instance is available as the ``lifelines_model`` attribute.

.. code:: python
Expand Down
4 changes: 3 additions & 1 deletion docs/Survival Regression.rst
Expand Up @@ -929,7 +929,7 @@ Model selection based on predictive power

If censoring is present, it's not appropriate to use a loss function like mean-squared-error or
mean-absolute-loss. Instead, one measure is the concordance-index, also known as the c-index. This measure
evaluates the accuracy of the ordering of predicted time. It is in fact a generalization
evaluates the accuracy of the *ranking* of predicted time. It is in fact a generalization
of AUC, another common loss function, and is interpreted similarly:

* 0.5 is the expected result from random predictions,
Expand Down Expand Up @@ -959,6 +959,8 @@ Fitted survival models typically have a concordance index between 0.55 and 0.75
from lifelines.utils import concordance_index
print(concordance_index(rossi['week'], -cph.predict_partial_hazard(rossi), rossi['arrest']))
.. note:: Remember, the concordance score evaluates the relative rankings of subject's event times. Thus, it is scale invariant (i.e. you can multiple by a positive constant, or add a constant, and the rankings won't change). A model maximized for concordance-index does not necessarily give good predicted *times*, but will give good predicted *rankings*.


However, there are other, arguably better, methods to measure the fit of a model. Included in ``print_summary`` is the log-likelihood, which can be used in an `AIC calculation <https://en.wikipedia.org/wiki/Akaike_information_criterion>`_, and the `log-likelihood ratio statistic <https://en.wikipedia.org/wiki/Likelihood-ratio_test>`_. Generally, I personally loved this article by Frank Harrell, `"Statistically Efficient Ways to Quantify Added Predictive Value of New Measurements" <http://www.fharrell.com/post/addvalue/>`_.

Expand Down
7 changes: 5 additions & 2 deletions docs/conf.py
Expand Up @@ -15,6 +15,7 @@
from datetime import date
import sys
import os
import lifelines

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
Expand All @@ -40,6 +41,7 @@

exclude_patterns = ["_build", "jupyter_notebooks/.ipynb_checkpoints/*.ipynb"]


# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]

Expand All @@ -63,8 +65,9 @@
#
# The short X.Y version.

version = "0.21.3"
# The full version, including dev info
# The short X.Y version.
version = lifelines.__version__
# The full version, including alpha/beta/rc tags.
release = version

# The language for content autogenerated by Sphinx. Refer to documentation
Expand Down
2 changes: 1 addition & 1 deletion docs/lifelines.fitters.rst
Expand Up @@ -112,7 +112,7 @@ lifelines.fitters.log\_logistic\_aft\_fitter module


lifelines.fitters.piecewise\_exponential\_regression\_fitter module
-----------------------------------------------------
----------------------------------------------------------------------

.. automodule:: lifelines.fitters.piecewise_exponential_regression_fitter
:members:
Expand Down

0 comments on commit a91113f

Please sign in to comment.