/// <summary> /// Run the example. /// </summary> public void Process() { IErrorCalculation calcEss = new ErrorCalculationSSE(); IErrorCalculation calcMse = new ErrorCalculationMSE(); IErrorCalculation calcRms = new ErrorCalculationRMS(); DataHolder smallErrors = Generate(Seed, Rows, Cols, Low, High, 0.1); DataHolder mediumErrors = Generate(Seed, Rows, Cols, Low, High, 0.5); DataHolder largeErrors = Generate(Seed, Rows, Cols, Low, High, 1.0); DataHolder hugeErrors = Generate(Seed, Rows, Cols, Low, High, 10.0); double smallEss = smallErrors.CalculateError(calcEss); double smallMse = smallErrors.CalculateError(calcMse); double smallRms = smallErrors.CalculateError(calcRms); double mediumEss = mediumErrors.CalculateError(calcEss); double mediumMse = mediumErrors.CalculateError(calcMse); double mediumRms = mediumErrors.CalculateError(calcRms); double largeEss = largeErrors.CalculateError(calcEss); double largeMse = largeErrors.CalculateError(calcMse); double largeRms = largeErrors.CalculateError(calcRms); double hugeEss = hugeErrors.CalculateError(calcEss); double hugeMse = hugeErrors.CalculateError(calcMse); double hugeRms = hugeErrors.CalculateError(calcRms); Console.WriteLine("Type\tESS\tMSE\tRMS"); Console.WriteLine("Small\t" + (int)smallEss + "\t" + smallMse.ToString("0.0000") + "\t" + smallRms.ToString("0.0000")); Console.WriteLine("Medium\t" + (int)mediumEss + "\t" + mediumMse.ToString("0.0000") + "\t" + mediumRms.ToString("0.0000")); Console.WriteLine("Large\t" + (int)largeEss + "\t" + largeMse.ToString("0.0000") + "\t" + largeRms.ToString("0.0000")); Console.WriteLine("Huge\t" + (int)hugeEss + "\t" + hugeMse.ToString("0.0000") + "\t" + hugeRms.ToString("0.0000")); }
public void PerformTraining(ILearningMethod method, object model, IEnumerable validationData) { IRegressionAlgorithm regression = model as IRegressionAlgorithm; if (regression != null) { IErrorCalculation errorCalc; switch (ErrorCalculation) { case ErrorCaclulationType.MeanSquare: errorCalc = new ErrorCalculationMSE(); break; case ErrorCaclulationType.RootMeanSquare: errorCalc = new ErrorCalculationRMS(); break; case ErrorCaclulationType.SumOfSquares: errorCalc = new ErrorCalculationSSE(); break; default: throw new ArgumentOutOfRangeException(); } new SimpleLearn().PerformIterationsEarlyStop(method, regression, (IList <BasicData>)validationData, Tolerate, errorCalc); } else { IClassificationAlgorithm classification = (IClassificationAlgorithm)model; new SimpleLearn().PerformIterationsClassifyEarlyStop(method, classification, (IList <BasicData>)validationData, Tolerate); } }
public void TestErrorCalc() { IErrorCalculation calc = new ErrorCalculationRMS(); double result = ErrorTestingUtil.CalculateError( calc, ErrorTestingUtil.Actual, ErrorTestingUtil.Ideal); Assert.AreEqual(12.3134, result, 0.001); }