Changeset 3905 for trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/Analyzers
- Timestamp:
- 06/08/10 17:47:15 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/Analyzers
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/Analyzers/BestSymbolicRegressionSolutionAnalyzer.cs
r3892 r3905 35 35 using HeuristicLab.Problems.DataAnalysis; 36 36 using HeuristicLab.Problems.DataAnalysis.Evaluators; 37 using HeuristicLab.Analysis; 37 38 38 39 namespace HeuristicLab.Problems.DataAnalysis.Regression.Symbolic.Analyzers { … … 43 44 private const string SymbolicExpressionTreeInterpreterParameterName = "SymbolicExpressionTreeInterpreter"; 44 45 private const string BestSolutionInputvariableCountResultName = "Variables used by best solution"; 46 private const string VariableFrequenciesParameterName = "VariableFrequencies"; 47 private const string VariableImpactsResultName = "Integrated variable frequencies"; 45 48 private const string BestSolutionParameterName = "BestSolution"; 46 49 … … 55 58 get { return (ILookupParameter<SymbolicRegressionSolution>)Parameters[BestSolutionParameterName]; } 56 59 } 60 public ILookupParameter<DataTable> VariableFrequenciesParameter { 61 get { return (ILookupParameter<DataTable>)Parameters[VariableFrequenciesParameterName]; } 62 } 57 63 #endregion 58 64 #region properties … … 63 69 get { return SymbolicExpressionTreeParameter.ActualValue; } 64 70 } 71 public DataTable VariableFrequencies { 72 get { return VariableFrequenciesParameter.ActualValue; } 73 } 65 74 #endregion 66 75 … … 69 78 Parameters.Add(new ScopeTreeLookupParameter<SymbolicExpressionTree>(SymbolicExpressionTreeParameterName, "The symbolic expression trees to analyze.")); 70 79 Parameters.Add(new ValueLookupParameter<ISymbolicExpressionTreeInterpreter>(SymbolicExpressionTreeInterpreterParameterName, "The interpreter that should be used for the analysis of symbolic expression trees.")); 80 Parameters.Add(new LookupParameter<DataTable>(VariableFrequenciesParameterName, "The variable frequencies table to use for the calculation of variable impacts")); 71 81 Parameters.Add(new LookupParameter<SymbolicRegressionSolution>(BestSolutionParameterName, "The best symbolic regression solution.")); 82 } 83 84 [StorableHook(HookType.AfterDeserialization)] 85 private void Initialize() { 86 if (!Parameters.ContainsKey(VariableFrequenciesParameterName)) { 87 Parameters.Add(new LookupParameter<DataTable>(VariableFrequenciesParameterName, "The variable frequencies table to use for the calculation of variable impacts")); 88 } 72 89 } 73 90 … … 89 106 if (Results.ContainsKey(BestSolutionInputvariableCountResultName)) { 90 107 Results[BestSolutionInputvariableCountResultName].Value = new IntValue(model.InputVariables.Count()); 108 Results[VariableImpactsResultName].Value = CalculateVariableImpacts(); 91 109 } else { 92 110 Results.Add(new Result(BestSolutionInputvariableCountResultName, new IntValue(model.InputVariables.Count()))); 111 Results.Add(new Result(VariableImpactsResultName, CalculateVariableImpacts())); 93 112 } 94 113 } 95 114 return BestSolutionParameter.ActualValue; 115 } 116 117 private DoubleMatrix CalculateVariableImpacts() { 118 if (VariableFrequencies != null) { 119 var impacts = new DoubleMatrix(VariableFrequencies.Rows.Count, 1, new string[] { "Impact" }, VariableFrequencies.Rows.Select(x => x.Name)); 120 int rowIndex = 0; 121 foreach (var dataRow in VariableFrequencies.Rows) { 122 string variableName = dataRow.Name; 123 double integral = 0; 124 if (dataRow.Values.Count > 1) { 125 double baseline = dataRow.Values.First(); 126 integral = (from value in dataRow.Values 127 select value - baseline) 128 .Sum(); 129 } 130 impacts[rowIndex++, 0] = integral; 131 } 132 return impacts; 133 } else return new DoubleMatrix(1, 1); 96 134 } 97 135 -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/Analyzers/SymbolicRegressionVariableFrequencyAnalyzer.cs
r3774 r3905 60 60 #endregion 61 61 #region properties 62 public DataTable Variable Impacts {62 public DataTable VariableFrequencies { 63 63 get { return VariableFrequenciesParameter.ActualValue; } 64 64 set { VariableFrequenciesParameter.ActualValue = value; } … … 80 80 ResultCollection results = ResultsParameter.ActualValue; 81 81 82 if (Variable Impacts == null) {83 Variable Impacts = new DataTable("Variable frequencies", "Relative frequency of variable references aggregated over the whole population.");82 if (VariableFrequencies == null) { 83 VariableFrequencies = new DataTable("Variable frequencies", "Relative frequency of variable references aggregated over the whole population."); 84 84 // add a data row for each input variable 85 85 foreach (var inputVariable in inputVariables) 86 Variable Impacts.Rows.Add(new DataRow(inputVariable));87 results.Add(new Result("Variable frequencies", Variable Impacts));86 VariableFrequencies.Rows.Add(new DataRow(inputVariable)); 87 results.Add(new Result("Variable frequencies", VariableFrequencies)); 88 88 } 89 89 foreach (var pair in VariableFrequencyAnalyser.CalculateVariableFrequencies(expressions, inputVariables)) { 90 Variable Impacts.Rows[pair.Key].Values.Add(pair.Value);91 results["Variable frequencies"].Value = Variable Impacts;90 VariableFrequencies.Rows[pair.Key].Values.Add(pair.Value); 91 results["Variable frequencies"].Value = VariableFrequencies; 92 92 } 93 93
Note: See TracChangeset
for help on using the changeset viewer.