Changeset 15280 for branches/Async/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/SymbolicRegressionSolutionsAnalyzer.cs
- Timestamp:
- 07/23/17 00:52:14 (7 years ago)
- Location:
- branches/Async
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Async
- Property svn:mergeinfo changed
-
branches/Async/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression (added) merged: 13395,13397,13582,13660,13670,13869,13900,13916,13921,13941
- Property svn:mergeinfo changed
-
branches/Async/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4 (added) merged: 13395,13397,13582,13660,13670,13869,13900,13916,13921,13941
- Property svn:mergeinfo changed
-
branches/Async/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/SymbolicRegressionSolutionsAnalyzer.cs
r12012 r15280 27 27 using HeuristicLab.Common; 28 28 using HeuristicLab.Core; 29 using HeuristicLab.Data; 29 30 using HeuristicLab.Operators; 30 31 using HeuristicLab.Optimization; … … 33 34 34 35 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression { 36 [StorableClass] 35 37 public class SymbolicRegressionSolutionsAnalyzer : SingleSuccessorOperator, IAnalyzer { 36 38 private const string ResultCollectionParameterName = "Results"; 37 39 private const string RegressionSolutionQualitiesResultName = "Regression Solution Qualities"; 40 private const string TrainingQualityParameterName = "TrainingRSquared"; 41 private const string TestQualityParameterName = "TestRSquared"; 38 42 39 43 public ILookupParameter<ResultCollection> ResultCollectionParameter { 40 44 get { return (ILookupParameter<ResultCollection>)Parameters[ResultCollectionParameterName]; } 45 } 46 public ILookupParameter<DoubleValue> TrainingQualityParameter { 47 get { return (ILookupParameter<DoubleValue>)Parameters[TrainingQualityParameterName]; } 48 } 49 public ILookupParameter<DoubleValue> TestQualityParameter { 50 get { return (ILookupParameter<DoubleValue>)Parameters[TestQualityParameterName]; } 41 51 } 42 52 … … 55 65 public SymbolicRegressionSolutionsAnalyzer() { 56 66 Parameters.Add(new LookupParameter<ResultCollection>(ResultCollectionParameterName, "The result collection to store the analysis results.")); 67 Parameters.Add(new LookupParameter<DoubleValue>(TrainingQualityParameterName)); 68 Parameters.Add(new LookupParameter<DoubleValue>(TestQualityParameterName)); 69 } 70 71 [StorableHook(HookType.AfterDeserialization)] 72 private void AfterDeserialization() { 73 // BackwardsCompatibility3.3 74 75 #region Backwards compatible code, remove with 3.4 76 if (!Parameters.ContainsKey(TrainingQualityParameterName)) 77 Parameters.Add(new LookupParameter<DoubleValue>(TrainingQualityParameterName)); 78 if (!Parameters.ContainsKey(TestQualityParameterName)) 79 Parameters.Add(new LookupParameter<DoubleValue>(TestQualityParameterName)); 80 #endregion 57 81 } 58 82 … … 66 90 67 91 var dataTable = (DataTable)results[RegressionSolutionQualitiesResultName].Value; 92 93 // only if the parameters are available (not available in old persisted code) 94 ILookupParameter<DoubleValue> trainingQualityParam = null; 95 ILookupParameter<DoubleValue> testQualityParam = null; 96 // store actual names of parameter because it is changed below 97 trainingQualityParam = TrainingQualityParameter; 98 string prevTrainingQualityParamName = trainingQualityParam.ActualName; 99 testQualityParam = TestQualityParameter; 100 string prevTestQualityParamName = testQualityParam.ActualName; 68 101 foreach (var result in results.Where(r => r.Value is IRegressionSolution)) { 69 102 var solution = (IRegressionSolution)result.Value; 70 103 71 var trainingR2 = result.Name + Environment.NewLine + "Training R²";72 if (!dataTable.Rows.ContainsKey(trainingR2 ))73 dataTable.Rows.Add(new DataRow(trainingR2 ));104 var trainingR2Name = result.Name + " Training R²"; 105 if (!dataTable.Rows.ContainsKey(trainingR2Name)) 106 dataTable.Rows.Add(new DataRow(trainingR2Name)); 74 107 75 var testR2 = result.Name + Environment.NewLine + " Test R²";76 if (!dataTable.Rows.ContainsKey(testR2 ))77 dataTable.Rows.Add(new DataRow(testR2 ));108 var testR2Name = result.Name + " Test R²"; 109 if (!dataTable.Rows.ContainsKey(testR2Name)) 110 dataTable.Rows.Add(new DataRow(testR2Name)); 78 111 79 dataTable.Rows[trainingR2].Values.Add(solution.TrainingRSquared); 80 dataTable.Rows[testR2].Values.Add(solution.TestRSquared); 112 dataTable.Rows[trainingR2Name].Values.Add(solution.TrainingRSquared); 113 dataTable.Rows[testR2Name].Values.Add(solution.TestRSquared); 114 115 // also add training and test R² to the scope using the parameters 116 // HACK: we change the ActualName of the parameter to write two variables for each solution in the results collection 117 trainingQualityParam.ActualName = trainingR2Name; 118 trainingQualityParam.ActualValue = new DoubleValue(solution.TrainingRSquared); 119 testQualityParam.ActualName = testR2Name; 120 testQualityParam.ActualValue = new DoubleValue(solution.TestRSquared); 81 121 } 122 123 trainingQualityParam.ActualName = prevTrainingQualityParamName; 124 testQualityParam.ActualName = prevTestQualityParamName; 82 125 83 126 return base.Apply();
Note: See TracChangeset
for help on using the changeset viewer.