Changeset 6728
- Timestamp:
- 09/09/11 10:45:50 (13 years ago)
- Location:
- trunk/sources
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/SingleObjective/SymbolicClassificationSingleObjectiveOverfittingAnalyzer.cs
r5907 r6728 76 76 public override IOperation Apply() { 77 77 double[] trainingQuality = QualityParameter.ActualValue.Select(x => x.Value).ToArray(); 78 var problemData = ProblemDataParameter.ActualValue; 79 var evaluator = EvaluatorParameter.ActualValue; 78 80 // evaluate on validation partition 79 81 IEnumerable<int> rows = GenerateRowsToEvaluate(); 80 82 if (!rows.Any()) return base.Apply(); 81 82 IExecutionContext childContext = (IExecutionContext)ExecutionContext.CreateChildOperation(EvaluatorParameter.ActualValue);83 double[] validationQuality = (from tree in SymbolicExpressionTree84 select EvaluatorParameter.ActualValue.Evaluate(childContext, tree, ProblemDataParameter.ActualValue, rows))85 83 IExecutionContext childContext = (IExecutionContext)ExecutionContext.CreateChildOperation(evaluator); 84 double[] validationQuality = SymbolicExpressionTree 85 .AsParallel() 86 .Select(t => evaluator.Evaluate(childContext, t, problemData, rows)) 87 .ToArray(); 86 88 double r = 0.0; 87 89 try { -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/SymbolicRegressionSingleObjectiveOverfittingAnalyzer.cs
r5907 r6728 79 79 80 80 double[] trainingQuality = QualityParameter.ActualValue.Select(x => x.Value).ToArray(); 81 var problemData = ProblemDataParameter.ActualValue; 82 var evaluator = EvaluatorParameter.ActualValue; 81 83 // evaluate on validation partition 82 IExecutionContext childContext = (IExecutionContext)ExecutionContext.CreateChildOperation(EvaluatorParameter.ActualValue); 83 double[] validationQuality = (from tree in SymbolicExpressionTree 84 select EvaluatorParameter.ActualValue.Evaluate(childContext, tree, ProblemDataParameter.ActualValue, rows)) 85 .ToArray(); 84 IExecutionContext childContext = (IExecutionContext)ExecutionContext.CreateChildOperation(evaluator); 85 double[] validationQuality = SymbolicExpressionTree 86 .AsParallel() 87 .Select(t => evaluator.Evaluate(childContext, t, problemData, rows)) 88 .ToArray(); 86 89 double r = 0.0; 87 90 try { -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisAlleleFrequencyAnalyzer.cs
r6503 r6728 70 70 71 71 protected override Allele[] CalculateAlleles(ISymbolicExpressionTree solution) { 72 List<Allele> alleles = new List<Allele>(); 73 74 foreach (var subtree in GetAllSubtreesOfDepth(solution, AlleleTreeDepth)) { 75 alleles.Add(GetAlleleFromSubtreeOfDepth(subtree, AlleleTreeDepth)); 76 } 77 return alleles.ToArray(); 72 return GetAllSubtreesOfDepth(solution, AlleleTreeDepth) 73 .AsParallel() 74 .Select(t => GetAlleleFromSubtreeOfDepth(t, AlleleTreeDepth)) 75 .ToArray(); 78 76 } 79 77 -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisMultiObjectiveValidationBestSolutionAnalyzer.cs
r5907 r6728 93 93 IList<int> nonDominatedIndexes = new List<int>(); 94 94 ISymbolicExpressionTree[] tree = SymbolicExpressionTree.ToArray(); 95 List<double[]> qualities = new List<double[]>();96 95 bool[] maximization = Maximization.ToArray(); 97 96 List<double[]> newNonDominatedQualities = new List<double[]>(); 98 97 var evaluator = EvaluatorParameter.ActualValue; 98 var problemData = ProblemDataParameter.ActualValue; 99 99 IExecutionContext childContext = (IExecutionContext)ExecutionContext.CreateChildOperation(evaluator); 100 101 var qualities = tree 102 .AsParallel() 103 .Select(t => evaluator.Evaluate(childContext, t, problemData, rows)) 104 .ToArray(); 100 105 for (int i = 0; i < tree.Length; i++) { 101 qualities.Add(evaluator.Evaluate(childContext, tree[i], ProblemDataParameter.ActualValue, rows)); // qualities[i] = ...102 106 if (IsNonDominated(qualities[i], trainingBestQualities, maximization) && 103 107 IsNonDominated(qualities[i], qualities, maximization)) { -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisSingleObjectiveValidationBestSolutionAnalyzer.cs
r5907 r6728 76 76 ISymbolicExpressionTree bestTree = null; 77 77 ISymbolicExpressionTree[] tree = SymbolicExpressionTree.ToArray(); 78 double[] quality = new double[tree.Length];79 78 var evaluator = EvaluatorParameter.ActualValue; 79 var problemData = ProblemDataParameter.ActualValue; 80 80 IEnumerable<int> rows = GenerateRowsToEvaluate(); 81 81 if (!rows.Any()) return base.Apply(); 82 82 83 83 IExecutionContext childContext = (IExecutionContext)ExecutionContext.CreateChildOperation(evaluator); 84 var quality = tree 85 .AsParallel() 86 .Select(t => evaluator.Evaluate(childContext, t, problemData, rows)) 87 .ToArray(); 88 84 89 for (int i = 0; i < tree.Length; i++) { 85 quality[i] = evaluator.Evaluate(childContext, tree[i], ProblemDataParameter.ActualValue, rows);86 90 if (IsBetter(quality[i], bestQuality, Maximization.Value)) { 87 91 bestQuality = quality[i]; -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisVariableFrequencyAnalyzer.cs
r6709 r6728 131 131 132 132 public static IEnumerable<KeyValuePair<string, double>> CalculateVariableFrequencies(IEnumerable<ISymbolicExpressionTree> trees, bool aggregateLaggedVariables = true) { 133 Dictionary<string, double> variableFrequencies = new Dictionary<string, double>(); 134 int totalNumberOfSymbols = 0; 135 136 foreach (var tree in trees) { 137 var variableReferences = GetVariableReferences(tree, aggregateLaggedVariables); 138 foreach (var pair in variableReferences) { 139 totalNumberOfSymbols += pair.Value; 140 if (variableFrequencies.ContainsKey(pair.Key)) { 141 variableFrequencies[pair.Key] += pair.Value; 142 } else { 143 variableFrequencies.Add(pair.Key, pair.Value); 144 } 145 } 146 } 133 134 var variableFrequencies = trees 135 .AsParallel() 136 .SelectMany(t => GetVariableReferences(t, aggregateLaggedVariables)) 137 .GroupBy(pair => pair.Key, pair => pair.Value) 138 .ToDictionary(g => g.Key, g => (double)g.Sum()); 139 140 double totalNumberOfSymbols = variableFrequencies.Values.Sum(); 147 141 148 142 foreach (var pair in variableFrequencies)
Note: See TracChangeset
for help on using the changeset viewer.