predictLinearSVM function

int predictLinearSVM(
  1. List<double> model,
  2. List<double> x
)

Implementation

int predictLinearSVM(List<double> model, List<double> x) {
  final bias = model[0];
  var dot = bias;
  for (var i = 0; i < x.length && i + 1 < model.length; i++) {
    dot += model[i + 1] * x[i];
  }
  return dot >= 0 ? 1 : -1;
}