我有这个清单:
new_tree = {'cues': 'glucose_tol',
'directions': '<=',
'thresholds': '122.5',
'exits': 1.0,
'children': [{'cues': True},
{'cues': 'mass_index',
'directions': '<=',
'thresholds': '30.8',
'exits': 1.0,
'children': [{'cues': 'pedigree',
'directions': '<=',
'thresholds': '0.305',
'exits': 1.0,
'children': [{'cues': True},
{'cues': 'diastolic_pb',
'directions': '<=',
'thresholds': '77.0',
'exits': 1,
'children': [{'cues': True},
{'cues': 'insulin',
'directions': '<=',
'thresholds': '480',
'exits': '0.5',
'children': [{'cues': True}, {'cues': False}]}]}]}]}]}
这棵树看起来像这样:
我想获得这些数据点在此树形列表中的路径,这样我就可以知道它们所处的位置,然后进行一些计算。
我有两个数据点只是为了说明:
times_pregnant,glucose_tol,diastolic_pb,triceps,insulin,mass_index,pedigree,age,label
6,148,72,35,0,33.6,0.627,50,1
1,85,66,29,0,26.6,0.351,31,0
第一个将为glucose_tol,mass_index,谱系,diastolic_pb,并将被分类为True。如何从该数据点经过的列表中获得这4条线索,并将其保存以备将来计算?