【问题标题】:gbm.interactions for gbm.fixedgbm.fixed 的 gbm.interactions
【发布时间】:2017-11-01 09:37:47
【问题描述】:

如何获得使用固定 n.trees 计算的 gbm 的交互评估? 我试过了:

data(Anguilla_train)
angaus.fixed <- gbm.fixed(data=Anguilla_train, gbm.x = 3:13, 
  gbm.y = 2,family = "bernoulli", tree.complexity = 5, learning.rate = 0.01,
  bag.fraction = 0.5, n.trees = 5000)
find.int <- gbm.interactions(angaus.fixed)

但是:

[.data.frame(pred.frame, , n) 中的 1 个错误:未定义的列 已选中

【问题讨论】:

    标签: r gbm dismo


    【解决方案1】:

    仔细检查dismo::gbm.interactions函数后发现dismo::gbm.fixed返回的对象与gbm.interactions不完全兼容。
    以下是如何修改您的代码:

    library(dismo)  
    data(Anguilla_train)
    angaus.fixed <- gbm.fixed(data=Anguilla_train, gbm.x = 3:13, 
      gbm.y = 2,family = "bernoulli", tree.complexity = 5, learning.rate = 0.01,
      bag.fraction = 0.5, n.trees = 5000)
    
    # Change the name of angaus.fixed$gbm.call$data with angaus.fixed$gbm.call$dataframe
    names(angaus.fixed$gbm.call)[1] <- "dataframe"
    
    find.int <- gbm.interactions(angaus.fixed)
    
    ######
    gbm.interactions - version 2.9
    Cross tabulating interactions for gbm model with 11 predictors
    1 2 3 4 5 6 7 8 9 10
    

    现在gbm.interactions 运行良好并产生以下结果:

    find.int$interactions
    
    #######
               SegSumT SegTSeas SegLowFlow DSDist DSMaxSlope USAvgT USRainDays USSlope USNative DSDam Method
    SegSumT          0    28.35       0.88 150.10      13.20  24.38      30.30   17.85    22.57  0.27  44.68
    SegTSeas         0     0.00      17.66 130.69       7.96  16.93       3.14   18.59    25.90  0.14   4.15
    SegLowFlow       0     0.00       0.00   5.92       3.85   6.88       4.69   10.85     5.06  0.09   6.23
    DSDist           0     0.00       0.00   0.00       2.40  10.68      47.77   41.54     6.82  0.01  11.42
    DSMaxSlope       0     0.00       0.00   0.00       0.00   3.22       2.85    3.80     2.64  0.00   1.25
    USAvgT           0     0.00       0.00   0.00       0.00   0.00       3.08   11.76    24.90  0.04   1.94
    USRainDays       0     0.00       0.00   0.00       0.00   0.00       0.00    4.69    15.26  0.09  18.16
    USSlope          0     0.00       0.00   0.00       0.00   0.00       0.00    0.00    12.08  0.03  19.44
    USNative         0     0.00       0.00   0.00       0.00   0.00       0.00    0.00     0.00  0.02  12.79
    DSDam            0     0.00       0.00   0.00       0.00   0.00       0.00    0.00     0.00  0.00   0.13
    Method           0     0.00       0.00   0.00       0.00   0.00       0.00    0.00     0.00  0.00   0.00
    
    
    find.int$rank.list
    
    #######
      var1.index var1.names var2.index var2.names int.size
    1          4     DSDist          1    SegSumT   150.10
    2          4     DSDist          2   SegTSeas   130.69
    3          7 USRainDays          4     DSDist    47.77
    4         11     Method          1    SegSumT    44.68
    5          8    USSlope          4     DSDist    41.54
    6          7 USRainDays          1    SegSumT    30.30
    

    【讨论】:

    猜你喜欢
    • 2015-07-11
    • 2017-06-09
    • 1970-01-01
    • 1970-01-01
    • 2014-01-30
    • 2011-09-26
    • 2019-12-17
    • 2017-12-26
    • 2015-04-21
    相关资源
    最近更新 更多