Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/14/12 13:25:17 (12 years ago)
Author:
gkronber
Message:

#1902 changed interface for covariance functions to improve readability, fixed several bugs in the covariance functions and in the line chart for Gaussian process models.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis.Views/3.4/GaussianProcessRegressionSolutionLineChartView.cs

    r8475 r8484  
    9191        // series of remaining points
    9292        int[] allIndices = Enumerable.Range(0, Content.ProblemData.Dataset.Rows).Except(Content.ProblemData.TrainingIndices).Except(Content.ProblemData.TestIndices).ToArray();
    93         var estimatedValues = Content.EstimatedValues.ToArray();
    94         List<double> allEstimatedValues = allIndices.Select(index => estimatedValues[index]).ToList();
     93        mean = Content.EstimatedValues.ToArray();
     94        s2 = Content.EstimatedVariance.ToArray();
     95        lower = mean.Zip(s2, (m, s) => m - 1.96 * Math.Sqrt(s)).ToArray();
     96        upper = mean.Zip(s2, (m, s) => m + 1.96 * Math.Sqrt(s)).ToArray();
     97        List<double> allLower = allIndices.Select(index => lower[index]).ToList();
     98        List<double> allUpper = allIndices.Select(index => upper[index]).ToList();
    9599        this.chart.Series.Add(ESTIMATEDVALUES_ALL_SERIES_NAME);
    96100        this.chart.Series[ESTIMATEDVALUES_ALL_SERIES_NAME].LegendText = ESTIMATEDVALUES_ALL_SERIES_NAME;
    97101        this.chart.Series[ESTIMATEDVALUES_ALL_SERIES_NAME].ChartType = SeriesChartType.Range;
    98         this.chart.Series[ESTIMATEDVALUES_ALL_SERIES_NAME].Points.DataBindXY(allIndices, allEstimatedValues);
    99         this.InsertEmptyPoints(this.chart.Series[ESTIMATEDVALUES_ALL_SERIES_NAME]);
     102        if (allIndices.Count() > 0) {
     103          this.chart.Series[ESTIMATEDVALUES_ALL_SERIES_NAME].Points.DataBindXY(allIndices, allLower, allUpper);
     104          this.InsertEmptyPoints(this.chart.Series[ESTIMATEDVALUES_ALL_SERIES_NAME]);
     105        }
    100106        this.chart.Series[ESTIMATEDVALUES_ALL_SERIES_NAME].Tag = Content;
    101107
     
    127133        if ((int)p2.XValue - (int)p1.XValue != 1) {
    128134          // insert an empty point between p1 and p2 so that the line will be invisible (transparent)
    129           var p = new DataPoint((int)((p1.XValue + p2.XValue) / 2), 0.0) { IsEmpty = true };
     135          var p = new DataPoint((int)((p1.XValue + p2.XValue) / 2), new double[] { 0.0, 0.0 }) { IsEmpty = true };
     136          // insert
    130137          series.Points.Insert(i + 1, p);
    131138        }
     
    236243        }
    237244      } else if (Content != null) {
    238         string targetVariableName = Content.ProblemData.TargetVariable;
    239245
    240246        IEnumerable<int> indices = null;
     
    268274            break;
    269275        }
    270         series.Points.DataBindXY(indices, lower, upper);
    271         this.InsertEmptyPoints(series);
    272         chart.Legends[series.Legend].ForeColor = Color.Black;
    273         UpdateCursorInterval();
    274         chart.Refresh();
     276        if (indices.Count() > 0) {
     277          series.Points.DataBindXY(indices, lower, upper);
     278          this.InsertEmptyPoints(series);
     279          chart.Legends[series.Legend].ForeColor = Color.Black;
     280          UpdateCursorInterval();
     281          chart.Refresh();
     282        }
    275283      }
    276284    }
     
    300308    private void chart_CustomizeLegend(object sender, CustomizeLegendEventArgs e) {
    301309      if (chart.Series.Count != 4) return;
    302       e.LegendItems[0].Cells[1].ForeColor = this.chart.Series[TARGETVARIABLE_SERIES_NAME].Points.Count == 0 ? Color.Gray : Color.Black;
    303       e.LegendItems[1].Cells[1].ForeColor = this.chart.Series[ESTIMATEDVALUES_TRAINING_SERIES_NAME].Points.Count == 0 ? Color.Gray : Color.Black;
    304       e.LegendItems[2].Cells[1].ForeColor = this.chart.Series[ESTIMATEDVALUES_TEST_SERIES_NAME].Points.Count == 0 ? Color.Gray : Color.Black;
    305       e.LegendItems[3].Cells[1].ForeColor = this.chart.Series[ESTIMATEDVALUES_ALL_SERIES_NAME].Points.Count == 0 ? Color.Gray : Color.Black;
     310      e.LegendItems[0].Cells[1].ForeColor = this.chart.Series[ESTIMATEDVALUES_TRAINING_SERIES_NAME].Points.Count == 0 ? Color.Gray : Color.Black;
     311      e.LegendItems[1].Cells[1].ForeColor = this.chart.Series[ESTIMATEDVALUES_TEST_SERIES_NAME].Points.Count == 0 ? Color.Gray : Color.Black;
     312      e.LegendItems[2].Cells[1].ForeColor = this.chart.Series[ESTIMATEDVALUES_ALL_SERIES_NAME].Points.Count == 0 ? Color.Gray : Color.Black;
     313      e.LegendItems[3].Cells[1].ForeColor = this.chart.Series[TARGETVARIABLE_SERIES_NAME].Points.Count == 0 ? Color.Gray : Color.Black;
    306314    }
    307315  }
Note: See TracChangeset for help on using the changeset viewer.