Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/23/12 15:05:30 (12 years ago)
Author:
ascheibe
Message:

#1886 added relative error and possibility to add fitted line to charts

Location:
branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3/LinearLeastSquaresFitting.cs

    r8521 r8522  
    4545    public static double CalculateError(double[] dataPoints, double a1, double a0) {
    4646      double r = 0.0;
     47      double avgy = dataPoints.Average();
     48      double sstot = 0.0;
     49      double sserr = 0.0;
     50
    4751      for (int i = 0; i < dataPoints.Count(); i++) {
    4852        double y = a1 * i + a0;
    49         r += Math.Abs(dataPoints[i] - y);
     53        sstot += Math.Pow(dataPoints[i] - avgy, 2);
     54        sserr += Math.Pow(dataPoints[i] - y, 2);
    5055      }
     56
     57      r = 1.0 - (sserr / sstot);
    5158      return r;
    5259    }
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3/RunCollectionStatisticalTabularView.cs

    r8521 r8522  
    156156      string rowName = (string)dataRowComboBox.SelectedItem;
    157157
    158       string[] columnNames = new string[] { "Count", "Minimum", "Maximum", "Average", "Median", "Standard Deviation", "Variance", "25th Percentile", "75th Percentile", "Gradient", "Absolut Error" };
     158      string[] columnNames = new string[] { "Count", "Minimum", "Maximum", "Average", "Median", "Standard Deviation", "Variance", "25th Percentile", "75th Percentile", "Gradient", "Relative Error" };
    159159
    160160      var runs = Content.Where(x => x.Results.ContainsKey(resultName));
     
    200200      stringConvertibleMatrixView.Content = dt;
    201201    }
     202
     203    private void addLineToChart_Click(object sender, EventArgs e) {
     204      string resultName = (string)dataTableComboBox.SelectedItem;
     205      string rowName = (string)dataRowComboBox.SelectedItem;
     206      var runs = Content.Where(x => x.Results.ContainsKey(resultName));
     207
     208      foreach (Run run in runs) {
     209        DataTable resTable = (DataTable)run.Results[resultName];
     210        DataRow row = resTable.Rows[rowName];
     211        var values = row.Values.ToArray();
     212        double k, d;
     213        LinearLeastSquaresFitting.Calculate(values, out k, out d);
     214
     215        DataRow newRow = new DataRow(row.Name + " Fitted Line");
     216        for (int i = 0; i < values.Count(); i++) {
     217          newRow.Values.Add(k * i + d);
     218        }
     219
     220        if (!resTable.Rows.ContainsKey(newRow.Name))
     221          resTable.Rows.Add(newRow);
     222      }
     223    }
    202224  }
    203225}
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3/RunCollectionStatisticalTabularView.designer.cs

    r8502 r8522  
    5050      this.label1 = new System.Windows.Forms.Label();
    5151      this.dataTableComboBox = new System.Windows.Forms.ComboBox();
     52      this.addLineToChart = new System.Windows.Forms.Button();
    5253      this.SuspendLayout();
    5354      //
     
    6465      this.stringConvertibleMatrixView.ShowRowsAndColumnsTextBox = true;
    6566      this.stringConvertibleMatrixView.ShowStatisticalInformation = true;
    66       this.stringConvertibleMatrixView.Size = new System.Drawing.Size(492, 323);
     67      this.stringConvertibleMatrixView.Size = new System.Drawing.Size(492, 294);
    6768      this.stringConvertibleMatrixView.TabIndex = 0;
    6869      //
     
    109110      this.dataTableComboBox.SelectedIndexChanged += new System.EventHandler(this.dataTableComboBox_SelectedIndexChanged);
    110111      //
     112      // addLineToChart
     113      //
     114      this.addLineToChart.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
     115      this.addLineToChart.Location = new System.Drawing.Point(420, 359);
     116      this.addLineToChart.Name = "addLineToChart";
     117      this.addLineToChart.Size = new System.Drawing.Size(75, 23);
     118      this.addLineToChart.TabIndex = 9;
     119      this.addLineToChart.Text = "Fit Line";
     120      this.addLineToChart.UseVisualStyleBackColor = true;
     121      this.addLineToChart.Click += new System.EventHandler(this.addLineToChart_Click);
     122      //
    111123      // RunCollectionStatisticalTabularView
    112124      //
     125      this.Controls.Add(this.addLineToChart);
    113126      this.Controls.Add(this.dataRowComboBox);
    114127      this.Controls.Add(this.label2);
     
    129142    private System.Windows.Forms.Label label1;
    130143    private System.Windows.Forms.ComboBox dataTableComboBox;
     144    private System.Windows.Forms.Button addLineToChart;
    131145  }
    132146}
Note: See TracChangeset for help on using the changeset viewer.