Changeset 5759 for branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers
- Timestamp:
- 03/19/11 02:22:45 (14 years ago)
- Location:
- branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisMultiObjectiveValidationAnalyzer.cs
r5747 r5759 20 20 #endregion 21 21 22 using System.Collections.Generic;23 using System.Linq;24 22 using HeuristicLab.Common; 25 23 using HeuristicLab.Core; 26 24 using HeuristicLab.Data; 27 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;28 using HeuristicLab.Operators;29 25 using HeuristicLab.Parameters; 30 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 31 using HeuristicLab.Optimization;32 27 33 28 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { … … 43 38 private const string EvaluatorParameterName = "Evaluator"; 44 39 private const string SymbolicDataAnalysisTreeInterpreterParameterName = "SymbolicDataAnalysisTreeInterpreter"; 45 private const string Validation SamplesStartParameterName = "ValidationSamplesStart";46 private const string ValidationSamplesEndParameterName = "ValidationSamplesEnd";40 private const string ValidationPartitionParameterName = "ValidationPartition"; 41 private const string RelativeNumberOfEvaluatedSamplesParameterName = "RelativeNumberOfEvaluatedSamples"; 47 42 48 43 #region parameter properties … … 56 51 get { return (ILookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter>)Parameters[SymbolicDataAnalysisTreeInterpreterParameterName]; } 57 52 } 58 public IValueLookupParameter<Int Value> ValidationSamplesStartParameter {59 get { return (IValueLookupParameter<Int Value>)Parameters[ValidationSamplesStartParameterName]; }53 public IValueLookupParameter<IntRange> ValidationPartitionParameter { 54 get { return (IValueLookupParameter<IntRange>)Parameters[ValidationPartitionParameterName]; } 60 55 } 61 public IValueLookupParameter< IntValue> ValidationSamplesEndParameter {62 get { return (IValueLookupParameter< IntValue>)Parameters[ValidationSamplesEndParameterName]; }56 public IValueLookupParameter<PercentValue> RelativeNumberOfEvaluatedSamplesParameter { 57 get { return (IValueLookupParameter<PercentValue>)Parameters[RelativeNumberOfEvaluatedSamplesParameterName]; } 63 58 } 64 #endregion65 66 #region properties67 public U ProblemData { get { return ProblemDataParameter.ActualValue; } }68 public T Evaluator { get { return EvaluatorParameter.ActualValue; } }69 public ISymbolicDataAnalysisExpressionTreeInterpreter SymbolicDataAnalysisTreeInterpreter { get { return SymbolicDataAnalysisTreeInterpreterParameter.ActualValue; } }70 public IntValue ValidationSamplesStart { get { return ValidationSamplesStartParameter.ActualValue; } }71 public IntValue ValidationSamplesEnd { get { return ValidationSamplesEndParameter.ActualValue; } }72 59 #endregion 73 60 … … 82 69 Parameters.Add(new LookupParameter<T>(EvaluatorParameterName, "The operator to use for fitness evaluation on the validation partition.")); 83 70 Parameters.Add(new LookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter>(SymbolicDataAnalysisTreeInterpreterParameterName, "The interpreter for symbolic data analysis expression trees.")); 84 Parameters.Add(new ValueLookupParameter<Int Value>(ValidationSamplesStartParameterName, "The start index of thevalidation partition."));85 Parameters.Add(new ValueLookupParameter< IntValue>(ValidationSamplesEndParameterName, "The end index of the validation partition."));71 Parameters.Add(new ValueLookupParameter<IntRange>(ValidationPartitionParameterName, "Thes validation partition.")); 72 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.")); 86 73 } 87 74 } -
branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisMultiObjectiveValidationBestSolutionAnalyzer.cs
r5747 r5759 20 20 #endregion 21 21 22 using System; 22 23 using System.Collections.Generic; 23 24 using System.Linq; … … 26 27 using HeuristicLab.Data; 27 28 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 28 using HeuristicLab.Operators;29 29 using HeuristicLab.Optimization; 30 30 using HeuristicLab.Parameters; 31 31 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 32 using System;32 using HeuristicLab.Random; 33 33 34 34 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { … … 75 75 76 76 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(); 81 77 82 var results = ResultCollection; 78 83 // create empty parameter and result values … … 94 99 bool[] maximization = Maximization.ToArray(); 95 100 List<double[]> newNonDominatedQualities = new List<double[]>(); 96 var evaluator = Evaluator; 97 int start = ValidationSamplesStart.Value; 98 int end = ValidationSamplesEnd.Value; 99 IEnumerable<int> rows = Enumerable.Range(start, end - start); 101 var evaluator = EvaluatorParameter.ActualValue; 102 IEnumerable<int> rows = RandomEnumerable.SampleRandomNumbers(start, end, count); 100 103 IExecutionContext childContext = (IExecutionContext)ExecutionContext.CreateChildOperation(evaluator); 101 104 for (int i = 0; i < tree.Length; i++) { 102 qualities.Add(evaluator.Evaluate(childContext, tree[i], ProblemData , rows)); // qualities[i] = ...105 qualities.Add(evaluator.Evaluate(childContext, tree[i], ProblemDataParameter.ActualValue, rows)); // qualities[i] = ... 103 106 if (IsNonDominated(qualities[i], trainingBestQualities, maximization) && 104 107 IsNonDominated(qualities[i], qualities, maximization)) { -
branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisSingleObjectiveValidationAnalyzer.cs
r5747 r5759 20 20 #endregion 21 21 22 using System.Collections.Generic;23 using System.Linq;24 22 using HeuristicLab.Common; 25 23 using HeuristicLab.Core; 26 24 using HeuristicLab.Data; 27 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;28 using HeuristicLab.Operators;29 25 using HeuristicLab.Parameters; 30 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 31 using HeuristicLab.Optimization;32 27 33 28 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { … … 43 38 private const string EvaluatorParameterName = "Evaluator"; 44 39 private const string SymbolicDataAnalysisTreeInterpreterParameterName = "SymbolicDataAnalysisTreeInterpreter"; 45 private const string Validation SamplesStartParameterName = "ValidationSamplesStart";46 private const string ValidationSamplesEndParameterName = "ValidationSamplesEnd";40 private const string ValidationPartitionParameterName = "ValidationPartition"; 41 private const string RelativeNumberOfEvaluatedSamplesParameterName = "RelativeNumberOfEvaluatedSamples"; 47 42 48 43 #region parameter properties … … 56 51 get { return (ILookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter>)Parameters[SymbolicDataAnalysisTreeInterpreterParameterName]; } 57 52 } 58 public IValueLookupParameter<Int Value> ValidationSamplesStartParameter {59 get { return (IValueLookupParameter<Int Value>)Parameters[ValidationSamplesStartParameterName]; }53 public IValueLookupParameter<IntRange> ValidationPartitionParameter { 54 get { return (IValueLookupParameter<IntRange>)Parameters[ValidationPartitionParameterName]; } 60 55 } 61 public IValueLookupParameter< IntValue> ValidationSamplesEndParameter {62 get { return (IValueLookupParameter< IntValue>)Parameters[ValidationSamplesEndParameterName]; }56 public IValueLookupParameter<PercentValue> RelativeNumberOfEvaluatedSamplesParameter { 57 get { return (IValueLookupParameter<PercentValue>)Parameters[RelativeNumberOfEvaluatedSamplesParameterName]; } 63 58 } 64 #endregion65 66 #region properties67 public U ProblemData { get { return ProblemDataParameter.ActualValue; } }68 public T Evaluator { get { return EvaluatorParameter.ActualValue; } }69 public ISymbolicDataAnalysisExpressionTreeInterpreter SymbolicDataAnalysisTreeInterpreter { get { return SymbolicDataAnalysisTreeInterpreterParameter.ActualValue; } }70 public IntValue ValidationSamplesStart { get { return ValidationSamplesStartParameter.ActualValue; } }71 public IntValue ValidationSamplesEnd { get { return ValidationSamplesEndParameter.ActualValue; } }72 59 #endregion 73 60 … … 82 69 Parameters.Add(new LookupParameter<T>(EvaluatorParameterName, "The operator to use for fitness evaluation on the validation partition.")); 83 70 Parameters.Add(new LookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter>(SymbolicDataAnalysisTreeInterpreterParameterName, "The interpreter for symbolic data analysis expression trees.")); 84 Parameters.Add(new ValueLookupParameter<Int Value>(ValidationSamplesStartParameterName, "The start index of thevalidation partition."));85 Parameters.Add(new ValueLookupParameter< IntValue>(ValidationSamplesEndParameterName, "The end index of the validation partition."));71 Parameters.Add(new ValueLookupParameter<IntRange>(ValidationPartitionParameterName, "Thes validation partition.")); 72 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.")); 86 73 } 87 74 } -
branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisSingleObjectiveValidationBestSolutionAnalyzer.cs
r5747 r5759 26 26 using HeuristicLab.Data; 27 27 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 28 using HeuristicLab.Operators;29 28 using HeuristicLab.Optimization; 30 29 using HeuristicLab.Parameters; 31 30 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 31 using HeuristicLab.Random; 32 32 33 33 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { … … 78 78 ISymbolicExpressionTree[] tree = SymbolicExpressionTrees.ToArray(); 79 79 double[] quality = new double[tree.Length]; 80 var evaluator = Evaluator; 81 int start = ValidationSamplesStart.Value; 82 int end = ValidationSamplesEnd.Value; 83 IEnumerable<int> rows = Enumerable.Range(start, end - start); 80 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(); 85 86 IEnumerable<int> rows = RandomEnumerable.SampleRandomNumbers(start, end, count); 84 87 IExecutionContext childContext = (IExecutionContext)ExecutionContext.CreateChildOperation(evaluator); 85 88 for (int i = 0; i < tree.Length; i++) { 86 quality[i] = evaluator.Evaluate(childContext, tree[i], ProblemData , rows);89 quality[i] = evaluator.Evaluate(childContext, tree[i], ProblemDataParameter.ActualValue, rows); 87 90 if (IsBetter(quality[i], bestQuality, Maximization.Value)) { 88 91 bestQuality = quality[i];
Note: See TracChangeset
for help on using the changeset viewer.