XGBOOST:无法翻转轴的重要性特征图

XGBOOST: Cannot flip the axis' of importance-Features plot

我正在尝试 翻转 轴,以便 Features 位于 X 轴上。以下代码给我一个系统覆盖轴的错误。

    >gplt = xgb.ggplot.importance (importance_matrix = xgb.importance(model =model_xgb) , top_n = 10 , n_clusters = 1 ) 
                                                   +theme(legend.position = "none" , text = element_text(size = 20))

    >gplt +coord_flip()


    #[OUTPUT]:

    Coordinate system already present. Adding new coordinate system, which will replace the existing one.

如果您查看 xgb.ggplot.importance 的代码,您会发现它包含对 coord_flip 的调用,并且调用它两次不会改变任何内容。为了得到你想要的,你可以做

gplt + coord_cartesian()

您仍会看到该消息,但您的轴应该翻转。