I cannot see how XGBoost's predict method makes predictions using more than one feature.
library(xgboost)
library(MASS)
sp500=data.frame(SP500)
label=sp500[,1]
lag1=sp500[-1,]
lag2=lag1[-1]
lag3=lag2[-1]
train=cbind(lag1,lag2,lag3)
model=xgboost(data=train[50:1000,],label=label[50:1000],
objective="reg:linear",booster="gbtree",nround=50)
predict(model,train[1,]) #returns an error, because it will not accept multiple columns
predict(model,t(train[1,]))
transposing my test set does not return an error, however this is incorrectly using the predictors because
predict(model,t(train[1:5,]))
only predicts three values instead of the expected five
So my question is, how can I make predictions with XGBoost using the same features as were used to build the model? In this example I built a model with three features, lag1, lag2, and lag3, to predict the response, return. But when attempting to make predictions using predict
, the function behaves as if it only will use one feature, and if it uses multiple values like when I transposed the test set, it is unknown how it is making use of these values.