evaluate method

void evaluate(
  1. List<List<double>> inputs,
  2. List<List<double>> targets
)

Implementation

}  void evaluate(List<List<double>> inputs, List<List<double>> targets) {
  int correctPredictions = 0;
  for (int i = 0; i < inputs.length; i++) {
    Tensor<Vector> testInput = Tensor<Vector>(inputs[i]);
    Tensor<Vector> pred = predict(testInput) as Tensor<Vector>;
    int result = (pred.value[0] > 0.5) ? 1 : 0;

    if (result == targets[i][0]) {
      correctPredictions++;
    }
  }
  double accuracy = (correctPredictions / inputs.length) * 100;
}