1

I want to create an XGDMatrix from a C++ 2D vector. My data inputs are in a vector<vector<float>> and I do not want to convert them into a 2D float array to be able to use XGDMatrixCreateFromMat (https://github.com/dmlc/xgboost/blob/master/include/xgboost/c_api.h#L177). Is there a way to use an iterator to the vector to construct XGDMatrix?

I was looking through the APIs in https://github.com/dmlc/xgboost/blob/master/include/xgboost/c_api.h and came across XGDMatrixCreateFromDataIter https://github.com/dmlc/xgboost/blob/master/include/xgboost/c_api.h#L12. But I do not know how to use it, can someone help with an example to use XGDMatrixCreateFromDataIter?

I want to load the data the same way in https://stackoverflow.com/a/45790765. However, instead of loading the data from a float[][], I want to load it from vector<vector<float>> without converting the 2D vector to a 2D float array.

Rahman
  • 21
  • 4

0 Answers0