Ensure that the response/dependent variable column is not included in the matrix you pass to xgb.DMatrix. The matrix should only contain the feature columns.
Can not use model loaded into workspace
NAW123
16
Reputation points
Hi,
I load a trained model into the workspace using R, and when I use xgboost to predict, it always says:
feature names stored in object and newdata are different
I checked the data for training and test, column names and order are the same, but test data has an extra column as a response/depending variable used for predicted results or compare prediction with it.
Without it, how do you know what to predict?
#modelclk$feature_names
test <- as.matrix(test2)
test$feature_names ***(it says atomic vectors)***
dtest<- xgb.DMatrix(test2, missing=NaN)
pred<- predict(loadedmodel, dtest)
What is wrong?
A.
2 answers
Sort by: Most helpful
-
-
NAW123 16 Reputation points
2024-11-30T00:46:23.17+00:00 Thanks, it works!
For old xxx.model, it always says error use model <- xxx.model. Is there anyway to load it?
Thanks,
N.