This forum is disabled, please visit https://forum.opencv.org

1 | initial version |

CvDTree is suitable for your task. It supports category (so binary too) and ordered variables, classification and regression problems. To build a tree you should use one of the CvDTree::train() methods, see doc. For example, for the first version of train method from the doc you can:

- Load your variables to the trainData matrix of CV_32FC1 type, each row of which is a one sample variables;
- Set tflag to CV_ROW_SAMPLE. It means that the each sample variables are located on the row in trainData.
- Load your vector of responses yi to the 'responses' matrix of CV_32FC1 type.
- Pass empty matrices for varIdx and sampleIdx parameters. That means that all variables and all samples will used in the training.
- Create varType matrix of CV_8UC1 type, rows count = 1, cols count = variable_count + 1 (the last "+1" is for response type). Set CV_VAR_ORDERED (it's 0) and CV_VAR_CATEGORICAL (it's 1) for ordered and categorical variables respectively. For you task it will something like this [1,..1, 0].
- Set empty mask for missingDataMask parameter if there are not missing values in your sample variables.
- Fill 'params'. See doc. It's more complete than the doc for CvDTree::train().

Now you can run training a regression tree for your data.

2 | No.2 Revision |

CvDTree is suitable for your task. It supports category (so binary too) and ordered variables, classification and regression problems. To build a tree you should use one of the CvDTree::train() methods, see doc. For example, for the first version of train method from the doc you can:

- Load your variables to the trainData matrix of CV_32FC1 type, each row of which is a one sample variables;
- Set tflag to CV_ROW_SAMPLE. It means that the each sample variables are located on the row in trainData.
- Load your vector of responses yi to the 'responses' matrix of CV_32FC1 type.
- Pass empty matrices for varIdx and sampleIdx parameters. That means that all variables and all samples will used in the training.
- Create varType matrix of CV_8UC1 type, rows count = 1, cols count = variable_count + 1 (the last "+1" is for response type). Set CV_VAR_ORDERED (it's 0) and CV_VAR_CATEGORICAL (it's 1) for ordered and categorical variables respectively. For you task it will something like this [1,..1, 0].
- Set empty mask for missingDataMask parameter if there are not missing values in your sample variables.
- Fill 'params'. See
~~doc. It's more complete than the doc for CvDTree::train().~~

Now you can run training a regression tree for your data.

Copyright OpenCV foundation, 2012-2018. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.