RTrees regression to multiple output responses

asked 2015-11-03 03:02:34 -0500

I am using RTrees for regression. However, I don't find the way to make it work with multiple variables. I am using code similar to the tree_engine.cpp sample.

My features have dimension 300, and I want to do joint regression to 3 output variables, so I have 3 ordered responses per feature vector. For example, 1 data row has indices 0-299=features, 300-302=responses.

I have tried the following settings:

const char* filename = "my_data.csv";
int response_idx = 300;
int response_size = 3;
std::string typespec = "ord[0-302]";

Ptr<TrainData> data = TrainData::loadFromCSV(filename, 0, response_idx, response_idx+response_size, typespec);

However, I get the error:

OpenCV Error: Assertion failed (d == 2 && (sizes[0] == 1 || sizes[1] == 1 || sizes[0]*sizes[1] == 0)) in create, file /Users/xavisuau/Downloads/opencv-3.0-2.0/modules/core/src/matrix.cpp, line 2294
libc++abi.dylib: terminating with uncaught exception of type cv::Exception: /Users/xavisuau/Downloads/opencv-3.0-2.0/modules/core/src/matrix.cpp:2294: error: (-215) d == 2 && (sizes[0] == 1 || sizes[1] == 1 || sizes[0]*sizes[1] == 0) in function create

Which looks quite deep...

Can anyone confirm regression is working using multiple response? Or is this maybe a bug?

Thanks!

edit retag flag offensive close merge delete

Comments

Can you post a line or 2 from your csv file, so we can reproduce the problem?

thdrksdfthmn gravatar imagethdrksdfthmn ( 2015-11-03 06:18:57 -0500 )edit

Did you have the solution? I have the same error.

Nguyen Quoc Khai gravatar imageNguyen Quoc Khai ( 2018-07-11 21:16:40 -0500 )edit

I have the same error. My data: 11.84,5.08,49,32.2,16.5,1.4,12.01,5.09,48,32,14.8,1.25,12.89,5.1,48,31.9,8.6,0.71,13.95,5.11,47,30.8,20.2,1.64,13.75,5.13,45,29.7,38.5,3.27,15.17,5.14,46,30.4,46.8,3.74

Nguyen Quoc Khai gravatar imageNguyen Quoc Khai ( 2018-07-11 21:17:53 -0500 )edit