I am having issue implementing recency-weighting for xgboost training in R (i.e. passing a weight vector to xgb.DMatrix) - although the weighting affects the learning curve readout for the training set, it does not appear to have any impact at all on the actual model produced - performance in the test set is identical. This is very weird but
I can’t seem to get to the bottom of this issue or generate a reproducible example. So instead I would like to pass the Date column of the features to a custom loss function, something like:
custom_loss <- function(preds,dat) {
labels <- getinfo(dat,"label")
dates <- [a vector corresponding to the dates associated with each prediction]
grad = f(dates)*-2*(labels - preds)
hess = f(dates)*2
[where f is an increasing function of the value in dates, so later samples matter more when training]
return(list(grad=grad,hess=hess))
}
So somehow I would need to pass the vector of dates associated with whatever labels are being evaluated by the custom objective function, but I can’t seem to figure out how to do this. Any suggestions?