【问题标题】:R: how can I find C/C++ source code from the gbm package?R:如何从 gbm 包中找到 C/C++ 源代码?
【发布时间】:2021-01-16 17:38:28
【问题描述】:
library(gbm)
gbm.fit

我运行上面的代码来查看gbm.fit的源代码。看起来函数的“肉”在这一行:

gbm.obj <- .Call("gbm_fit", Y = as.double(y), Offset = as.double(offset), 
                   X = as.double(x), X.order = as.integer(x.order), weights = as.double(w), 
                   Misc = as.double(Misc), cRows = as.integer(cRows), cCols = as.integer(cCols), 
                   var.type = as.integer(var.type), var.monotone = as.integer(var.monotone), 
                   distribution = as.character(distribution.call.name), 
                   n.trees = as.integer(n.trees), interaction.depth = as.integer(interaction.depth), 
                   n.minobsinnode = as.integer(n.minobsinnode), n.classes = as.integer(nClass), 
                   shrinkage = as.double(shrinkage), bag.fraction = as.double(bag.fraction), 
                   nTrain = as.integer(nTrain), fit.old = as.double(NA), 
                   n.cat.splits.old = as.integer(0), n.trees.old = as.integer(0), 
                   verbose = as.integer(verbose), PACKAGE = "gbm")

据我所知,.Call 正在将一个 R 对象传递给 C/C++ 代码。我对有一个名为gbm_fit 的 C/C++ 函数吗?我究竟在哪里可以找到这个源代码?我试过四处寻找https://rdrr.io/cran/gbm/src/R/gbm.fit.R,但似乎找不到 C/C++ 函数的实际源代码。我也下载了“gbm_2.1.8.tgz”但是找不到源代码。

【问题讨论】:

    标签: r package gbm


    【解决方案1】:

    函数 gbm_fit 的源代码位于文件 gbm-2.1.8.tar.gz 的 src/gbmentry.cpp 中(不是 tgz 文件;即 macOS 二进制文件)。这个文件可以是 GitHub 上的viewed online

    【讨论】:

      猜你喜欢
      • 2016-11-13
      • 1970-01-01
      • 1970-01-01
      • 2010-12-01
      相关资源
      最近更新 更多