public double matthewsCorrelationCoefficient(int classIndex){
  double numTP=numTruePositives(classIndex);
  double numTN=numTrueNegatives(classIndex);
  double numFP=numFalsePositives(classIndex);
  double numFN=numFalseNegatives(classIndex);
  double n=(numTP * numTN) - (numFP * numFN);
  double d=(numTP + numFP) * (numTP + numFN) * (numTN + numFP)* (numTN + numFN);
  d=Math.sqrt(d);
  if (d == 0) {
    d=1;
  }
  return n / d;
}

public double matthewsCorrelationCoefficient ( int classIndex ) { double numTP = numTruePositives ( classIndex ) ; double numTN = numTrueNegatives ( classIndex ) ; double numFP = numFalsePositives ( classIndex ) ; double numFN = numFalseNegatives ( classIndex ) ; double n = ( numTP * numTN ) - ( numFP * numFN ) ; double d = ( numTP + numFP ) * ( numTP + numFN ) * ( numTN + numFP ) * ( numTN + numFN ) ; d = Math . sqrt ( d ) ; if ( d == 0 ) { d = 1 ; } return n / d ; }
calculates the matthews correlation coefficient ( sometimes called phi coefficient ) for the supplied class
