Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/30/11 13:14:12 (13 years ago)
Author:
gkronber
Message:

#1418 renamed parameter and updated all validation analyzers to leave out test samples if the validation partition overlaps with the test partition.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisMultiObjectiveValidationAnalyzer.cs

    r5809 r5882  
    2020#endregion
    2121
     22using System.Linq;
    2223using HeuristicLab.Common;
    2324using HeuristicLab.Core;
     
    2526using HeuristicLab.Parameters;
    2627using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     28using System.Collections.Generic;
     29using System;
     30using HeuristicLab.Random;
    2731
    2832namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
     
    3539    where T : class, ISymbolicDataAnalysisMultiObjectiveEvaluator<U>
    3640    where U : class, IDataAnalysisProblemData {
     41    private const string RandomParameterName = "Random";
    3742    private const string ProblemDataParameterName = "ProblemData";
    3843    private const string EvaluatorParameterName = "Evaluator";
     
    4247
    4348    #region parameter properties
     49    public ILookupParameter<IRandom> RandomParameter {
     50      get { return (ILookupParameter<IRandom>)Parameters[RandomParameterName]; }
     51    }
    4452    public ILookupParameter<U> ProblemDataParameter {
    4553      get { return (ILookupParameter<U>)Parameters[ProblemDataParameterName]; }
     
    7280      Parameters.Add(new ValueLookupParameter<PercentValue>(RelativeNumberOfEvaluatedSamplesParameterName, "The relative number of samples of the dataset partition, which should be randomly chosen for evaluation between the start and end index."));
    7381    }
     82
     83    protected IEnumerable<int> GenerateRowsToEvaluate() {
     84      int seed = RandomParameter.ActualValue.Next();
     85      int samplesStart = ValidationPartitionParameter.ActualValue.Start;
     86      int samplesEnd = ValidationPartitionParameter.ActualValue.End;
     87      int testPartitionStart = ProblemDataParameter.ActualValue.TestPartition.Start;
     88      int testPartitionEnd = ProblemDataParameter.ActualValue.TestPartition.End;
     89
     90      if (samplesEnd < samplesStart) throw new ArgumentException("Start value is larger than end value.");
     91      int count = (int)((samplesEnd - samplesStart) * RelativeNumberOfEvaluatedSamplesParameter.ActualValue.Value);
     92      if (count == 0) count = 1;
     93      return RandomEnumerable.SampleRandomNumbers(seed, samplesStart, samplesEnd, count)
     94        .Where(i => i < testPartitionStart || testPartitionEnd <= i);
     95    }
    7496  }
    7597}
Note: See TracChangeset for help on using the changeset viewer.