Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/18/12 11:18:51 (12 years ago)
Author:
sforsten
Message:

#1758:

  • merged trunk r7330:8022 into branch
  • importButton shows a message, if clicked and it can't be used
Location:
branches/ChangeDatasetOfRegressionModel/HeuristicLab.Problems.DataAnalysis.Views
Files:
8 edited
2 copied

Legend:

Unmodified
Added
Removed
  • branches/ChangeDatasetOfRegressionModel/HeuristicLab.Problems.DataAnalysis.Views

  • branches/ChangeDatasetOfRegressionModel/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionEnsembleSolutionModelView.Designer.cs

    r7259 r8032  
    5050      //
    5151      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    52       this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
     52      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
    5353      this.Name = "RegressionEnsembleSolutionModelView";
    5454      this.ResumeLayout(false);
  • branches/ChangeDatasetOfRegressionModel/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionErrorCharacteristicsCurveView.Designer.cs

    r7043 r8032  
    4949      this.chart.TabIndex = 0;
    5050      this.chart.Text = "chart";
    51       this.chart.MouseDown += new System.Windows.Forms.MouseEventHandler(this.chart_MouseDown);
     51      this.chart.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.Chart_MouseDoubleClick);
     52      this.chart.MouseMove += new System.Windows.Forms.MouseEventHandler(this.chart_MouseMove);
    5253      //
    5354      // label1
     
    7374      //
    7475      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    75       this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
     76      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
    7677      this.Controls.Add(this.label1);
    7778      this.Controls.Add(this.cmbSamples);
  • branches/ChangeDatasetOfRegressionModel/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionErrorCharacteristicsCurveView.cs

    r7259 r8032  
    2727using HeuristicLab.MainForm;
    2828using HeuristicLab.MainForm.WindowsForms;
     29
    2930namespace HeuristicLab.Problems.DataAnalysis.Views {
    3031  [View("Error Characteristics Curve")]
     
    104105      var originalValues = GetOriginalValues().ToList();
    105106      constantModel = CreateConstantModel();
    106       var meanModelEstimatedValues = GetEstimatedValues(constantModel);
    107       var meanModelResiduals = GetResiduals(originalValues, meanModelEstimatedValues);
    108 
    109       meanModelResiduals.Sort();
    110       chart.ChartAreas[0].AxisX.Maximum = Math.Ceiling(meanModelResiduals.Last());
    111       chart.ChartAreas[0].CursorX.Interval = meanModelResiduals.First() / 100;
    112 
    113       Series meanModelSeries = new Series("Mean Model");
    114       meanModelSeries.ChartType = SeriesChartType.FastLine;
    115       UpdateSeries(meanModelResiduals, meanModelSeries);
    116       meanModelSeries.ToolTip = "Area over Curve: " + CalculateAreaOverCurve(meanModelSeries);
    117       meanModelSeries.Tag = constantModel;
    118       chart.Series.Add(meanModelSeries);
     107      var baselineEstimatedValues = GetEstimatedValues(constantModel);
     108      var baselineResiduals = GetResiduals(originalValues, baselineEstimatedValues);
     109
     110      baselineResiduals.Sort();
     111      chart.ChartAreas[0].AxisX.Maximum = Math.Ceiling(baselineResiduals.Last());
     112      chart.ChartAreas[0].CursorX.Interval = baselineResiduals.First() / 100;
     113
     114      Series baselineSeries = new Series("Baseline");
     115      baselineSeries.ChartType = SeriesChartType.FastLine;
     116      UpdateSeries(baselineResiduals, baselineSeries);
     117      baselineSeries.ToolTip = "Area over Curve: " + CalculateAreaOverCurve(baselineSeries);
     118      baselineSeries.Tag = constantModel;
     119      chart.Series.Add(baselineSeries);
    119120
    120121      AddRegressionSolution(Content);
     
    200201    }
    201202
    202     protected IEnumerable<double> GetMeanModelEstimatedValues(IEnumerable<double> originalValues) {
     203    protected IEnumerable<double> GetbaselineEstimatedValues(IEnumerable<double> originalValues) {
    203204      double averageTrainingTarget = ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable, ProblemData.TrainingIndizes).Average();
    204205      return Enumerable.Repeat(averageTrainingTarget, originalValues.Count());
     
    229230    }
    230231
    231     #region Mean Model
    232     private void chart_MouseDown(object sender, MouseEventArgs e) {
    233       if (e.Clicks < 2) return;
     232    #region Baseline
     233    private void Chart_MouseDoubleClick(object sender, MouseEventArgs e) {
    234234      HitTestResult result = chart.HitTest(e.X, e.Y);
    235235      if (result.ChartElementType != ChartElementType.LegendItem) return;
    236       if (result.Series.Name != constantModel.Name) return;
    237236
    238237      MainFormManager.MainForm.ShowContent((IRegressionSolution)result.Series.Tag);
     
    242241      double averageTrainingTarget = ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable, ProblemData.TrainingIndizes).Average();
    243242      var solution = new ConstantRegressionModel(averageTrainingTarget).CreateRegressionSolution(ProblemData);
    244       solution.Name = "Mean Model";
     243      solution.Name = "Baseline";
    245244      return solution;
    246245    }
    247246    #endregion
     247
     248    private void chart_MouseMove(object sender, MouseEventArgs e) {
     249      HitTestResult result = chart.HitTest(e.X, e.Y);
     250      if (result.ChartElementType == ChartElementType.LegendItem)
     251        Cursor = Cursors.Hand;
     252      else
     253        Cursor = Cursors.Default;
     254    }
    248255  }
    249256}
  • branches/ChangeDatasetOfRegressionModel/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionEstimatedValuesView.Designer.cs

    r7259 r8032  
    5050      this.AllowDrop = true;
    5151      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    52       this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
     52      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
    5353      this.Name = "EstimatedValuesView";
    5454      this.Size = new System.Drawing.Size(310, 285);
  • branches/ChangeDatasetOfRegressionModel/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionLineChartView.Designer.cs

    r7259 r8032  
    7272      this.AllowDrop = true;
    7373      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    74       this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
     74      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
    7575      this.Controls.Add(this.chart);
    7676      this.Name = "RegressionSolutionLineChartView";
  • branches/ChangeDatasetOfRegressionModel/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionLineChartView.cs

    r7327 r8032  
    2626using System.Windows.Forms.DataVisualization.Charting;
    2727using HeuristicLab.MainForm;
    28 using HeuristicLab.MainForm.WindowsForms;
    2928
    3029namespace HeuristicLab.Problems.DataAnalysis.Views {
     
    7271        this.chart.Series[ESTIMATEDVALUES_TRAINING_SERIES_NAME].LegendText = ESTIMATEDVALUES_TRAINING_SERIES_NAME;
    7372        this.chart.Series[ESTIMATEDVALUES_TRAINING_SERIES_NAME].ChartType = SeriesChartType.FastLine;
     73        this.chart.Series[ESTIMATEDVALUES_TRAINING_SERIES_NAME].EmptyPointStyle.Color = this.chart.Series[ESTIMATEDVALUES_TRAINING_SERIES_NAME].Color;
    7474        this.chart.Series[ESTIMATEDVALUES_TRAINING_SERIES_NAME].Points.DataBindXY(Content.ProblemData.TrainingIndizes.ToArray(), Content.EstimatedTrainingValues.ToArray());
     75        this.InsertEmptyPoints(this.chart.Series[ESTIMATEDVALUES_TRAINING_SERIES_NAME]);
    7576        this.chart.Series[ESTIMATEDVALUES_TRAINING_SERIES_NAME].Tag = Content;
    7677        // test series
     
    7980        this.chart.Series[ESTIMATEDVALUES_TEST_SERIES_NAME].ChartType = SeriesChartType.FastLine;
    8081        this.chart.Series[ESTIMATEDVALUES_TEST_SERIES_NAME].Points.DataBindXY(Content.ProblemData.TestIndizes.ToArray(), Content.EstimatedTestValues.ToArray());
     82        this.InsertEmptyPoints(this.chart.Series[ESTIMATEDVALUES_TEST_SERIES_NAME]);
    8183        this.chart.Series[ESTIMATEDVALUES_TEST_SERIES_NAME].Tag = Content;
    8284        // series of remaining points
     
    8486        var estimatedValues = Content.EstimatedValues.ToArray();
    8587        List<double> allEstimatedValues = allIndizes.Select(index => estimatedValues[index]).ToList();
    86 
    8788        this.chart.Series.Add(ESTIMATEDVALUES_ALL_SERIES_NAME);
    8889        this.chart.Series[ESTIMATEDVALUES_ALL_SERIES_NAME].LegendText = ESTIMATEDVALUES_ALL_SERIES_NAME;
    8990        this.chart.Series[ESTIMATEDVALUES_ALL_SERIES_NAME].ChartType = SeriesChartType.FastLine;
    9091        this.chart.Series[ESTIMATEDVALUES_ALL_SERIES_NAME].Points.DataBindXY(allIndizes, allEstimatedValues);
     92        this.InsertEmptyPoints(this.chart.Series[ESTIMATEDVALUES_ALL_SERIES_NAME]);
    9193        this.chart.Series[ESTIMATEDVALUES_ALL_SERIES_NAME].Tag = Content;
    9294        this.ToggleSeriesData(this.chart.Series[ESTIMATEDVALUES_ALL_SERIES_NAME]);
     
    9496        UpdateCursorInterval();
    9597        this.UpdateStripLines();
     98      }
     99    }
     100
     101    private void InsertEmptyPoints(Series series) {
     102      int i = 0;
     103      while (i < series.Points.Count - 1) {
     104        if (series.Points[i].IsEmpty) {
     105          ++i;
     106          continue;
     107        }
     108
     109        var p1 = series.Points[i];
     110        var p2 = series.Points[i + 1];
     111        // check for consecutive indices
     112        if ((int)p2.XValue - (int)p1.XValue != 1) {
     113          // insert an empty point between p1 and p2 so that the line will be invisible (transparent)
     114          var p = new DataPoint((int)((p1.XValue + p2.XValue) / 2), 0.0) { IsEmpty = true };
     115          series.Points.Insert(i + 1, p);
     116        }
     117        ++i;
    96118      }
    97119    }
     
    196218      if (series.Points.Count > 0) {  //checks if series is shown
    197219        if (this.chart.Series.Any(s => s != series && s.Points.Count > 0)) {
    198           series.Points.Clear();
     220          ClearPointsQuick(series.Points);
    199221        }
    200222      } else if (Content != null) {
     
    219241        }
    220242        series.Points.DataBindXY(indizes, predictedValues);
    221         chart.DataManipulator.InsertEmptyPoints(1, IntervalType.Number, series.Name);
     243        this.InsertEmptyPoints(series);
    222244        chart.Legends[series.Legend].ForeColor = Color.Black;
    223245        UpdateCursorInterval();
    224246        chart.Refresh();
    225247      }
     248    }
     249
     250    // workaround as per http://stackoverflow.com/questions/5744930/datapointcollection-clear-performance
     251    private static void ClearPointsQuick(DataPointCollection points) {
     252      points.SuspendUpdates();
     253      while (points.Count > 0)
     254        points.RemoveAt(points.Count - 1);
     255      points.ResumeUpdates();
    226256    }
    227257
  • branches/ChangeDatasetOfRegressionModel/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionScatterPlotView.cs

    r7259 r8032  
    119119      this.chart.ChartAreas[0].CursorX.Interval = zoomInterval;
    120120      this.chart.ChartAreas[0].CursorY.Interval = zoomInterval;
     121
     122      this.chart.ChartAreas[0].AxisX.ScaleView.SmallScrollSize = zoomInterval;
     123      this.chart.ChartAreas[0].AxisY.ScaleView.SmallScrollSize = zoomInterval;
     124
     125      this.chart.ChartAreas[0].AxisX.ScaleView.SmallScrollMinSizeType = DateTimeIntervalType.Number;
     126      this.chart.ChartAreas[0].AxisX.ScaleView.SmallScrollMinSize = zoomInterval;
     127      this.chart.ChartAreas[0].AxisY.ScaleView.SmallScrollMinSizeType = DateTimeIntervalType.Number;
     128      this.chart.ChartAreas[0].AxisY.ScaleView.SmallScrollMinSize = zoomInterval;
     129
     130      if (digits < 0) {
     131        this.chart.ChartAreas[0].AxisX.LabelStyle.Format = "F" + (int)Math.Abs(digits);
     132        this.chart.ChartAreas[0].AxisY.LabelStyle.Format = "F" + (int)Math.Abs(digits);
     133      } else {
     134        this.chart.ChartAreas[0].AxisX.LabelStyle.Format = "F0";
     135        this.chart.ChartAreas[0].AxisY.LabelStyle.Format = "F0";
     136      }
    121137    }
    122138
Note: See TracChangeset for help on using the changeset viewer.