Passing other recipe roles into model function

I'm building a custom xgBoost parsnip model and I'm hoping to use fields that are not included in the predictors or outcome to create a watchlist. Is it possible to pass other fields through to the model function?

I often build models to make annual predictions on cohorts of students and typically include several past cohorts in the training data with a sliding window of testing data based on cohort to be sure that the model is tested on data that is closer to the actual data that will be used to generate the predictions. This is easy enough to accomplish within the cross-validation resamples, but it seems as though the model would perform better if the validation data within the xgBoost fit was also a more recent cohort rather than a random sample across all the training data (as is the case with the validation argument as currently implemented in Parsnip's xgBoost model. I think the best way to do this would be to pass criteria into the model function so the data could be split for each resample, but the criteria would be based on the cohort field, which isn't one of the predictors.

This isn't possible at the moment. If you'd like us to consider that for future development, could you please open an issue at Issues · tidymodels/parsnip · GitHub with a small illustrative reprex?

For that, we'd need to change how parsnip works with the validation argument to parsnip::xgb_train() and the watchlist as an engine argument.

Thanks for the response! This is helpful to know.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.