code: public static double ssReg(double[] residuals, double[] targetAttribute) {
          double mean = sum(targetAttribute) / targetAttribute.length;
          double ret = 0;
          for (int i = 0; i < residuals.length; i++) {
              ret += Math.pow(residuals[i] - mean, 2);
          }
          return ret;
      }
docs: How much of the variance is explained by the regression
  @param residuals error
  @param targetAttribute data for target attribute
  @return the sum squares of regression