Predicting with CoxPH could raise an error

Fixes an issue where CoxPH would cause an error to be raised
which seemed to be due to mixing of pandas and numpy.

Signed-off-by: Jonas Kalderstam <jonas@kalderstam.se>
Add tests for CoxPH which are currently failing

Noticed some strange behavior with CoxPH. I always have
normalized data, which did not seem to work good with
the implementation. The failures here seem unrelated to that
though.

The added tests currently fail with the following trace:

>Traceback (most recent call last):
>  File "/home/jonas/workspacepython/lifelines/lifelines/tests/test_suite.py", line 937, in test_crossval_normalized
>    event_col='E', k=3)
>  File "/home/jonas/workspacepython/lifelines/lifelines/utils.py", line 311, in k_fold_cross_validation
>    fitter.fit(training_data, duration_col=duration_col, event_col=event_col)
>  File "/home/jonas/workspacepython/lifelines/lifelines/estimation.py", line 998, in fit
>    include_likelihood=include_likelihood)
>  File "/home/jonas/workspacepython/lifelines/lifelines/estimation.py", line 938, in _newton_rhaphson
>    delta = solve(-hessian, step_size * gradient.T)
>  File "/home/jonas/anaconda3/lib/python3.4/site-packages/numpy/linalg/linalg.py", line 381, in solve
>    r = gufunc(a, b, signature=signature, extobj=extobj)
>  File "/home/jonas/anaconda3/lib/python3.4/site-packages/numpy/linalg/linalg.py", line 90, in _raise_linalgerror_singular
>    raise LinAlgError("Singular matrix")
>numpy.linalg.linalg.LinAlgError: Singular matrix

However, note that I have commented out one of the datasets because that
seems to cause the cross-validation to end up in an infinite loop of
some kind. The tests never finish (only waited for ~2 minutes).

Doing similar checks with *R* works with no problem.

Doing the following is a fast way to check the results:

    python -m unittest lifelines.tests.test_suite.CoxRegressionTests

Signed-off-by: Jonas Kalderstam <jonas@kalderstam.se>
fixing inequality bug, and adding noise to tests
fix typo
adding predict method to fitters, and cleaning up some tests + adding more regression tests; adding new datasets
fixing coxph prediction values
fixing a few tets
Change to gaussian noise, increase limits

Cox should really solve the data (cindex > 0.9). This
is what happens in R.

Signed-off-by: Jonas Kalderstam <jonas@kalderstam.se>
reverting the keyword argument for birth_col, I found a better way
getting baseline survival for CoxPH correct! Adding new baseline pieces like cumulative_hazard_ and baseline_survival_
adding new CoxPH test for p-values and se
make test more liberal
in order to allow for weighted values, and to keep thing non-boolean, cast output of survival_table_to_events to float
Make CoxPHs summary print more details, like in R

Signed-off-by: Jonas Kalderstam <jonas@kalderstam.se>
Set scientific format

Signed-off-by: Jonas Kalderstam <jonas@kalderstam.se>
Set format on concordance in summary print

Signed-off-by: Jonas Kalderstam <jonas@kalderstam.se>
Fix errors with singular matrix in CoxPH

This fixes the error of singular matrices when solution
is 'too exact'.

Signed-off-by: Jonas Kalderstam <jonas@kalderstam.se>
Correct numerical errors in Newton-Raphson

This correct two different problems with the N-R implementation.

1) Floating point precision

We had

    z = np.array([1.65685650e-179,   1.98728692e-179])
    denom = 2.01875531e-179

and wanted to calculate a2

    a2 = np.dot(z.T, z) / denom**2
    # Result: 0/0 = NaN

This meant squaring a number with 179 zero decimal points, which
resulted in a number with 358 zero decimal points, which exceeds
the maximum possible 324. Changing the order in the arithmetic solves
this particular problem though:

     a2 = np.dot(z.T / denom, z / denom)
     # Result: 1.64266749603

2) Exploding convergence in N-R

In case of noise-less data, the function managed to converge "too
well". This resulted in a overflowed result from the linear solver,
meaning delta went to a huge positive number and the numerics
exploded.

I have implemented a maximum allowed step size (10 seemed appropriate)
and a maximum number of iteration steps (50 is enough). If the delta is
too large, step size is divided by 2 and the algorithm tries again. A
lower limit of the step size is set at 0.001.

Signed-off-by: Jonas Kalderstam <jonas@kalderstam.se>
adding normalizer (default True) to coxPH model - this helps with avoiding overflow in exponential arguments
adding new test for normalizing time variable: why does this improve c-index?