Merge pull request #5281 from ilya-lavrenov:ml2

pull/5297/head
Alexander Alekhin 9 years ago
commit ae0d428b62
  1. 8
      modules/ml/src/gbt.cpp

@ -1292,13 +1292,18 @@ CvGBTrees::calc_error( CvMLData* _data, int type, std::vector<float> *resp )
return -FLT_MAX;
float* pred_resp = 0;
bool needsFreeing = false;
if (resp)
{
resp->resize(n);
pred_resp = &((*resp)[0]);
}
else
{
pred_resp = new float[n];
needsFreeing = true;
}
Sample_predictor predictor = Sample_predictor(this, pred_resp, _data->get_values(),
_data->get_missing(), _sample_idx);
@ -1331,6 +1336,9 @@ CvGBTrees::calc_error( CvMLData* _data, int type, std::vector<float> *resp )
err = err / (float)n;
}
if (needsFreeing)
delete[]pred_resp;
return err;
}

Loading…
Cancel
Save