Free cookie consent management tool by TermsFeed Policy Generator

Changeset 5882


Ignore:
Timestamp:
03/30/11 13:14:12 (14 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.

Location:
trunk/sources
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/SingleObjective/SymbolicClassificationSingleObjectiveOverfittingAnalyzer.cs

    r5858 r5882  
    2828using HeuristicLab.Parameters;
    2929using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     30using System.Collections.Generic;
    3031
    3132namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Classification {
     
    7677      double[] trainingQuality = QualityParameter.ActualValue.Select(x => x.Value).ToArray();
    7778      // evaluate on validation partition
    78       int start = ValidationPartitionParameter.ActualValue.Start;
    79       int end = ValidationPartitionParameter.ActualValue.End;
    80       var rows = Enumerable.Range(start, end - start);
    81       if (!rows.Any()) return base.Apply();
     79      IEnumerable<int> rows = GenerateRowsToEvaluate();
     80      if (rows.Count() <= 0) return base.Apply();
    8281
    8382      IExecutionContext childContext = (IExecutionContext)ExecutionContext.CreateChildOperation(EvaluatorParameter.ActualValue);
    84       double[] validationQuality = (from tree in SymbolicExpressionTrees
     83      double[] validationQuality = (from tree in SymbolicExpressionTree
    8584                                    select EvaluatorParameter.ActualValue.Evaluate(childContext, tree, ProblemDataParameter.ActualValue, rows))
    8685                                   .ToArray();
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/SymbolicRegressionSingleObjectiveOverfittingAnalyzer.cs

    r5858 r5882  
    2828using HeuristicLab.Parameters;
    2929using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     30using System.Collections.Generic;
    3031
    3132namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression {
     
    7475
    7576    public override IOperation Apply() {
     77      IEnumerable<int> rows = GenerateRowsToEvaluate();
     78      if (rows.Count() <= 0) return base.Apply();
     79
    7680      double[] trainingQuality = QualityParameter.ActualValue.Select(x => x.Value).ToArray();
    7781      // evaluate on validation partition
    78       int start = ValidationPartitionParameter.ActualValue.Start;
    79       int end = ValidationPartitionParameter.ActualValue.End;
    80       var rows = Enumerable.Range(start, end - start);
    81       if (!rows.Any()) return base.Apply();
    82 
    8382      IExecutionContext childContext = (IExecutionContext)ExecutionContext.CreateChildOperation(EvaluatorParameter.ActualValue);
    84       double[] validationQuality = (from tree in SymbolicExpressionTrees
     83      double[] validationQuality = (from tree in SymbolicExpressionTree
    8584                                    select EvaluatorParameter.ActualValue.Evaluate(childContext, tree, ProblemDataParameter.ActualValue, rows))
    8685                                   .ToArray();
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisAnalyzer.cs

    r5809 r5882  
    4949    #endregion
    5050    #region properties
    51     public ItemArray<ISymbolicExpressionTree> SymbolicExpressionTrees {
     51    public ItemArray<ISymbolicExpressionTree> SymbolicExpressionTree {
    5252      get { return SymbolicExpressionTreeParameter.ActualValue; }
    5353    }
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisMultiObjectiveTrainingBestSolutionAnalyzer.cs

    r5809 r5882  
    8787      #region find best trees
    8888      IList<int> nonDominatedIndexes = new List<int>();
    89       ISymbolicExpressionTree[] tree = SymbolicExpressionTrees.ToArray();
     89      ISymbolicExpressionTree[] tree = SymbolicExpressionTree.ToArray();
    9090      List<double[]> qualities = Qualities.Select(x => x.ToArray()).ToList();
    9191      bool[] maximization = Maximization.ToArray();
  • 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}
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisMultiObjectiveValidationBestSolutionAnalyzer.cs

    r5809 r5882  
    7575
    7676    public override IOperation Apply() {
    77       int start = ValidationPartitionParameter.ActualValue.Start;
    78       int end = ValidationPartitionParameter.ActualValue.End;
    79       int count = (int)((end - start) * RelativeNumberOfEvaluatedSamplesParameter.ActualValue.Value);
    80       if (count <= 0) return base.Apply();
     77      IEnumerable<int> rows = GenerateRowsToEvaluate();
     78      if (rows.Count() <= 0) return base.Apply();
    8179
    8280      var results = ResultCollection;
     
    9593      #region find best trees
    9694      IList<int> nonDominatedIndexes = new List<int>();
    97       ISymbolicExpressionTree[] tree = SymbolicExpressionTrees.ToArray();
     95      ISymbolicExpressionTree[] tree = SymbolicExpressionTree.ToArray();
    9896      List<double[]> qualities = new List<double[]>();
    9997      bool[] maximization = Maximization.ToArray();
    10098      List<double[]> newNonDominatedQualities = new List<double[]>();
    10199      var evaluator = EvaluatorParameter.ActualValue;
    102       IEnumerable<int> rows = RandomEnumerable.SampleRandomNumbers(start, end, count);
    103100      IExecutionContext childContext = (IExecutionContext)ExecutionContext.CreateChildOperation(evaluator);
    104101      for (int i = 0; i < tree.Length; i++) {
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisSingleObjectiveTrainingBestSolutionAnalyzer.cs

    r5809 r5882  
    7474      double bestQuality = Maximization.Value ? double.NegativeInfinity : double.PositiveInfinity;
    7575      ISymbolicExpressionTree bestTree = null;
    76       ISymbolicExpressionTree[] tree = SymbolicExpressionTrees.ToArray();
     76      ISymbolicExpressionTree[] tree = SymbolicExpressionTree.ToArray();
    7777      double[] quality = Quality.Select(x => x.Value).ToArray();
    7878      for (int i = 0; i < tree.Length; i++) {
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisSingleObjectiveValidationAnalyzer.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, ISymbolicDataAnalysisSingleObjectiveEvaluator<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]; }
     
    6674    public SymbolicDataAnalysisSingleObjectiveValidationAnalyzer()
    6775      : base() {
     76      Parameters.Add(new LookupParameter<IRandom>(RandomParameterName, "The random generator."));
    6877      Parameters.Add(new LookupParameter<U>(ProblemDataParameterName, "The problem data of the symbolic data analysis problem."));
    6978      Parameters.Add(new LookupParameter<T>(EvaluatorParameterName, "The operator to use for fitness evaluation on the validation partition."));
     
    7281      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."));
    7382    }
     83
     84    protected IEnumerable<int> GenerateRowsToEvaluate() {
     85      int seed = RandomParameter.ActualValue.Next();
     86      int samplesStart = ValidationPartitionParameter.ActualValue.Start;
     87      int samplesEnd = ValidationPartitionParameter.ActualValue.End;
     88      int testPartitionStart = ProblemDataParameter.ActualValue.TestPartition.Start;
     89      int testPartitionEnd = ProblemDataParameter.ActualValue.TestPartition.End;
     90
     91      if (samplesEnd < samplesStart) throw new ArgumentException("Start value is larger than end value.");
     92      int count = (int)((samplesEnd - samplesStart) * RelativeNumberOfEvaluatedSamplesParameter.ActualValue.Value);
     93      if (count == 0) count = 1;
     94      return RandomEnumerable.SampleRandomNumbers(seed, samplesStart, samplesEnd, count)
     95        .Where(i => i < testPartitionStart || testPartitionEnd <= i);
     96    }
    7497  }
    7598}
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisSingleObjectiveValidationBestSolutionAnalyzer.cs

    r5809 r5882  
    7676      double bestQuality = Maximization.Value ? double.NegativeInfinity : double.PositiveInfinity;
    7777      ISymbolicExpressionTree bestTree = null;
    78       ISymbolicExpressionTree[] tree = SymbolicExpressionTrees.ToArray();
     78      ISymbolicExpressionTree[] tree = SymbolicExpressionTree.ToArray();
    7979      double[] quality = new double[tree.Length];
    8080      var evaluator = EvaluatorParameter.ActualValue;
    81       int start = ValidationPartitionParameter.ActualValue.Start;
    82       int end = ValidationPartitionParameter.ActualValue.End;
    83       int count = (int)((end - start) * RelativeNumberOfEvaluatedSamplesParameter.ActualValue.Value);
    84       if (count <= 0) return base.Apply();
     81      IEnumerable<int> rows = GenerateRowsToEvaluate();
     82      if (rows.Count() <= 0) return base.Apply();
    8583
    86       IEnumerable<int> rows = RandomEnumerable.SampleRandomNumbers(start, end, count);
    8784      IExecutionContext childContext = (IExecutionContext)ExecutionContext.CreateChildOperation(evaluator);
    8885      for (int i = 0; i < tree.Length; i++) {
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interfaces/ISymbolicDataAnalysisValidationAnalyzer.cs

    r5809 r5882  
    2525    where T : class,ISymbolicDataAnalysisEvaluator<U>
    2626    where U : class, IDataAnalysisProblemData {
     27    ILookupParameter<IRandom> RandomParameter { get; }
    2728    ILookupParameter<U> ProblemDataParameter { get; }
    2829    ILookupParameter<T> EvaluatorParameter { get; }
Note: See TracChangeset for help on using the changeset viewer.