public static double calculateRegressionError(MLRegression method, MLDataSet data) {

    final ErrorCalculation errorCalculation = new ErrorCalculation();
    if (method instanceof MLContext) ((MLContext) method).clearContext();

    for (final MLDataPair pair : data) {
      final MLData actual = method.compute(pair.getInput());
      errorCalculation.updateError(
          actual.getData(), pair.getIdeal().getData(), pair.getSignificance());
    }
    return errorCalculation.calculate();
  }
 /**
  * Evaluate the network and display (to the console) the output for every value in the training
  * set. Displays ideal and actual.
  *
  * @param network The network to evaluate.
  * @param training The training set to evaluate.
  */
 public static void evaluate(final MLRegression network, final MLDataSet training) {
   for (final MLDataPair pair : training) {
     final MLData output = network.compute(pair.getInput());
     System.out.println(
         "Input="
             + EncogUtility.formatNeuralData(pair.getInput())
             + ", Actual="
             + EncogUtility.formatNeuralData(output)
             + ", Ideal="
             + EncogUtility.formatNeuralData(pair.getIdeal()));
   }
 }