Free cookie consent management tool by TermsFeed Policy Generator

Changeset 18022


Ignore:
Timestamp:
07/17/21 19:04:42 (3 years ago)
Author:
gkronber
Message:

#3125: merged r17976,r17978,r18020 from trunk to stable

Location:
stable
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views

  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/SymbolicRegressionSolutionErrorCharacteristicsCurveView.cs

    r17181 r18022  
    2626using HeuristicLab.Algorithms.DataAnalysis;
    2727using HeuristicLab.MainForm;
     28using HeuristicLab.PluginInfrastructure;
    2829using HeuristicLab.Problems.DataAnalysis.Views;
    2930
     
    4344    private IRegressionSolution CreateLinearRegressionSolution() {
    4445      if (Content == null) throw new InvalidOperationException();
    45       double rmse, cvRmsError;
    4646      var problemData = (IRegressionProblemData)ProblemData.Clone();
    4747      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)
     
    8787      newProblemData.TestPartition.End = problemData.TestPartition.End;
    8888
    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;
    9299    }
    93100
     
    99106      if (Content.Model.SymbolicExpressionTree.IterateNodesPrefix().OfType<LaggedVariableTreeNode>().Any()) yield break;
    100107
    101       yield return CreateLinearRegressionSolution();
     108      var linearRegressionSolution = CreateLinearRegressionSolution();
     109      if (linearRegressionSolution != null) yield return linearRegressionSolution;
    102110    }
    103111  }
  • stable/HeuristicLab.Problems.DataAnalysis.Views

  • stable/HeuristicLab.Problems.DataAnalysis.Views/3.4

  • stable/HeuristicLab.Problems.DataAnalysis.Views/3.4/HeuristicLab.Problems.DataAnalysis.Views-3.4.csproj

    r17803 r18022  
    563563      <Private>False</Private>
    564564    </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>
    575565    <ProjectReference Include="..\..\HeuristicLab.Problems.DataAnalysis\3.4\HeuristicLab.Problems.DataAnalysis-3.4.csproj">
    576566      <Project>{DF87C13E-A889-46FF-8153-66DCAA8C5674}</Project>
  • stable/HeuristicLab.Problems.DataAnalysis.Views/3.4/Plugin.cs.frame

    r17186 r18022  
    4545  [PluginDependency("HeuristicLab.Optimizer", "3.3")]
    4646  [PluginDependency("HeuristicLab.Problems.DataAnalysis", "3.4")]
    47   [PluginDependency("HeuristicLab.Problems.DataAnalysis.Symbolic.Regression", "3.4")]
    4847  [PluginDependency("HeuristicLab.Visualization.ChartControlsExtensions", "3.3")]
    4948  public class HeuristicLabProblemsDataAnalysisViewsPlugin : PluginBase {
  • stable/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionErrorCharacteristicsCurveView.cs

    r17181 r18022  
    2929using HeuristicLab.MainForm;
    3030using HeuristicLab.Optimization;
     31using HeuristicLab.PluginInfrastructure;
    3132
    3233namespace HeuristicLab.Problems.DataAnalysis.Views {
     
    7475    }
    7576
    76     private readonly IList<IRegressionSolution> solutions = new List<IRegressionSolution>();
     77    private readonly List<IRegressionSolution> solutions = new List<IRegressionSolution>();
    7778    public IEnumerable<IRegressionSolution> Solutions {
    7879      get { return solutions.AsEnumerable(); }
     
    101102      else {
    102103        // recalculate baseline solutions (for symbolic regression models the features used in the model might have changed)
    103         solutions.Clear(); // remove all
     104        solutions.Clear();
    104105        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());
    109107        UpdateChart();
    110108      }
     
    114112      else {
    115113        // recalculate baseline solutions
    116         solutions.Clear(); // remove all
     114        solutions.Clear();
    117115        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());
    122117        UpdateChart();
    123118      }
     
    129124      ReadOnly = Content == null;
    130125      if (Content != null) {
    131         // recalculate all solutions
    132126        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());
    138128      }
    139129      UpdateChart();
     
    175165      UpdateSeries(residuals, solutionSeries);
    176166
    177       solutionSeries.ToolTip = "Area over Curve: " + CalculateAreaOverCurve(solutionSeries);
     167      solutionSeries.ToolTip = "Area over curve: " + CalculateAreaOverCurve(solutionSeries);
    178168      solutionSeries.LegendToolTip = "Double-click to open model";
    179169      chart.Series.Add(solutionSeries);
     
    249239    protected virtual List<double> GetResiduals(IEnumerable<double> originalValues, IEnumerable<double> estimatedValues) {
    250240      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))
    252243            .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))
    254246            .Where(r => !double.IsNaN(r) && !double.IsInfinity(r)).ToList();
    255247        case "Relative error":
     
    289281
    290282    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;
    293288    }
    294289
    295290    private IRegressionSolution CreateConstantSolution() {
     291      if (!ProblemData.TrainingIndices.Any()) return null;
     292
    296293      double averageTrainingTarget = ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable, ProblemData.TrainingIndices).Average();
    297294      var model = new ConstantModel(averageTrainingTarget, ProblemData.TargetVariable);
     
    301298    }
    302299    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;
    307310    }
    308311
Note: See TracChangeset for help on using the changeset viewer.