Free cookie consent management tool by TermsFeed Policy Generator

Changeset 16621


Ignore:
Timestamp:
02/26/19 13:39:59 (5 years ago)
Author:
gkronber
Message:

#2929: changed code to update the best found solution

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2929_PrioritizedGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.PGE/3.3/PGE.cs

    r16620 r16621  
    275275      var iterationsResult = new IntValue(0);
    276276      Results.Add(new Result("Iteration", iterationsResult));
    277       var bestTestScoreResult = new IntValue(0); // TODO: why is test score an int?
    278       Results.Add(new Result("Best test score", bestTestScoreResult));
     277      var bestMSEResult = new DoubleValue();
     278      Results.Add(new Result("Best MSE", bestMSEResult));
    279279      var testScoresTable = new DataTable("Test scores");
    280280      var bestTestScoreRow = new DataRow("Best test score");
     
    294294      Results.Add(bestSolutionResult);
    295295
     296      var allSolutions = new ItemList<IRegressionSolution>();
     297      var allSolutionsResult = new Result("Solutions", allSolutions);
     298      Results.Add(allSolutionsResult);
     299
    296300      // TODO: the following is potentially problematic for other go processes run on the same machine at the same time
    297301      // shouldn't be problematic bc is inherited only, normally only child processes are affected
     
    341345        ProblemTypeString: problemTypeString, numProcs: numProc);
    342346
    343       var bestTestScore = int.MaxValue;
     347      var bestMSE = double.MaxValue;
    344348      for (int iter = 1; iter <= MaxIterations; iter++) {
    345349        iterationsResult.Value = iter;
     
    360364          log.LogMessage("Push/Pop (" + iResult + ", " + testScore + ") " + eqnStr + " coeff: " + string.Join(" ", coeff));
    361365
    362           if (!string.IsNullOrEmpty(eqnStr) && (testScore < bestTestScore)) {
    363             // update best quality
    364             bestTestScore = testScore;
    365             bestTestScoreResult.Value = testScore;
     366          if (!string.IsNullOrEmpty(eqnStr)) {
    366367            var sol = CreateSolution(problemData, eqnStr, coeff, problemData.AllowedInputVariables.ToArray());
    367             bestSolutionResult.Value = sol;
     368            allSolutions.Add(sol);
     369            if (sol.TrainingMeanSquaredError < bestMSE) {
     370              // update best quality
     371              bestMSE = sol.TrainingMeanSquaredError;
     372              bestMSEResult.Value = bestMSE;
     373              bestSolutionResult.Value = sol;
     374            }
    368375          }
    369           bestTestScoreRow.Values.Add(bestTestScoreResult.Value); // always add the current best test score to data row
     376          bestTestScoreRow.Values.Add(bestMSEResult.Value); // always add the current best test score to data row
    370377          curTestScoreRow.Values.Add(testScore);
    371378        }
Note: See TracChangeset for help on using the changeset viewer.