如何获得这本字典:
{'glucose_tol <= 122.5':
[
{'mass_index <= 30.8':
[
{'pedigree <= 0.305':
[
{'diastolic_pb <= 77.0': [ {'insulin <= 480.0': [0.0, 1.0]},
1.0] },
1.0]},
1.0]},
1.0]
}
变成像这样的大熊猫数据框:
tree cues directions thresholds exits
1 1 glucose_tol;mass_index;pedigree;diastolic_pb;insulin <=;<=;<=;<=;<= 122.5;30.8;0.305;77.0;480.0 1;1;1;1;0.5
出口末尾的0.5表示我们的最后一个节点的值为0.0、1.0(False和True)
我需要这样做,以便无论我给出的决策树如何,它都以这种格式在熊猫数据框中返回给我。