【问题标题】:XGBOOST: Cannot flip the axis' of importance-Features plotXGBOOST:不能翻转轴的重要性 - 特征图
【发布时间】:2019-11-23 05:58:17
【问题描述】:

我正在尝试翻转轴,使 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.

【问题讨论】:

    标签: r ggplot2 xgboost


    【解决方案1】:

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

    gplt + coord_cartesian()
    

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

    【讨论】:

      猜你喜欢
      • 2019-12-13
      • 2017-01-15
      • 2019-04-15
      • 2020-11-13
      • 2020-08-20
      • 1970-01-01
      • 2020-03-17
      • 2022-01-19
      • 2019-12-19
      相关资源
      最近更新 更多