Ask Your Question

Revision history [back]

click to hide/show revision 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:

  1. Load your variables to the trainData matrix of CV_32FC1 type, each row of which is a one sample variables;
  2. Set tflag to CV_ROW_SAMPLE. It means that the each sample variables are located on the row in trainData.
  3. Load your vector of responses yi to the 'responses' matrix of CV_32FC1 type.
  4. Pass empty matrices for varIdx and sampleIdx parameters. That means that all variables and all samples will used in the training.
  5. 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].
  6. Set empty mask for missingDataMask parameter if there are not missing values in your sample variables.
  7. 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.

click to hide/show revision 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:

  1. Load your variables to the trainData matrix of CV_32FC1 type, each row of which is a one sample variables;
  2. Set tflag to CV_ROW_SAMPLE. It means that the each sample variables are located on the row in trainData.
  3. Load your vector of responses yi to the 'responses' matrix of CV_32FC1 type.
  4. Pass empty matrices for varIdx and sampleIdx parameters. That means that all variables and all samples will used in the training.
  5. 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].
  6. Set empty mask for missingDataMask parameter if there are not missing values in your sample variables.
  7. 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.