Free cookie consent management tool by TermsFeed Policy Generator

Changeset 17824 for trunk


Ignore:
Timestamp:
01/21/21 09:40:33 (4 years ago)
Author:
gkronber
Message:

#3099: set estimation limits in CV folds to original values.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/HeuristicLab.Algorithms.DataAnalysis/3.4/CrossValidation.cs

    r17180 r17824  
    3535using HeuristicLab.Problems.DataAnalysis.Symbolic;
    3636using HeuristicLab.Random;
     37using HeuristicLab.Problems.DataAnalysis.Symbolic.Regression;
     38using HeuristicLab.Problems.DataAnalysis.Symbolic.Classification;
    3739
    3840namespace HeuristicLab.Algorithms.DataAnalysis {
     
    338340              symbolicProblem.FitnessCalculationPartition.End = SamplesEnd.Value;
    339341            }
     342
     343            // We need to set the estimation limits because they are recalculated by the problem
     344            // whenever the data partitions change.
     345            // Instead of explicitly handling all types we could also check the parameters-collection
     346            // for a parameter with name "EstimationLimits".
     347            SetEstimationLimits(problem, new[] { typeof(SymbolicRegressionSingleObjectiveProblem),
     348                                                 typeof(SymbolicRegressionMultiObjectiveProblem),
     349                                                 typeof(SymbolicClassificationSingleObjectiveProblem),
     350                                                 typeof(SymbolicClassificationMultiObjectiveProblem) });
     351
    340352            clonedAlgorithm.Prepare();
    341353            clonedAlgorithms.Add(clonedAlgorithm);
     
    809821    }
    810822    #endregion
     823
     824    #region helper
     825
     826    private void SetEstimationLimits(IDataAnalysisProblem problem, Type[] types) {
     827      foreach (var type in types) {
     828        if (type.IsAssignableFrom(problem.GetType())) {
     829          var originalLimits = (DoubleLimit)Problem.Parameters["EstimationLimits"].ActualValue;  // problem is a clone of Problem
     830          var limits = (DoubleLimit)problem.Parameters["EstimationLimits"].ActualValue;
     831          limits.Lower = originalLimits.Lower;
     832          limits.Upper = originalLimits.Upper;
     833        }
     834      }
     835    }
     836
     837    #endregion
    811838  }
    812839}
  • trunk/HeuristicLab.Tests/HeuristicLab.Algorithms.DataAnalysis-3.4/CrossValidationTest.cs

    r17823 r17824  
    2121
    2222using System.Linq;
    23 using HeuristicLab.Data;
    2423using HeuristicLab.Optimization;
    2524using HeuristicLab.Problems.DataAnalysis;
     
    5857      IResult cvFoldsResult;
    5958      Assert.IsTrue(cv.Results.TryGetValue("CrossValidation Folds", out cvFoldsResult));
    60       var runs = ((RunCollection)cvFoldsResult.Value);
     59      var runs = (RunCollection)cvFoldsResult.Value;
    6160      var foldEstimationLimits = (DoubleLimit)runs.First().Parameters["EstimationLimits"];
    6261
Note: See TracChangeset for help on using the changeset viewer.