Hi,
as it is possible to make a customized objective function such as here for binary classification:
logregobj <- function(preds, dtrain) {
labels <- getinfo(dtrain, “label”)
preds <- 1/(1 + exp(-preds))
grad <- preds - labels
hess <- preds * (1 - preds)
return(list(grad = grad, hess = hess))
}
My questions regarding this example is:
-
What is really preds here? It looks like preds are by default logit of predicted probabilities of being in class 1, say. Is this always the case? I can’t find the function where the objective function with “preds” is explicitly used.
-
I don’t understand the computation of grad and hessian. Using minus log likelihood og bernoulli random variables this gives a sum of y*log p + (1-y)log(1-p) (y is 0 or 1, p pred. prob.). Differentiation w.r.t. p (which is what you shoud do, right?) gives gradient (preds-labels)/(preds(1-preds).
Thank you for any replies.