Changeset 5882
- Timestamp:
- 03/30/11 13:14:12 (14 years ago)
- Location:
- trunk/sources
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/SingleObjective/SymbolicClassificationSingleObjectiveOverfittingAnalyzer.cs
r5858 r5882 28 28 using HeuristicLab.Parameters; 29 29 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 30 using System.Collections.Generic; 30 31 31 32 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Classification { … … 76 77 double[] trainingQuality = QualityParameter.ActualValue.Select(x => x.Value).ToArray(); 77 78 // 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(); 82 81 83 82 IExecutionContext childContext = (IExecutionContext)ExecutionContext.CreateChildOperation(EvaluatorParameter.ActualValue); 84 double[] validationQuality = (from tree in SymbolicExpressionTree s83 double[] validationQuality = (from tree in SymbolicExpressionTree 85 84 select EvaluatorParameter.ActualValue.Evaluate(childContext, tree, ProblemDataParameter.ActualValue, rows)) 86 85 .ToArray(); -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/SymbolicRegressionSingleObjectiveOverfittingAnalyzer.cs
r5858 r5882 28 28 using HeuristicLab.Parameters; 29 29 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 30 using System.Collections.Generic; 30 31 31 32 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression { … … 74 75 75 76 public override IOperation Apply() { 77 IEnumerable<int> rows = GenerateRowsToEvaluate(); 78 if (rows.Count() <= 0) return base.Apply(); 79 76 80 double[] trainingQuality = QualityParameter.ActualValue.Select(x => x.Value).ToArray(); 77 81 // 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 83 82 IExecutionContext childContext = (IExecutionContext)ExecutionContext.CreateChildOperation(EvaluatorParameter.ActualValue); 84 double[] validationQuality = (from tree in SymbolicExpressionTree s83 double[] validationQuality = (from tree in SymbolicExpressionTree 85 84 select EvaluatorParameter.ActualValue.Evaluate(childContext, tree, ProblemDataParameter.ActualValue, rows)) 86 85 .ToArray(); -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisAnalyzer.cs
r5809 r5882 49 49 #endregion 50 50 #region properties 51 public ItemArray<ISymbolicExpressionTree> SymbolicExpressionTree s{51 public ItemArray<ISymbolicExpressionTree> SymbolicExpressionTree { 52 52 get { return SymbolicExpressionTreeParameter.ActualValue; } 53 53 } -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisMultiObjectiveTrainingBestSolutionAnalyzer.cs
r5809 r5882 87 87 #region find best trees 88 88 IList<int> nonDominatedIndexes = new List<int>(); 89 ISymbolicExpressionTree[] tree = SymbolicExpressionTree s.ToArray();89 ISymbolicExpressionTree[] tree = SymbolicExpressionTree.ToArray(); 90 90 List<double[]> qualities = Qualities.Select(x => x.ToArray()).ToList(); 91 91 bool[] maximization = Maximization.ToArray(); -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisMultiObjectiveValidationAnalyzer.cs
r5809 r5882 20 20 #endregion 21 21 22 using System.Linq; 22 23 using HeuristicLab.Common; 23 24 using HeuristicLab.Core; … … 25 26 using HeuristicLab.Parameters; 26 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 using System.Collections.Generic; 29 using System; 30 using HeuristicLab.Random; 27 31 28 32 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { … … 35 39 where T : class, ISymbolicDataAnalysisMultiObjectiveEvaluator<U> 36 40 where U : class, IDataAnalysisProblemData { 41 private const string RandomParameterName = "Random"; 37 42 private const string ProblemDataParameterName = "ProblemData"; 38 43 private const string EvaluatorParameterName = "Evaluator"; … … 42 47 43 48 #region parameter properties 49 public ILookupParameter<IRandom> RandomParameter { 50 get { return (ILookupParameter<IRandom>)Parameters[RandomParameterName]; } 51 } 44 52 public ILookupParameter<U> ProblemDataParameter { 45 53 get { return (ILookupParameter<U>)Parameters[ProblemDataParameterName]; } … … 72 80 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.")); 73 81 } 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 } 74 96 } 75 97 } -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisMultiObjectiveValidationBestSolutionAnalyzer.cs
r5809 r5882 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(); 77 IEnumerable<int> rows = GenerateRowsToEvaluate(); 78 if (rows.Count() <= 0) return base.Apply(); 81 79 82 80 var results = ResultCollection; … … 95 93 #region find best trees 96 94 IList<int> nonDominatedIndexes = new List<int>(); 97 ISymbolicExpressionTree[] tree = SymbolicExpressionTree s.ToArray();95 ISymbolicExpressionTree[] tree = SymbolicExpressionTree.ToArray(); 98 96 List<double[]> qualities = new List<double[]>(); 99 97 bool[] maximization = Maximization.ToArray(); 100 98 List<double[]> newNonDominatedQualities = new List<double[]>(); 101 99 var evaluator = EvaluatorParameter.ActualValue; 102 IEnumerable<int> rows = RandomEnumerable.SampleRandomNumbers(start, end, count);103 100 IExecutionContext childContext = (IExecutionContext)ExecutionContext.CreateChildOperation(evaluator); 104 101 for (int i = 0; i < tree.Length; i++) { -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisSingleObjectiveTrainingBestSolutionAnalyzer.cs
r5809 r5882 74 74 double bestQuality = Maximization.Value ? double.NegativeInfinity : double.PositiveInfinity; 75 75 ISymbolicExpressionTree bestTree = null; 76 ISymbolicExpressionTree[] tree = SymbolicExpressionTree s.ToArray();76 ISymbolicExpressionTree[] tree = SymbolicExpressionTree.ToArray(); 77 77 double[] quality = Quality.Select(x => x.Value).ToArray(); 78 78 for (int i = 0; i < tree.Length; i++) { -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisSingleObjectiveValidationAnalyzer.cs
r5809 r5882 20 20 #endregion 21 21 22 using System.Linq; 22 23 using HeuristicLab.Common; 23 24 using HeuristicLab.Core; … … 25 26 using HeuristicLab.Parameters; 26 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 using System.Collections.Generic; 29 using System; 30 using HeuristicLab.Random; 27 31 28 32 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { … … 35 39 where T : class, ISymbolicDataAnalysisSingleObjectiveEvaluator<U> 36 40 where U : class, IDataAnalysisProblemData { 41 private const string RandomParameterName = "Random"; 37 42 private const string ProblemDataParameterName = "ProblemData"; 38 43 private const string EvaluatorParameterName = "Evaluator"; … … 42 47 43 48 #region parameter properties 49 public ILookupParameter<IRandom> RandomParameter { 50 get { return (ILookupParameter<IRandom>)Parameters[RandomParameterName]; } 51 } 44 52 public ILookupParameter<U> ProblemDataParameter { 45 53 get { return (ILookupParameter<U>)Parameters[ProblemDataParameterName]; } … … 66 74 public SymbolicDataAnalysisSingleObjectiveValidationAnalyzer() 67 75 : base() { 76 Parameters.Add(new LookupParameter<IRandom>(RandomParameterName, "The random generator.")); 68 77 Parameters.Add(new LookupParameter<U>(ProblemDataParameterName, "The problem data of the symbolic data analysis problem.")); 69 78 Parameters.Add(new LookupParameter<T>(EvaluatorParameterName, "The operator to use for fitness evaluation on the validation partition.")); … … 72 81 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.")); 73 82 } 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 } 74 97 } 75 98 } -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisSingleObjectiveValidationBestSolutionAnalyzer.cs
r5809 r5882 76 76 double bestQuality = Maximization.Value ? double.NegativeInfinity : double.PositiveInfinity; 77 77 ISymbolicExpressionTree bestTree = null; 78 ISymbolicExpressionTree[] tree = SymbolicExpressionTree s.ToArray();78 ISymbolicExpressionTree[] tree = SymbolicExpressionTree.ToArray(); 79 79 double[] quality = new double[tree.Length]; 80 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(); 81 IEnumerable<int> rows = GenerateRowsToEvaluate(); 82 if (rows.Count() <= 0) return base.Apply(); 85 83 86 IEnumerable<int> rows = RandomEnumerable.SampleRandomNumbers(start, end, count);87 84 IExecutionContext childContext = (IExecutionContext)ExecutionContext.CreateChildOperation(evaluator); 88 85 for (int i = 0; i < tree.Length; i++) { -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interfaces/ISymbolicDataAnalysisValidationAnalyzer.cs
r5809 r5882 25 25 where T : class,ISymbolicDataAnalysisEvaluator<U> 26 26 where U : class, IDataAnalysisProblemData { 27 ILookupParameter<IRandom> RandomParameter { get; } 27 28 ILookupParameter<U> ProblemDataParameter { get; } 28 29 ILookupParameter<T> EvaluatorParameter { get; }
Note: See TracChangeset
for help on using the changeset viewer.