Changeset 18022
- Timestamp:
- 07/17/21 19:04:42 (3 years ago)
- Location:
- stable
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
stable
- Property svn:mergeinfo changed
/trunk merged: 17976,17978,18020
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views merged: 17976
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/SymbolicRegressionSolutionErrorCharacteristicsCurveView.cs
r17181 r18022 26 26 using HeuristicLab.Algorithms.DataAnalysis; 27 27 using HeuristicLab.MainForm; 28 using HeuristicLab.PluginInfrastructure; 28 29 using HeuristicLab.Problems.DataAnalysis.Views; 29 30 … … 43 44 private IRegressionSolution CreateLinearRegressionSolution() { 44 45 if (Content == null) throw new InvalidOperationException(); 45 double rmse, cvRmsError;46 46 var problemData = (IRegressionProblemData)ProblemData.Clone(); 47 47 if (!problemData.TrainingIndices.Any()) return null; // don't create an LR model if the problem does not have a training set (e.g. loaded into an existing model) … … 87 87 newProblemData.TestPartition.End = problemData.TestPartition.End; 88 88 89 var solution = LinearRegression.CreateLinearRegressionSolution(newProblemData, out rmse, out cvRmsError); 90 solution.Name = "Baseline (linear subset)"; 91 return solution; 89 try { 90 var solution = LinearRegression.CreateSolution(newProblemData, out _, out _); 91 solution.Name = "Baseline (linear subset)"; 92 return solution; 93 } catch (NotSupportedException e) { 94 ErrorHandling.ShowErrorDialog("Could not create a linear regression solution.", e); 95 } catch (ArgumentException e) { 96 ErrorHandling.ShowErrorDialog("Could not create a linear regression solution.", e); 97 } 98 return null; 92 99 } 93 100 … … 99 106 if (Content.Model.SymbolicExpressionTree.IterateNodesPrefix().OfType<LaggedVariableTreeNode>().Any()) yield break; 100 107 101 yield return CreateLinearRegressionSolution(); 108 var linearRegressionSolution = CreateLinearRegressionSolution(); 109 if (linearRegressionSolution != null) yield return linearRegressionSolution; 102 110 } 103 111 } -
stable/HeuristicLab.Problems.DataAnalysis.Views
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Problems.DataAnalysis.Views merged: 17976,17978,18020
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.DataAnalysis.Views/3.4
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Problems.DataAnalysis.Views/3.4 merged: 17976,17978,18020
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.DataAnalysis.Views/3.4/HeuristicLab.Problems.DataAnalysis.Views-3.4.csproj
r17803 r18022 563 563 <Private>False</Private> 564 564 </ProjectReference> 565 <ProjectReference Include="..\..\HeuristicLab.Problems.DataAnalysis.Symbolic.Regression\3.4\HeuristicLab.Problems.DataAnalysis.Symbolic.Regression-3.4.csproj">566 <Project>{5AC82412-911B-4FA2-A013-EDC5E3F3FCC2}</Project>567 <Name>HeuristicLab.Problems.DataAnalysis.Symbolic.Regression-3.4</Name>568 <Private>False</Private>569 </ProjectReference>570 <ProjectReference Include="..\..\HeuristicLab.Problems.DataAnalysis.Symbolic\3.4\HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj">571 <Project>{3D28463F-EC96-4D82-AFEE-38BE91A0CA00}</Project>572 <Name>HeuristicLab.Problems.DataAnalysis.Symbolic-3.4</Name>573 <Private>False</Private>574 </ProjectReference>575 565 <ProjectReference Include="..\..\HeuristicLab.Problems.DataAnalysis\3.4\HeuristicLab.Problems.DataAnalysis-3.4.csproj"> 576 566 <Project>{DF87C13E-A889-46FF-8153-66DCAA8C5674}</Project> -
stable/HeuristicLab.Problems.DataAnalysis.Views/3.4/Plugin.cs.frame
r17186 r18022 45 45 [PluginDependency("HeuristicLab.Optimizer", "3.3")] 46 46 [PluginDependency("HeuristicLab.Problems.DataAnalysis", "3.4")] 47 [PluginDependency("HeuristicLab.Problems.DataAnalysis.Symbolic.Regression", "3.4")]48 47 [PluginDependency("HeuristicLab.Visualization.ChartControlsExtensions", "3.3")] 49 48 public class HeuristicLabProblemsDataAnalysisViewsPlugin : PluginBase { -
stable/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionErrorCharacteristicsCurveView.cs
r17181 r18022 29 29 using HeuristicLab.MainForm; 30 30 using HeuristicLab.Optimization; 31 using HeuristicLab.PluginInfrastructure; 31 32 32 33 namespace HeuristicLab.Problems.DataAnalysis.Views { … … 74 75 } 75 76 76 private readonly IList<IRegressionSolution> solutions = new List<IRegressionSolution>();77 private readonly List<IRegressionSolution> solutions = new List<IRegressionSolution>(); 77 78 public IEnumerable<IRegressionSolution> Solutions { 78 79 get { return solutions.AsEnumerable(); } … … 101 102 else { 102 103 // recalculate baseline solutions (for symbolic regression models the features used in the model might have changed) 103 solutions.Clear(); // remove all104 solutions.Clear(); 104 105 solutions.Add(Content); // re-add the first solution 105 // and recalculate all other solutions 106 foreach (var sol in CreateBaselineSolutions()) { 107 solutions.Add(sol); 108 } 106 solutions.AddRange(CreateBaselineSolutions()); 109 107 UpdateChart(); 110 108 } … … 114 112 else { 115 113 // recalculate baseline solutions 116 solutions.Clear(); // remove all114 solutions.Clear(); 117 115 solutions.Add(Content); // re-add the first solution 118 // and recalculate all other solutions 119 foreach (var sol in CreateBaselineSolutions()) { 120 solutions.Add(sol); 121 } 116 solutions.AddRange(CreateBaselineSolutions()); 122 117 UpdateChart(); 123 118 } … … 129 124 ReadOnly = Content == null; 130 125 if (Content != null) { 131 // recalculate all solutions132 126 solutions.Add(Content); 133 if (ProblemData.TrainingIndices.Any()) { 134 foreach (var sol in CreateBaselineSolutions()) 135 solutions.Add(sol); 136 // more solutions can be added by drag&drop 137 } 127 solutions.AddRange(CreateBaselineSolutions()); 138 128 } 139 129 UpdateChart(); … … 175 165 UpdateSeries(residuals, solutionSeries); 176 166 177 solutionSeries.ToolTip = "Area over Curve: " + CalculateAreaOverCurve(solutionSeries);167 solutionSeries.ToolTip = "Area over curve: " + CalculateAreaOverCurve(solutionSeries); 178 168 solutionSeries.LegendToolTip = "Double-click to open model"; 179 169 chart.Series.Add(solutionSeries); … … 249 239 protected virtual List<double> GetResiduals(IEnumerable<double> originalValues, IEnumerable<double> estimatedValues) { 250 240 switch (residualComboBox.SelectedItem.ToString()) { 251 case "Absolute error": return originalValues.Zip(estimatedValues, (x, y) => Math.Abs(x - y)) 241 case "Absolute error": 242 return originalValues.Zip(estimatedValues, (x, y) => Math.Abs(x - y)) 252 243 .Where(r => !double.IsNaN(r) && !double.IsInfinity(r)).ToList(); 253 case "Squared error": return originalValues.Zip(estimatedValues, (x, y) => (x - y) * (x - y)) 244 case "Squared error": 245 return originalValues.Zip(estimatedValues, (x, y) => (x - y) * (x - y)) 254 246 .Where(r => !double.IsNaN(r) && !double.IsInfinity(r)).ToList(); 255 247 case "Relative error": … … 289 281 290 282 protected virtual IEnumerable<IRegressionSolution> CreateBaselineSolutions() { 291 yield return CreateConstantSolution(); 292 yield return CreateLinearSolution(); 283 var constantSolution = CreateConstantSolution(); 284 if (constantSolution != null) yield return constantSolution; 285 286 var linearRegressionSolution = CreateLinearSolution(); 287 if (linearRegressionSolution != null) yield return linearRegressionSolution; 293 288 } 294 289 295 290 private IRegressionSolution CreateConstantSolution() { 291 if (!ProblemData.TrainingIndices.Any()) return null; 292 296 293 double averageTrainingTarget = ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable, ProblemData.TrainingIndices).Average(); 297 294 var model = new ConstantModel(averageTrainingTarget, ProblemData.TargetVariable); … … 301 298 } 302 299 private IRegressionSolution CreateLinearSolution() { 303 double rmsError, cvRmsError; 304 var solution = LinearRegression.CreateLinearRegressionSolution((IRegressionProblemData)ProblemData.Clone(), out rmsError, out cvRmsError); 305 solution.Name = "Baseline (linear)"; 306 return solution; 300 try { 301 var solution = LinearRegression.CreateSolution((IRegressionProblemData)ProblemData.Clone(), out _, out _); 302 solution.Name = "Baseline (linear)"; 303 return solution; 304 } catch (NotSupportedException e) { 305 ErrorHandling.ShowErrorDialog("Could not create a linear regression solution.", e); 306 } catch (ArgumentException e) { 307 ErrorHandling.ShowErrorDialog("Could not create a linear regression solution.", e); 308 } 309 return null; 307 310 } 308 311
Note: See TracChangeset
for help on using the changeset viewer.