calcError method

(double, Mat) calcError(
  1. TrainData data,
  2. bool test
)

Computes the error on the training (test false) or test (test true) part of data.

Returns the error (percentage of misclassified samples for classifiers, MSE for regressors) and the predicted responses.

Implementation

(double, Mat) calcError(TrainData data, bool test) {
  final p = calloc<ffi.Float>();
  final resp = Mat.empty();
  try {
    cvRun(() => cml.cv_ml_NormalBayesClassifier_calcError(ref, data.ref, test, resp.ref, p, ffi.nullptr));
    return (p.value, resp);
  } catch (_) {
    resp.dispose();
    rethrow;
  } finally {
    calloc.free(p);
  }
}