Ask Your Question

siso's profile - activity

2013-11-18 21:53:14 -0600 asked a question RandomForest->predict always results 0

I am trying to predict an output from a feature vector. However the following code is always giving a result of 0. I have build a tree and trained it with many input of values 1 and 2 and I have saved this tree in the xml. When I try to predict the answer is always 0. Does anyone have an idea why this could happen ?

CvRTrees *aforest = new CvRTrees;

aforest->load("treeState.xml");

Mat predictionTraits(1, 250, CV_32FC1);

for(uint i = 0; i < featureVector.size(); i++){

    predictionTraits.at<float>(0, i) = featureVector[i];
}

float result = aforest->predict(predictionTraits);
cout << "The result for this gesture has label" << result <<"\n" ;