code: public double matthewsCorrelation(EvaluationAveraging averaging) {
          int nClasses = confusion().getClasses().size();
          if (averaging == EvaluationAveraging.Macro) {
              double macroMatthewsCorrelation = 0.0;
              for (int i = 0; i < nClasses; i++) {
                  macroMatthewsCorrelation += matthewsCorrelation(i);
              }
              macroMatthewsCorrelation /= nClasses;
              return macroMatthewsCorrelation;
          } else if (averaging == EvaluationAveraging.Micro) {
              long tpCount = 0;
              long fpCount = 0;
              long fnCount = 0;
              long tnCount = 0;
              for (int i = 0; i < nClasses; i++) {
                  tpCount += truePositives.getCount(i);
                  fpCount += falsePositives.getCount(i);
                  fnCount += falseNegatives.getCount(i);
                  tnCount += trueNegatives.getCount(i);
              }
              return EvaluationUtils.matthewsCorrelation(tpCount, fpCount, fnCount, tnCount);
          } else {
              throw new UnsupportedOperationException("Unknown averaging approach: " + averaging);
          }
      }
docs: Calculate the average binary Mathews correlation coefficient, using macro or micro averaging.<br>
  MCC = (TP*TN - FP*FN) / sqrt((TP+FP)(TP+FN)(TN+FP)(TN+FN))<br>
  Note: This is NOT the same as the multi-class Matthews correlation coefficient
  
  @param averaging Averaging approach
  @return Average