Free cookie consent management tool by TermsFeed Policy Generator

Changeset 14987 for trunk


Ignore:
Timestamp:
05/16/17 12:53:53 (8 years ago)
Author:
pfleck
Message:

#2713

  • Fixed problems with negative values for some regression types.
  • Fixed issue where the regression line was not drawn up to the last point.
  • Tool strip now reads "Configure Chart...".
Location:
trunk/sources/HeuristicLab.Analysis.Views/3.3
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Analysis.Views/3.3/DataTableView.Designer.cs

    r14982 r14987  
    107107      this.configureToolStripMenuItem.Name = "configureToolStripMenuItem";
    108108      this.configureToolStripMenuItem.Size = new System.Drawing.Size(256, 22);
    109       this.configureToolStripMenuItem.Text = "Configure Chart";
     109      this.configureToolStripMenuItem.Text = "Configure Chart...";
    110110      this.configureToolStripMenuItem.Click += new System.EventHandler(this.configureToolStripMenuItem_Click);
    111111      //
  • trunk/sources/HeuristicLab.Analysis.Views/3.3/ScatterPlotView.Designer.cs

    r14982 r14987  
    6969      // chart
    7070      //
    71       this.chart.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
    72             | System.Windows.Forms.AnchorStyles.Left) 
     71      this.chart.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     72            | System.Windows.Forms.AnchorStyles.Left)
    7373            | System.Windows.Forms.AnchorStyles.Right)));
    7474      this.chart.BorderlineColor = System.Drawing.Color.Black;
     
    107107      this.configureToolStripMenuItem.Name = "configureToolStripMenuItem";
    108108      this.configureToolStripMenuItem.Size = new System.Drawing.Size(256, 22);
    109       this.configureToolStripMenuItem.Text = "Configure Chart";
     109      this.configureToolStripMenuItem.Text = "Configure Chart...";
    110110      this.configureToolStripMenuItem.Click += new System.EventHandler(this.configureToolStripMenuItem_Click);
    111111      //
  • trunk/sources/HeuristicLab.Analysis.Views/3.3/ScatterPlotView.cs

    r14982 r14987  
    571571
    572572      double[] coefficients;
    573       if (!Fitting(row, out coefficients))
     573      if (!Fitting(row, out coefficients)) {
     574        regressionSeries.LegendToolTip = "Could not calculate regression.";
    574575        return;
     576      }
    575577
    576578      // Fill regrssion series
    577       var validPoints = row.Points.Where(p => !IsInvalidValue(p.X));
    578       double min = validPoints.Min(p => p.X), max = validPoints.Max(p => p.X);
    579       double range = max - min, delta = range / row.Points.Count;
    580       for (double x = min; x < max; x += delta) {
     579      double min = row.Points.Min(p => p.X), max = row.Points.Max(p => p.X);
     580      double range = max - min, delta = range / Math.Max(row.Points.Count - 1, 50);
     581      for (double x = min; x <= max; x += delta) {
    581582        regressionSeries.Points.AddXY(x, Estimate(x, row, coefficients));
    582583      }
     
    657658
    658659    protected static bool Fitting(ScatterPlotDataRow row, out double[] coefficients) {
     660      if (!IsValidRegressionData(row)) {
     661        coefficients = new double[0];
     662        return false;
     663      }
     664
    659665      var xs = row.Points.Select(p => p.X).ToList();
    660666      var ys = row.Points.Select(p => p.Y).ToList();
     
    688694      // Linear fitting
    689695      bool success = LinearFitting(matrix, nRows, out coefficients);
    690       if (!success) return success;
     696      if (!success) return false;
    691697
    692698      // Output transformation
     
    698704      }
    699705
     706      return true;
     707    }
     708    protected static bool IsValidRegressionData(ScatterPlotDataRow row) {
     709      // No invalid values allowed
     710      for (int i = 0; i < row.Points.Count; i++) {
     711        if (IsInvalidValue(row.Points[i].X) || IsInvalidValue(row.Points[i].Y))
     712          return false;
     713      }
     714      // Exp, Power and Log Regression do not work with negative values
     715      switch (row.VisualProperties.RegressionType) {
     716        case ScatterPlotDataRowVisualProperties.ScatterPlotDataRowRegressionType.Exponential:
     717          for (int i = 0; i < row.Points.Count; i++) {
     718            if (row.Points[i].Y <= 0)
     719              return false;
     720          }
     721          break;
     722        case ScatterPlotDataRowVisualProperties.ScatterPlotDataRowRegressionType.Power:
     723          for (int i = 0; i < row.Points.Count; i++) {
     724            if (row.Points[i].X <= 0 || row.Points[i].Y <= 0)
     725              return false;
     726          }
     727          break;
     728        case ScatterPlotDataRowVisualProperties.ScatterPlotDataRowRegressionType.Logarithmic:
     729          for (int i = 0; i < row.Points.Count; i++) {
     730            if (row.Points[i].X <= 0)
     731              return false;
     732          }
     733          break;
     734      }
    700735      return true;
    701736    }
Note: See TracChangeset for help on using the changeset viewer.