predict method

Array predict(
  1. Array features
)

Predicted outputs for one sample with featureCount features.

Implementation

Array predict(Array features) {
  if (features.length != featureCount) {
    throw FormatException(
        'expected $featureCount features, got ${features.length}');
  }
  var terms = _terms(features);
  var out = Array.fixed(outputCount, initialValue: 0.0);
  for (var t = 0; t < terms.length; t++) {
    for (var o = 0; o < outputCount; o++) {
      out[o] += coefficients[t][o] * terms[t];
    }
  }
  return out;
}