public static int ComputeNumberOfErrors(SparseMatrix Dt, SparseMatrix y) { if (Dt.nCols != y.nCols) { throw new Exception("The numbers of samples from label and prediction do not match."); } int nTotError = 0; int[] PredictedClass = y.IndexOfVerticalMax(); for (int IdxCol = 0; IdxCol < Dt.nCols; IdxCol++) { if (Dt.SparseColumnVectors[IdxCol].Key[0] != PredictedClass[IdxCol]) { nTotError++; } } return nTotError; }