Python 优化后的功能名称
这与 在我的例子中,问题在图表中:Python 优化后的功能名称,python,xgboost,Python,Xgboost,这与 在我的例子中,问题在图表中: for importance_type in ('weight', 'gain', 'cover'): print('%s:' % importance_type,bst.get_score(importance_type = importance_type)) node_params = {'shape': 'box', #Green 'style' : 'filled, rounded',
for importance_type in ('weight', 'gain', 'cover'):
print('%s:' % importance_type,bst.get_score(importance_type = importance_type))
node_params = {'shape': 'box', #Green
'style' : 'filled, rounded',
'fillcolor': '#78fcb'}
xgb.to_graphviz(clf_xgb,size = '10,10',condition_node_params= node_params)
graph_data = xgb.to_graphviz(clf_xgb,size = '10,10',condition_node_params=node_params)
graph_data.view(filename= 'xgboost_response')
plt.show()
for importance_type in ('weight', 'gain', 'cover'):
print('%s:' % importance_type,bst.get_score().items(importance_type = importance_type))
我将feature_名称添加为一个内部函数,当我尝试手动添加包含feature名称的“feature_cols”时,出现了一个错误。此代码不显示功能名称
如有任何建议,将不胜感激
*编辑
feature_cols = data_set_sub.columns[0:-1]
X = data_set_sub[feature_cols] # Independent variables - features
y = data_set_sub.New # Dependent variables - class
y = y.to_list()
le = preprocessing.LabelBinarizer()
y = le.fit_transform(y)
#* here goes the training/test split
答案在这里:
按FChm
注意:第一列以0开头,第二列以您的功能名称开头,第三列以功能类型开头:即:“q”/“i”。注意复制品!它们可能会混淆您的结果
加入fmap
xgb.to_graphviz(clf_xgb, size='10,10', condition_node_params=node_params,fmap='feature_map.txt')
graph_data = xgb.to_graphviz(clf_xgb, size='10,10', condition_node_params=node_params,fmap='feature_map.txt')
graph_data.view(filename='xgboost_response2')
plt.show()
你能告诉我你在哪里添加“feature_cols”吗?编辑过,我之前没有显示我是如何手动添加的,它不起作用,所以我猜它也不相关