public double ValidateWithMse(double[][] validateInput, double[] validateOutput) { var sumSquaredError = 0.0; for (var i = 0; i < validateInput.Length; i++) { var result = Classifier.Classify(validateInput[i]); var finalResult = result.Max(); for (var j = 0; j < result.Length; j++) { if (Math.Abs(result[j] - finalResult) < 0.000001 && Math.Abs(validateOutput[i] - (result.Length - j)) < 0.000001) { sumSquaredError += Math.Pow((1 - finalResult), 2); break; } else if (j == result.Length - 1) { sumSquaredError += 1; } } } return(sumSquaredError / validateInput.Length); }
private int[] GetPredictedValues() { var testInput = dataPreparator.GetTestInput(); var testOutput = dataPreparator.GetTestOutput(); var predicted = new int[testOutput.Length]; for (var i = 0; i < testInput.Length; i++) { var result = classifier.Classify(testInput[i]); var maxResult = result.Max(); var indexOfMax = result.IndexOf(maxResult); for (var j = 0; j < result.Length; j++) { if (indexOfMax == j) { predicted[i] = result.Length - j - 1; } } } return(predicted); }