我试图获得各个岩石类型的每个特征的相对重要性以及它的特征名称。我做了以下事情:
for y_train_all, y_strings_all in zip(y_trains_classes,
y_classes_names):
grid_for.fit(X_train, y_train_all)
feature_importances = grid_for.best_estimator_.feature_importances_
attributes_all = ["Depth" ,"Neutron Porosity","Caliper ", "Density Porosity","Gamma Ray",
"Photoelectric", "Bulk Density", "Density Correction", "Resistivity (Deep)",
"Resistivity (Medium)", "Resistivity (Shallow)","Ratio(Shallow/Deep resistivity)",
"SP", "Micro-inverse (resistivity) micro-log", "Micro-normal (resistivity) micro-log",
"Delta-t (transit time)", "Sonic Porosity"]
print("\n", "Features importance of", y_strings_all, "= \n", sorted(zip(feature_importances*100, attributes_all),
reverse=True))
我得到了一个摇滚类型:
Features importance of shaly limestone =
[(32.698676805752939, 'Depth'), (11.437112671467331, 'Gamma Ray'), (7.0256677233376346, 'SP'), (5.2919610063076963, 'Density Correction'), (4.69972333501756, 'Resistivity (Deep)'), (4.3250282898616081, 'Caliper '), (3.876972448849632, 'Micro-normal (resistivity) micro-log'), (3.8373287915693957, 'Resistivity (Medium)'), (3.6854852718774076, 'Photoelectric'), (3.6552972972995796, 'Sonic Porosity'), (3.5872666770164936, 'Micro-inverse (resistivity) micro-log'), (3.5667515140079744, 'Delta-t (transit time)'), (2.7913023534006003, 'Resistivity (Shallow)'), (2.714697087901786, 'Neutron Porosity'), (2.4667204236786993, 'Ratio(Shallow/Deep resistivity)'), (2.1928475922610642, 'Density Porosity'), (2.1471607103925967, 'Bulk Density')]
当我只针对一种类型的摇滚乐时,我得到的印刷效果非常顺利:
[(32.698676805752939, 'Depth'),
(11.437112671467331, 'Gamma Ray'),
(7.0256677233376346, 'SP'),
(5.2919610063076963, 'Density Correction'),
(4.69972333501756, 'Resistivity (Deep)'),
(4.3250282898616081, 'Caliper'),
(3.876972448849632, 'Micro-normal (resistivity) micro-log'),
(3.8373287915693957, 'Resistivity (Medium)'),
(3.6854852718774076, 'Photoelctric'),
(3.6552972972995796, 'Sonic Porosity'),
(3.5872666770164936, 'Micro-inverse (resistivity) micro-log'),
(3.5667515140079744, 'Delta-t (transit time)'),
(2.7913023534006003, 'Resistivity (Shallow)'),
(2.714697087901786, 'Neutron Porosity'),
(2.4667204236786993, 'Ratio(Shallow/Deep resistivity)'),
(2.1928475922610642, 'Density Porosity'),
(2.1471607103925967, 'Bulk Density')]
如何让打印的解决方案看起来一样平滑(一行feature_importance
),就像我只得到一种摇滚类型的答案一样?