{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Lifelines examples\n", "##### Gehan Survival Dataset\n", "\n", "The data show the length of remission in weeks for two groups of leukemia patients, treated and control, and were analyzed by Cox in his original proportional hazards paper. The data are available in a file containing three columns:\n", "\n", "- Treatment: coded Treated (drug) or Control (placebo),\n", "- Time: weeks of remission,\n", "- Failure: coded 1 if a failure (relapse), 0 if censored\n", "\n", "Thus, the third and fourth observations, 6 and 6+, corresponding to a death and a censored observation at six weeks, are coded 6, 1 and 6, 0, respectively." ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Populating the interactive namespace from numpy and matplotlib\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "WARNING: pylab import has clobbered these variables: ['datetime']\n", "`%matplotlib` prevents importing * from pylab and numpy\n" ] } ], "source": [ "from lifelines.estimation import KaplanMeierFitter, NelsonAalenFitter\n", "import pandas as pd\n", "import numpy as np\n", "%pylab inline\n", "figsize(12.5,6)" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/Users/camerondavidson-pilon/.virtualenvs/data/lib/python2.7/site-packages/IPython/kernel/__main__.py:1: ParserWarning: Falling back to the 'python' engine because the 'c' engine does not support regex separators; you can avoid this warning by specifying engine='python'.\n", " if __name__ == '__main__':\n" ] } ], "source": [ "data = pd.read_csv('../lifelines/datasets/gehan.dat', sep=\"\\s{1,3}\", header=None)" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", " | 0 | \n", "1 | \n", "2 | \n", "
---|---|---|---|
37 | \n", "1 | \n", "12 | \n", "1 | \n", "
38 | \n", "1 | \n", "15 | \n", "1 | \n", "
39 | \n", "1 | \n", "17 | \n", "1 | \n", "
40 | \n", "1 | \n", "22 | \n", "1 | \n", "
41 | \n", "1 | \n", "23 | \n", "1 | \n", "