我尝试运行以下代码。但它在 lifelines/plotting.py 文件中给出了参数所需的错误。我无法修复它。
import pandas as pd
from lifelines.datasets import load_dd
import matplotlib.pyplot as plt
data = load_dd()
print data.sample(6)
from lifelines import KaplanMeierFitter
kmf = KaplanMeierFitter()
T = data["duration"]
E = data["observed"]
kmf.fit(T, event_observed=E)
kmf.survival_function_.plot()
plt.title('Survival function of political regimes');
kmf.plot()
plt.show()
但它给出了以下错误
Traceback (most recent call last): File "/Users/rabindra/PycharmProjects/SurvivalAnalysis/sources/main.py", line 17, in <module>
kmf.plot() File "/Library/Python/2.7/site-packages/lifelines/plotting.py", line 331, in plot
set_kwargs_color(kwargs) File "/Library/Python/2.7/site-packages/lifelines/plotting.py", line 223, in set_kwargs_color
kwargs["ax"]._get_lines.get_next_color()) AttributeError: '_process_plot_var_args' object has no attribute 'get_next_color'
我也面临着同样的问题。
将 lifelines 升级到 0.14.0,将 matplotlib 升级到 2.2.2 并且可以正常工作。