I've built the following model, but can't work out how to implement it in xgboost.
I'm trying to approximate probabilities within a given portfolio using an existing spreadsheet as the basis (initial y_test values).
Assuming I have split my dataset into data tables train_db and test_db:
oos_error <- Inf
repeat {
rf <-
train(
train_dt[, .(<x values>)],
train_dt[, y / y_test],
weights = train_dt$WEIGHTS,
preProcess = c("center", "scale"),
method = "rpart2",
tuneGrid = expand.grid(maxdepth = 2)
)
train_dt[, y_test := 0.99 * y_test + 0.01 * y_test * predict(rf, newdata = train_dt)]
test_dt[, y_test := 0.99 * y_test + 0.01 * y_test * predict(rf, newdata = test_dt)]
oos_error_prev <- oos_error
oos_error <- test_dt[, LOSS_FUNCTION(.)] ## Residual squared error
if (oos_error > oos_error_prev) {
break()
}
}
When trying to construct my train_dt xgb.DMatrix input, I'm not sure what to put as the input, since what is trying to be predicted is based on the previous input.