Free cookie consent management tool by TermsFeed Policy Generator

Changeset 11093 for trunk/sources


Ignore:
Timestamp:
07/06/14 14:14:42 (10 years ago)
Author:
gkronber
Message:

#2197: fixed bugs in views for data analysis solutions that might occur if the problem does not have training samples (e.g. when the data is loaded into an existing solution)

Location:
trunk/sources
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views/3.4/SymbolicClassificationSolutionView.cs

    r10540 r11093  
    2222using System;
    2323using System.ComponentModel;
     24using System.Linq;
    2425using System.Windows.Forms;
    2526using HeuristicLab.MainForm;
     
    4243    protected override void SetEnabledStateOfControls() {
    4344      base.SetEnabledStateOfControls();
    44       btnSimplify.Enabled = Content != null && !Locked;
     45      btnSimplify.Enabled = Content != null && !Locked && Content.ProblemData.TrainingIndices.Any(); // simplification is only possible if there are trainings samples
    4546      exportButton.Enabled = Content != null && !Locked;
    4647    }
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views/3.4/SymbolicDiscriminantFunctionClassificationSolutionView.cs

    r10540 r11093  
    2222using System;
    2323using System.ComponentModel;
     24using System.Linq;
    2425using System.Windows.Forms;
    2526using HeuristicLab.MainForm;
     
    4243    protected override void SetEnabledStateOfControls() {
    4344      base.SetEnabledStateOfControls();
    44       btnSimplify.Enabled = Content != null && !Locked;
     45      btnSimplify.Enabled = Content != null && !Locked && Content.ProblemData.TrainingIndices.Any(); // simplification is only possible if there are trainings samples
    4546      exportButton.Enabled = Content != null && !Locked;
    4647    }
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/SymbolicRegressionSolutionErrorCharacteristicsCurveView.cs

    r9456 r11093  
    6060      double rmse, cvRmsError;
    6161      var problemData = (IRegressionProblemData)ProblemData.Clone();
     62      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)
    6263
    6364      //clear checked inputVariables
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/SymbolicRegressionSolutionView.cs

    r10894 r11093  
    2222using System;
    2323using System.ComponentModel;
     24using System.Linq;
    2425using System.Windows.Forms;
    2526using HeuristicLab.MainForm;
     
    4243    protected override void SetEnabledStateOfControls() {
    4344      base.SetEnabledStateOfControls();
    44       btnSimplify.Enabled = Content != null && !Locked;
     45      btnSimplify.Enabled = Content != null && !Locked && Content.ProblemData.TrainingIndices.Any(); // simplification is only possible if there are trainings samples
    4546      exportButton.Enabled = Content != null && !Locked;
    4647    }
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis.Views/3.4/SymbolicTimeSeriesPrognosisSolutionView.cs

    r10540 r11093  
    2121
    2222using System;
    23 using System.Windows.Forms;
     23using System.Linq;
    2424using HeuristicLab.MainForm;
    2525using HeuristicLab.Problems.DataAnalysis.Views;
     
    4040    protected override void SetEnabledStateOfControls() {
    4141      base.SetEnabledStateOfControls();
    42       btnSimplify.Enabled = Content != null && !Locked;
     42      btnSimplify.Enabled = Content != null && !Locked && Content.ProblemData.TrainingIndices.Any(); // simplification is only possible if there are trainings samples
    4343    }
    4444
    4545    private void btn_SimplifyModel_Click(object sender, EventArgs e) {
    46       InteractiveSymbolicTimeSeriesPrognosisSolutionSimplifierView view = new InteractiveSymbolicTimeSeriesPrognosisSolutionSimplifierView();
     46      var view = new InteractiveSymbolicTimeSeriesPrognosisSolutionSimplifierView();
    4747      view.Content = (SymbolicTimeSeriesPrognosisSolution)this.Content.Clone();
    4848      view.Show();
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionErrorCharacteristicsCurveView.cs

    r10500 r11093  
    9999      chart.Series.Clear();
    100100      chart.Annotations.Clear();
     101
    101102      if (Content == null) return;
    102 
    103       var constantModel = CreateConstantModel();
    104       var originalValues = GetOriginalValues().ToList();
    105       var baselineEstimatedValues = GetEstimatedValues(constantModel);
    106       var baselineResiduals = GetResiduals(originalValues, baselineEstimatedValues);
    107 
    108       baselineResiduals.Sort();
    109       chart.ChartAreas[0].AxisX.Maximum = Math.Ceiling(baselineResiduals.Last());
    110       chart.ChartAreas[0].CursorX.Interval = baselineResiduals.First() / 100;
    111 
    112       Series baselineSeries = new Series("Baseline");
    113       baselineSeries.ChartType = SeriesChartType.FastLine;
    114       UpdateSeries(baselineResiduals, baselineSeries);
    115       baselineSeries.ToolTip = "Area over Curve: " + CalculateAreaOverCurve(baselineSeries);
    116       baselineSeries.Tag = constantModel;
    117       baselineSeries.LegendToolTip = "Double-click to open model";
    118       chart.Series.Add(baselineSeries);
     103      if (cmbSamples.SelectedItem.ToString() == TrainingSamples && !ProblemData.TrainingIndices.Any()) return;
     104      if (cmbSamples.SelectedItem.ToString() == TestSamples && !ProblemData.TestIndices.Any()) return;
     105
     106      if (Content.ProblemData.TrainingIndices.Any()) {
     107        var constantModel = CreateConstantModel();
     108        var originalValues = GetOriginalValues().ToList();
     109        var baselineEstimatedValues = GetEstimatedValues(constantModel);
     110        var baselineResiduals = GetResiduals(originalValues, baselineEstimatedValues);
     111
     112        Series baselineSeries = new Series("Baseline");
     113        baselineSeries.ChartType = SeriesChartType.FastLine;
     114        UpdateSeries(baselineResiduals, baselineSeries);
     115        baselineSeries.ToolTip = "Area over Curve: " + CalculateAreaOverCurve(baselineSeries);
     116        baselineSeries.Tag = constantModel;
     117        baselineSeries.LegendToolTip = "Double-click to open model";
     118        chart.Series.Add(baselineSeries);
     119      }
    119120
    120121      AddRegressionSolution(Content);
     
    127128      solutionSeries.Tag = solution;
    128129      solutionSeries.ChartType = SeriesChartType.FastLine;
    129       var estimatedValues = GetResiduals(GetOriginalValues(), GetEstimatedValues(solution));
    130       UpdateSeries(estimatedValues, solutionSeries);
     130      var residuals = GetResiduals(GetOriginalValues(), GetEstimatedValues(solution));
     131     
     132      chart.ChartAreas[0].AxisX.Maximum = Math.Ceiling(residuals.Max());
     133      chart.ChartAreas[0].CursorX.Interval = residuals.Min() / 100;
     134
     135      UpdateSeries(residuals, solutionSeries);
     136
    131137      solutionSeries.ToolTip = "Area over Curve: " + CalculateAreaOverCurve(solutionSeries);
    132138      solutionSeries.LegendToolTip = "Double-click to open model";
     
    236242      double averageTrainingTarget = ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable, ProblemData.TrainingIndices).Average();
    237243      var model = new ConstantRegressionModel(averageTrainingTarget);
    238       var solution = new ConstantRegressionSolution(model,(IRegressionProblemData)ProblemData.Clone());
     244      var solution = new ConstantRegressionSolution(model, (IRegressionProblemData)ProblemData.Clone());
    239245      solution.Name = "Baseline";
    240246      return solution;
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/TimeSeriesPrognosis/TimeSeriesPrognosisSolutionErrorCharacteristicsCurveView.cs

    r9462 r11093  
    2222using System.Collections.Generic;
    2323using System.Linq;
    24 using System.Windows.Forms;
    2524using HeuristicLab.MainForm;
    26 using HeuristicLab.MainForm.WindowsForms;
     25
    2726namespace HeuristicLab.Problems.DataAnalysis.Views {
    2827  [View("Error Characteristics Curve")]
     
    5150      if (Content == null) return;
    5251
    53       //AR1 model
    54       double alpha, beta;
    55       OnlineCalculatorError errorState;
    5652      IEnumerable<double> trainingStartValues = ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable, ProblemData.TrainingIndices.Select(r => r - 1).Where(r => r > 0)).ToList();
    57       OnlineLinearScalingParameterCalculator.Calculate(ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable, ProblemData.TrainingIndices.Where(x => x > 0)), trainingStartValues, out alpha, out beta, out errorState);
    58       var AR1model = new TimeSeriesPrognosisAutoRegressiveModel(ProblemData.TargetVariable, new double[] { beta }, alpha).CreateTimeSeriesPrognosisSolution(ProblemData);
    59       AR1model.Name = "AR(1) Model";
    60       AddRegressionSolution(AR1model);
     53      if (trainingStartValues.Any()) {
     54        //AR1 model
     55        double alpha, beta;
     56        OnlineCalculatorError errorState;
     57        OnlineLinearScalingParameterCalculator.Calculate(ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable, ProblemData.TrainingIndices.Where(x => x > 0)), trainingStartValues, out alpha, out beta, out errorState);
     58        var ar1model = new TimeSeriesPrognosisAutoRegressiveModel(ProblemData.TargetVariable, new double[] { beta }, alpha).CreateTimeSeriesPrognosisSolution(ProblemData);
     59        ar1model.Name = "AR(1) Model";
     60        AddRegressionSolution(ar1model);
     61      }
    6162    }
    6263  }
Note: See TracChangeset for help on using the changeset viewer.