Ask Your Question

Revision history [back]

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" ;

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;

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

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

Mat predictionTraits(1, 250, CV_32FC1);

CV_32FC1);

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

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

}

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

;