private void CalculateResults() { ModelLength = Model.SymbolicExpressionTree.Length; ModelDepth = Model.SymbolicExpressionTree.Depth; EstimationLimits.Lower = Model.LowerEstimationLimit; EstimationLimits.Upper = Model.UpperEstimationLimit; TrainingUpperEstimationLimitHits = EstimatedTrainingValues.Count(x => x.IsAlmost(Model.UpperEstimationLimit)); TestUpperEstimationLimitHits = EstimatedTestValues.Count(x => x.IsAlmost(Model.UpperEstimationLimit)); TrainingLowerEstimationLimitHits = EstimatedTrainingValues.Count(x => x.IsAlmost(Model.LowerEstimationLimit)); TestLowerEstimationLimitHits = EstimatedTestValues.Count(x => x.IsAlmost(Model.LowerEstimationLimit)); TrainingNaNEvaluations = Model.Interpreter.GetSymbolicExpressionTreeValues(Model.SymbolicExpressionTree, ProblemData.Dataset, ProblemData.TrainingIndices).Count(double.IsNaN); TestNaNEvaluations = Model.Interpreter.GetSymbolicExpressionTreeValues(Model.SymbolicExpressionTree, ProblemData.Dataset, ProblemData.TestIndices).Count(double.IsNaN); }
protected void CalculateRegressionResults() { double[] estimatedTrainingValues = EstimatedTrainingValues.ToArray(); // cache values double[] originalTrainingValues = ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable, ProblemData.TrainingIndices).ToArray(); double[] estimatedTestValues = EstimatedTestValues.ToArray(); // cache values double[] originalTestValues = ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable, ProblemData.TestIndices).ToArray(); OnlineCalculatorError errorState; double trainingMSE = OnlineMeanSquaredErrorCalculator.Calculate(originalTrainingValues, estimatedTrainingValues, out errorState); TrainingMeanSquaredError = errorState == OnlineCalculatorError.None ? trainingMSE : double.NaN; double testMSE = OnlineMeanSquaredErrorCalculator.Calculate(originalTestValues, estimatedTestValues, out errorState); TestMeanSquaredError = errorState == OnlineCalculatorError.None ? testMSE : double.NaN; double trainingR = OnlinePearsonsRCalculator.Calculate(originalTrainingValues, estimatedTrainingValues, out errorState); TrainingRSquared = errorState == OnlineCalculatorError.None ? trainingR * trainingR : double.NaN; double testR = OnlinePearsonsRCalculator.Calculate(originalTestValues, estimatedTestValues, out errorState); TestRSquared = errorState == OnlineCalculatorError.None ? testR * testR : double.NaN; double trainingNormalizedGini = NormalizedGiniCalculator.Calculate(originalTrainingValues, estimatedTrainingValues, out errorState); if (errorState != OnlineCalculatorError.None) { trainingNormalizedGini = double.NaN; } double testNormalizedGini = NormalizedGiniCalculator.Calculate(originalTestValues, estimatedTestValues, out errorState); if (errorState != OnlineCalculatorError.None) { testNormalizedGini = double.NaN; } TrainingNormalizedGiniCoefficient = trainingNormalizedGini; TestNormalizedGiniCoefficient = testNormalizedGini; }