Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/30/11 14:01:20 (14 years ago)
Author:
mkommend
Message:

#1418: Corrected bugs in CrossValidation when using evolutionary algorithms.

File:
1 edited

Legend:

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

    r5809 r5886  
    3131using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3232using HeuristicLab.Problems.DataAnalysis;
     33using HeuristicLab.Problems.DataAnalysis.Symbolic;
    3334
    3435namespace HeuristicLab.Algorithms.DataAnalysis {
     
    267268        if (clonedAlgorithms.Count == 0) {
    268269          int testSamplesCount = (SamplesEnd.Value - SamplesStart.Value) / Folds.Value;
     270
    269271          for (int i = 0; i < Folds.Value; i++) {
    270272            IAlgorithm clonedAlgorithm = (IAlgorithm)algorithm.Clone();
    271273            clonedAlgorithm.Name = algorithm.Name + " Fold " + i;
    272274            IDataAnalysisProblem problem = clonedAlgorithm.Problem as IDataAnalysisProblem;
    273             problem.ProblemData.TestPartition.End = (i + 1) == Folds.Value ? SamplesEnd.Value : (i + 1) * testSamplesCount + SamplesStart.Value;
    274             problem.ProblemData.TestPartition.Start = (i * testSamplesCount) + SamplesStart.Value;
     275            ISymbolicDataAnalysisProblem symbolicProblem = problem as ISymbolicDataAnalysisProblem;
     276
     277            int testStart = (i * testSamplesCount) + SamplesStart.Value;
     278            int testEnd = (i + 1) == Folds.Value ? SamplesEnd.Value : (i + 1) * testSamplesCount + SamplesStart.Value;
     279
     280            problem.ProblemData.TestPartition.Start = testStart;
     281            problem.ProblemData.TestPartition.End = testEnd;
     282            DataAnalysisProblemData problemData = problem.ProblemData as DataAnalysisProblemData;
     283            if (problemData != null) {
     284              problemData.TrainingPartitionParameter.Hidden = false;
     285              problemData.TestPartitionParameter.Hidden = false;
     286            }
     287
     288            if (symbolicProblem != null) {
     289              symbolicProblem.FitnessCalculationPartition.Start = SamplesStart.Value;
     290              symbolicProblem.FitnessCalculationPartition.End = SamplesEnd.Value;
     291            }
     292
    275293            clonedAlgorithms.Add(clonedAlgorithm);
    276294          }
     
    447465        Problem.ProblemDataChanged += (object sender, EventArgs e) => OnProblemChanged();
    448466        SamplesEnd.Value = Problem.ProblemData.Dataset.Rows;
     467
     468        DataAnalysisProblemData problemData = Problem.ProblemData as DataAnalysisProblemData;
     469        if (problemData != null) {
     470          problemData.TrainingPartitionParameter.Hidden = true;
     471          problemData.TestPartitionParameter.Hidden = true;
     472        }
     473        ISymbolicDataAnalysisProblem symbolicProblem = Problem as ISymbolicDataAnalysisProblem;
     474        if (symbolicProblem != null) {
     475          symbolicProblem.FitnessCalculationPartitionParameter.Hidden = true;
     476          symbolicProblem.FitnessCalculationPartition.Start = SamplesStart.Value;
     477          symbolicProblem.FitnessCalculationPartition.End = SamplesEnd.Value;
     478          symbolicProblem.ValidationPartitionParameter.Hidden = true;
     479          symbolicProblem.ValidationPartition.Start = 0;
     480          symbolicProblem.ValidationPartition.End = 0;
     481        }
    449482      } else
    450483        SamplesEnd.Value = 0;
Note: See TracChangeset for help on using the changeset viewer.