code: public static double correlation(double[] residuals, double targetAttribute[]) {
          double[] predictedValues = new double[residuals.length];
          for (int i = 0; i < predictedValues.length; i++) {
              predictedValues[i] = targetAttribute[i] - residuals[i];
          }
          double ssErr = ssError(predictedValues, targetAttribute);
          double total = ssTotal(residuals, targetAttribute);
          return 1 - (ssErr / total);
      }
docs: Returns the correlation coefficient of two double vectors.
  
  @param residuals residuals
  @param targetAttribute target attribute vector
  
  @return the correlation coefficient or r