public void SetTestResults(ClassificationPerformanceMeasuresCalculator testPerformanceCalculator) {
   if (!string.IsNullOrWhiteSpace(ClassificationPositiveClassName)
             && !ClassificationPositiveClassName.Equals(testPerformanceCalculator.PositiveClassName))
     throw new ArgumentException("Classification positive class of the test data doesn't match with the data of training partition.");
   ClassificationPositiveClassName = testPerformanceCalculator.PositiveClassName;
   TestTruePositiveRate = testPerformanceCalculator.TruePositiveRate;
   TestTrueNegativeRate = testPerformanceCalculator.TrueNegativeRate;
   TestPositivePredictiveValue = testPerformanceCalculator.PositivePredictiveValue;
   TestNegativePredictiveValue = testPerformanceCalculator.NegativePredictiveValue;
   TestFalsePositiveRate = testPerformanceCalculator.FalsePositiveRate;
   TestFalseDiscoveryRate = testPerformanceCalculator.FalseDiscoveryRate;
 }
    protected void CalculateClassificationResults() {
      double[] estimatedTrainingClassValues = EstimatedTrainingClassValues.ToArray(); // cache values
      double[] originalTrainingClassValues = ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable, ProblemData.TrainingIndices).ToArray();

      double[] estimatedTestClassValues = EstimatedTestClassValues.ToArray(); // cache values
      double[] originalTestClassValues = ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable, ProblemData.TestIndices).ToArray();

      var positiveClassName = ProblemData.PositiveClass;
      double positiveClassValue = ProblemData.GetClassValue(positiveClassName);
      ClassificationPerformanceMeasuresCalculator trainingPerformanceCalculator = new ClassificationPerformanceMeasuresCalculator(positiveClassName, positiveClassValue);
      ClassificationPerformanceMeasuresCalculator testPerformanceCalculator = new ClassificationPerformanceMeasuresCalculator(positiveClassName, positiveClassValue);

      OnlineCalculatorError errorState;
      double trainingAccuracy = OnlineAccuracyCalculator.Calculate(originalTrainingClassValues, estimatedTrainingClassValues, out errorState);
      if (errorState != OnlineCalculatorError.None) trainingAccuracy = double.NaN;
      double testAccuracy = OnlineAccuracyCalculator.Calculate(originalTestClassValues, estimatedTestClassValues, out errorState);
      if (errorState != OnlineCalculatorError.None) testAccuracy = double.NaN;

      TrainingAccuracy = trainingAccuracy;
      TestAccuracy = testAccuracy;

      double trainingNormalizedGini = NormalizedGiniCalculator.Calculate(originalTrainingClassValues, estimatedTrainingClassValues, out errorState);
      if (errorState != OnlineCalculatorError.None) trainingNormalizedGini = double.NaN;
      double testNormalizedGini = NormalizedGiniCalculator.Calculate(originalTestClassValues, estimatedTestClassValues, out errorState);
      if (errorState != OnlineCalculatorError.None) testNormalizedGini = double.NaN;

      TrainingNormalizedGiniCoefficient = trainingNormalizedGini;
      TestNormalizedGiniCoefficient = testNormalizedGini;

      ClassificationPerformanceMeasures.Reset();

      trainingPerformanceCalculator.Calculate(originalTrainingClassValues, estimatedTrainingClassValues);
      if (trainingPerformanceCalculator.ErrorState == OnlineCalculatorError.None)
        ClassificationPerformanceMeasures.SetTrainingResults(trainingPerformanceCalculator);

      testPerformanceCalculator.Calculate(originalTestClassValues, estimatedTestClassValues);
      if (testPerformanceCalculator.ErrorState == OnlineCalculatorError.None)
        ClassificationPerformanceMeasures.SetTestResults(testPerformanceCalculator);

      if (ProblemData.Classes == 2) {
        var f1Training = FOneScoreCalculator.Calculate(originalTrainingClassValues, estimatedTrainingClassValues, out errorState);
        if (errorState == OnlineCalculatorError.None) ClassificationPerformanceMeasures.TrainingF1Score = f1Training;
        var f1Test = FOneScoreCalculator.Calculate(originalTestClassValues, estimatedTestClassValues, out errorState);
        if (errorState == OnlineCalculatorError.None) ClassificationPerformanceMeasures.TestF1Score = f1Test;
      }

      var mccTraining = MatthewsCorrelationCoefficientCalculator.Calculate(originalTrainingClassValues, estimatedTrainingClassValues, out errorState);
      if (errorState == OnlineCalculatorError.None) ClassificationPerformanceMeasures.TrainingMatthewsCorrelation = mccTraining;
      var mccTest = MatthewsCorrelationCoefficientCalculator.Calculate(originalTestClassValues, estimatedTestClassValues, out errorState);
      if (errorState == OnlineCalculatorError.None) ClassificationPerformanceMeasures.TestMatthewsCorrelation = mccTest;
    }