Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/28/11 13:47:28 (13 years ago)
Author:
sforsten
Message:

#1669: branch has been merged with the trunk in revision 7081 and methods in RegressionBenchmark have been renamed.

Location:
branches/RegressionBenchmarks
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/RegressionBenchmarks

  • branches/RegressionBenchmarks/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionErrorCharacteristicsCurveView.Designer.cs

    r6642 r7085  
    4949      this.chart.TabIndex = 0;
    5050      this.chart.Text = "chart";
     51      this.chart.MouseDown += new System.Windows.Forms.MouseEventHandler(this.chart_MouseDown);
    5152      //
    5253      // label1
  • branches/RegressionBenchmarks/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionErrorCharacteristicsCurveView.cs

    r6750 r7085  
    3131  [Content(typeof(IRegressionSolution))]
    3232  public partial class RegressionSolutionErrorCharacteristicsCurveView : DataAnalysisSolutionEvaluationView {
     33    private IRegressionSolution constantModel;
    3334    protected const string TrainingSamples = "Training";
    3435    protected const string TestSamples = "Test";
     
    101102      if (Content == null) return;
    102103
    103       var originalValues = GetOriginalValues();
    104       var meanModelEstimatedValues = GetMeanModelEstimatedValues(originalValues);
     104      var originalValues = GetOriginalValues().ToList();
     105      constantModel = CreateConstantModel();
     106      var meanModelEstimatedValues = GetEstimatedValues(constantModel);
    105107      var meanModelResiduals = GetResiduals(originalValues, meanModelEstimatedValues);
    106108
     
    113115      UpdateSeries(meanModelResiduals, meanModelSeries);
    114116      meanModelSeries.ToolTip = "Area over Curve: " + CalculateAreaOverCurve(meanModelSeries);
     117      meanModelSeries.Tag = constantModel;
    115118      chart.Series.Add(meanModelSeries);
    116119
     
    133136      series.Points.Clear();
    134137      residuals.Sort();
     138      if (!residuals.Any() || residuals.All(double.IsNaN)) return;
    135139
    136140      series.Points.AddXY(0, 0);
     
    146150
    147151        point.XValue = residuals[i];
    148         point.YValues[0] = ((double)i+1) / residuals.Count;
     152        point.YValues[0] = ((double)i + 1) / residuals.Count;
    149153        point.ToolTip = "Error: " + point.XValue + "\n" + "Samples: " + point.YValues[0];
    150154        series.Points.Add(point);
     
    206210
    207211    private double CalculateAreaOverCurve(Series series) {
    208       if (series.Points.Count < 1) throw new ArgumentException("Could not calculate area under curve if less than 1 data points were given.");
     212      if (series.Points.Count < 1) return 0;
    209213
    210214      double auc = 0.0;
     
    224228      else UpdateChart();
    225229    }
     230
     231    #region Mean Model
     232    private void chart_MouseDown(object sender, MouseEventArgs e) {
     233      if (e.Clicks < 2) return;
     234      HitTestResult result = chart.HitTest(e.X, e.Y);
     235      if (result.ChartElementType != ChartElementType.LegendItem) return;
     236      if (result.Series.Name != constantModel.Name) return;
     237
     238      MainFormManager.MainForm.ShowContent((IRegressionSolution)result.Series.Tag);
     239    }
     240
     241    private IRegressionSolution CreateConstantModel() {
     242      double averageTrainingTarget = ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable, ProblemData.TrainingIndizes).Average();
     243      var solution = new ConstantRegressionModel(averageTrainingTarget).CreateRegressionSolution(ProblemData);
     244      solution.Name = "Mean Model";
     245      return solution;
     246    }
     247    #endregion
    226248  }
    227249}
  • branches/RegressionBenchmarks/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionScatterPlotView.cs

    r6740 r7085  
    2020#endregion
    2121using System;
    22 using System.Collections.Generic;
    2322using System.Drawing;
    2423using System.Linq;
     
    172171        string targetVariableName = Content.ProblemData.TargetVariable;
    173172
    174         IEnumerable<double> predictedValues = null;
    175         IEnumerable<double> targetValues = null;
     173        double[] predictedValues = null;
     174        double[] targetValues = null;
    176175        switch (series.Name) {
    177176          case ALL_SERIES:
     
    188187            break;
    189188        }
    190         series.Points.DataBindXY(predictedValues, "", targetValues, "");
     189        if (predictedValues.Length == targetValues.Length)
     190          series.Points.DataBindXY(predictedValues, "", targetValues, "");
    191191        this.chart.Legends[series.Legend].ForeColor = Color.Black;
    192192        UpdateCursorInterval();
Note: See TracChangeset for help on using the changeset viewer.