CamDavidsonPilon / lifelines

Survival analysis in Python
lifelines.readthedocs.org
MIT License
2.37k stars 560 forks source link

kaplan_meier_fitter: RuntimeWarning: divide by zero encountered in log #259

Closed floatingpurr closed 8 years ago

floatingpurr commented 8 years ago

When I try to calculate KM for

T = [0, 3.5232, 3, 2, 1, 2]
E = [1, 1, 0, 0, 1, 1]

I read the following warning:

.../kaplan_meier_fitter.py:97: RuntimeWarning: divide by zero encountered in log
  return (np.log(population - deaths) - np.log(population))

Are there any consequence and is there a way to fix?

CamDavidsonPilon commented 8 years ago

Hey there, I actually fixed that in a recent change, but I have not released a new cut. One second...

Okay, I cut a new release, 0.9.3.1, that handles these warnings (they are harmless btw)

floatingpurr commented 8 years ago

Hey @CamDavidsonPilon , thank you so much! : )

floatingpurr commented 8 years ago

...but now the same code trigger this error:

ax = kmf.plot(show_censors=True, ci_show=False)


  File "/.../plotting.py", line 292, in plot
    set_kwargs_color(kwargs)
  File "/.../plotting.py", line 229, in set_kwargs_color
    kwargs["ax"]._get_lines.get_next_color())
AttributeError: '_process_plot_var_args' object has no attribute 'get_next_color'

Is it due to new modifications?

CamDavidsonPilon commented 8 years ago

Ah I believe i also deprecated some old versions of matplotlib - which version are you using?

floatingpurr commented 8 years ago

I'm using matplotlib==1.5.3

CamDavidsonPilon commented 8 years ago

shoot, hm, let me get this fixed asap

CamDavidsonPilon commented 8 years ago

0.9.3.2 was just released with a 🎩'd fix