如何计算数据帧pandaspython中特征的条件概率?

2024-10-03 06:23:52 发布

您现在位置:Python中文网/ 问答频道 /正文

假设我有以下数据集:

              headache    diabetes    pressure      case                       

patient 1        0          1            1           sick
........         .          .            .              .
.........        .          .            .              .
patient n        0          0           0            not sick

如何在python中计算这三个属性的后验概率和条件概率? 我使用了以下代码:

我有个错误:

pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
TypeError: '(slice(None, None, None), 0)' is an invalid key

Tags: 数据innonepandasgetindex概率loc