I would like to reference a column in a xgb.DMatrix and use it in an if condition.
Is it possible to reference elements in a column in an xgb.DMatrix? (I am using the xgboost
package)
Such as:
mat1_xgb[date_created<latest_date,]
where
latest_date is some date in numeric format
mat1_xgb$date_created is a column of dates in numeric formats
Example
In r code:
Matrix_1:
| date_created | val1 | date_closed |
| 17912 |2.3 | 17914 |
| 17913 |2. 5 | 17915 |
| 17932 |2.1 | 17941 |
Then create a for loop where the xgboost model is run using only the dates prior to an increment date:
for(i in seq(2,dim(Matrix_1)[1],1)){
latest_date = Matrix_1[2,date_created]
xgb1_learn = xgboost(data = Matrix_1[date_closed<latest_date], params = params, etc)
data_table_1[i:i+50] = predict(xgb1_learn, Matrix_1[i:i+50])
}
So we train the model only on past datapoints