- Timestamp:
- 08/01/10 18:08:04 (14 years ago)
- Location:
- trunk/sources
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/Analyzers/BestSymbolicRegressionSolutionAnalyzer.cs
r4068 r4125 124 124 foreach (var dataRow in variableFrequencies.Rows) { 125 125 string variableName = dataRow.Name; 126 double integral = 0; 127 if (dataRow.Values.Count > 1) { 128 double baseline = dataRow.Values.First(); 129 integral = (from value in dataRow.Values 130 select value - baseline) 131 .Sum(); 132 integral /= dataRow.Values.Count; 133 } 134 impacts[rowIndex++, 0] = integral; 126 impacts[rowIndex++, 0] = dataRow.Values.Average(); 135 127 } 136 128 return impacts; -
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/VariableFrequencyAnalyser.cs
r4068 r4125 84 84 85 85 public static IEnumerable<KeyValuePair<string, double>> CalculateVariableFrequencies(IEnumerable<SymbolicExpressionTree> trees, IEnumerable<string> inputVariables) { 86 int totalVariableReferences = 0;87 86 Dictionary<string, double> variableReferencesSum = new Dictionary<string, double>(); 88 87 Dictionary<string, double> variableFrequencies = new Dictionary<string, double>(); … … 94 93 variableReferencesSum[pair.Key] += pair.Value; 95 94 } 96 totalVariableReferences += GetTotalVariableReferencesCount(tree);97 95 } 96 double totalVariableReferences = variableReferencesSum.Values.Sum(); 98 97 foreach (string inputVariable in inputVariables) { 99 double relFreq = variableReferencesSum[inputVariable] / (double)totalVariableReferences;98 double relFreq = variableReferencesSum[inputVariable] / totalVariableReferences; 100 99 variableFrequencies.Add(inputVariable, relFreq); 101 100 } … … 103 102 } 104 103 105 private static int GetTotalVariableReferencesCount(SymbolicExpressionTree tree) {106 return tree.IterateNodesPrefix().OfType<VariableTreeNode>().Count();107 }108 109 104 private static IEnumerable<KeyValuePair<string, int>> GetVariableReferenceCount(SymbolicExpressionTree tree, IEnumerable<string> inputVariables) { 110 105 Dictionary<string, int> references = new Dictionary<string, int>(); 111 var groupedFuns = (from node in tree.IterateNodesPrefix().OfType<VariableTreeNode>() 112 select node.VariableName) 113 .GroupBy(x => x) 114 .Select(g => new { Key = g.Key, Count = g.Count() }) 115 .ToArray(); 106 var variableNames = from node in tree.IterateNodesPrefix().OfType<VariableTreeNode>() 107 select node.VariableName; 116 108 117 foreach (var inputVariable in inputVariables) { 118 var matchingFuns = from g in groupedFuns 119 where g.Key == inputVariable 120 select g.Count; 121 if (matchingFuns.Count() == 0) 122 references.Add(inputVariable, 0); 123 else { 124 references.Add(inputVariable, matchingFuns.Single()); 109 foreach (var variableName in variableNames) { 110 if (!references.ContainsKey(variableName)) { 111 references[variableName] = 1; 112 } else { 113 references[variableName] += 1; 125 114 } 126 115 }
Note: See TracChangeset
for help on using the changeset viewer.