【发布时间】:2018-05-03 21:48:24
【问题描述】:
根据文档, http://xgboost.readthedocs.io/en/latest/python/python_api.html 如果我们要定义自定义目标函数,它应该有签名
objective(y_true, y_pred) -> grad, hess
在哪里
hess: array_like of shape [n_samples]
The value of the second derivative for each sample point
但是,如果我们有损失函数,取决于 N 个变量,我们应该有 NxN 的二阶导数矩阵,但我们的 hess 的形状只有 Nx1。我们应该排除“交叉变量”衍生品吗?或者还有什么?
【问题讨论】:
-
gist.github.com/ytsaig/a596feec53d2a024ac69f5ae5a83d8f7 这是一个多类示例,可能会回答您的问题。是的,它们必须被排除,只有 d^2F / d^2Ni 是相关的,而不是交叉变量 (d^2F / dNidNj)
-
哦,这里是 XGBoosts logreg 示例:github.com/dmlc/xgboost/blob/master/demo/guide-python/…
标签: python xgboost custom-function hessian hessian-matrix