GBTree Returns Same Value for any sample
Hello,
I am attempting to use the machine learning tool GBTrees in OpenCV. My data wasn't working, so i have generated a simple linear sequence to train the classifier with, this returns the same value on output each time.
std::string dataFileName = "NZ-SQL-Corpus.csv";
TrainingData tData;// = ReadDataSource(dataFileName);
tData.samples = cv::Mat(100,1,CV_32FC1);
tData.samplesMask = cv::Mat::zeros(100,1,CV_8UC1);
tData.responses = cv::Mat::zeros(100,1,CV_32FC1);
for(int i=0;i<tData.samples.rows;i++)
{
tData.samples.at<float>(i,0)=i;
tData.responses.at<float>(i,0)=i;
}
cv::Mat train_data = tData.samples.clone();
cv::Mat mask = tData.samplesMask.clone();
cv::Mat train_resp = tData.responses.clone();
cv::GradientBoostingTreeParams params(CvGBTrees::SQUARED_LOSS, 200, 0.8f, 0.01f, 3, true);
cv::Mat varIdx, sampleIdx, varType;
varType = cv::Mat( train_data.cols+1, 1, CV_8U );
varType.setTo(CV_VAR_CATEGORICAL);
sampleIdx = cv::Mat();
bool trained = gbTree.train(train_data,CV_ROW_SAMPLE,train_resp,varIdx,sampleIdx,varType,mask,params);
TestClassifier(tData);
Results....
The red line is the samples, green line is the responses.
The response value is 18.526666641235352 for any value between 1-100 as a sample.
Any tips?