Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/05/11 20:17:59 (12 years ago)
Author:
gkronber
Message:

#1081 worked on multi-variate time series prognosis

Location:
branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis.Views/3.4
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis.Views/3.4/HeuristicLab.Problems.DataAnalysis.Views-3.4.csproj

    r7100 r7129  
    257257      <DependentUpon>RegressionSolutionScatterPlotView.cs</DependentUpon>
    258258    </Compile>
     259    <Compile Include="TimeSeriesPrognosis\TimeSeriesPrognosisSolutionLineChartView.cs">
     260      <SubType>UserControl</SubType>
     261    </Compile>
     262    <Compile Include="TimeSeriesPrognosis\TimeSeriesPrognosisSolutionLineChartView.Designer.cs">
     263      <DependentUpon>TimeSeriesPrognosisSolutionLineChartView.cs</DependentUpon>
     264    </Compile>
    259265    <Compile Include="TimeSeriesPrognosis\TimeSeriesPrognosisSolutionPrognosedValuesView.cs">
    260266      <SubType>UserControl</SubType>
     
    378384    </BootstrapperPackage>
    379385  </ItemGroup>
    380   <ItemGroup />
     386  <ItemGroup>
     387    <EmbeddedResource Include="TimeSeriesPrognosis\TimeSeriesPrognosisSolutionLineChartView.resx">
     388      <DependentUpon>TimeSeriesPrognosisSolutionLineChartView.cs</DependentUpon>
     389    </EmbeddedResource>
     390  </ItemGroup>
    381391  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
    382392  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
  • branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis.Views/3.4/TimeSeriesPrognosis/TimeSeriesPrognosisSolutionLineChartView.Designer.cs

    r6802 r7129  
    4444    /// </summary>
    4545    private void InitializeComponent() {
    46       System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
    47       System.Windows.Forms.DataVisualization.Charting.Legend legend1 = new System.Windows.Forms.DataVisualization.Charting.Legend();
     46      System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea2 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
     47      System.Windows.Forms.DataVisualization.Charting.Legend legend2 = new System.Windows.Forms.DataVisualization.Charting.Legend();
    4848      this.chart = new HeuristicLab.Visualization.ChartControlsExtensions.EnhancedChart();
     49      this.targetVariableComboBox = new System.Windows.Forms.ComboBox();
     50      this.label = new System.Windows.Forms.Label();
     51      this.prognosedValuesCheckbox = new System.Windows.Forms.CheckBox();
    4952      ((System.ComponentModel.ISupportInitialize)(this.chart)).BeginInit();
    5053      this.SuspendLayout();
     
    5255      // chart
    5356      //
    54       chartArea1.Name = "ChartArea";
    55       this.chart.ChartAreas.Add(chartArea1);
    56       this.chart.Dock = System.Windows.Forms.DockStyle.Fill;
    57       legend1.Alignment = System.Drawing.StringAlignment.Center;
    58       legend1.Docking = System.Windows.Forms.DataVisualization.Charting.Docking.Top;
    59       legend1.Name = "Default";
    60       this.chart.Legends.Add(legend1);
    61       this.chart.Location = new System.Drawing.Point(0, 0);
     57      this.chart.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     58                  | System.Windows.Forms.AnchorStyles.Left)
     59                  | System.Windows.Forms.AnchorStyles.Right)));
     60      chartArea2.Name = "ChartArea";
     61      this.chart.ChartAreas.Add(chartArea2);
     62      legend2.Alignment = System.Drawing.StringAlignment.Center;
     63      legend2.Docking = System.Windows.Forms.DataVisualization.Charting.Docking.Top;
     64      legend2.Name = "Default";
     65      this.chart.Legends.Add(legend2);
     66      this.chart.Location = new System.Drawing.Point(0, 31);
    6267      this.chart.Name = "chart";
    63       this.chart.Size = new System.Drawing.Size(358, 225);
     68      this.chart.Size = new System.Drawing.Size(388, 194);
    6469      this.chart.TabIndex = 0;
    6570      this.chart.CustomizeLegend += new System.EventHandler<System.Windows.Forms.DataVisualization.Charting.CustomizeLegendEventArgs>(this.chart_CustomizeLegend);
     
    6873      this.chart.MouseMove += new System.Windows.Forms.MouseEventHandler(this.chart_MouseMove);
    6974      //
     75      // targetVariableComboBox
     76      //
     77      this.targetVariableComboBox.FormattingEnabled = true;
     78      this.targetVariableComboBox.Location = new System.Drawing.Point(91, 4);
     79      this.targetVariableComboBox.Name = "targetVariableComboBox";
     80      this.targetVariableComboBox.Size = new System.Drawing.Size(173, 21);
     81      this.targetVariableComboBox.TabIndex = 1;
     82      this.targetVariableComboBox.SelectedIndexChanged += new System.EventHandler(this.targetVariableComboBox_SelectedIndexChanged);
     83      //
     84      // label
     85      //
     86      this.label.AutoSize = true;
     87      this.label.Location = new System.Drawing.Point(4, 7);
     88      this.label.Name = "label";
     89      this.label.Size = new System.Drawing.Size(81, 13);
     90      this.label.TabIndex = 2;
     91      this.label.Text = "Target variable:";
     92      //
     93      // prognosedValuesCheckbox
     94      //
     95      this.prognosedValuesCheckbox.AutoSize = true;
     96      this.prognosedValuesCheckbox.Checked = true;
     97      this.prognosedValuesCheckbox.CheckState = System.Windows.Forms.CheckState.Checked;
     98      this.prognosedValuesCheckbox.Location = new System.Drawing.Point(271, 7);
     99      this.prognosedValuesCheckbox.Name = "prognosedValuesCheckbox";
     100      this.prognosedValuesCheckbox.Size = new System.Drawing.Size(112, 17);
     101      this.prognosedValuesCheckbox.TabIndex = 3;
     102      this.prognosedValuesCheckbox.Text = "Prognosed Values";
     103      this.prognosedValuesCheckbox.UseVisualStyleBackColor = true;
     104      this.prognosedValuesCheckbox.CheckedChanged += new System.EventHandler(this.prognosedValuesCheckbox_CheckedChanged);
     105      //
    70106      // TimeSeriesPrognosisSolutionLineChartView
    71107      //
     
    73109      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    74110      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
     111      this.Controls.Add(this.prognosedValuesCheckbox);
     112      this.Controls.Add(this.label);
     113      this.Controls.Add(this.targetVariableComboBox);
    75114      this.Controls.Add(this.chart);
    76115      this.Name = "TimeSeriesPrognosisSolutionLineChartView";
    77       this.Size = new System.Drawing.Size(358, 225);
     116      this.Size = new System.Drawing.Size(388, 225);
    78117      ((System.ComponentModel.ISupportInitialize)(this.chart)).EndInit();
    79118      this.ResumeLayout(false);
     119      this.PerformLayout();
    80120
    81121    }
     
    84124
    85125    private HeuristicLab.Visualization.ChartControlsExtensions.EnhancedChart chart;
     126    private System.Windows.Forms.ComboBox targetVariableComboBox;
     127    private System.Windows.Forms.Label label;
     128    private System.Windows.Forms.CheckBox prognosedValuesCheckbox;
    86129  }
    87130}
  • branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis.Views/3.4/TimeSeriesPrognosis/TimeSeriesPrognosisSolutionLineChartView.cs

    r6802 r7129  
    3636    private const string PROGNOSEDVALUES_TEST_SERIES_NAME = "Prognosed Values (test)";
    3737    private const string PROGNOSEDVALUES_ALL_SERIES_NAME = "Prognosed Values (all samples)";
     38    private string prevTargetVariable;
    3839
    3940    public new ITimeSeriesPrognosisSolution Content {
     
    5758    }
    5859
     60    private void UpdateTargetVariables() {
     61      // populate combobox
     62      targetVariableComboBox.Items.Clear();
     63      if (Content != null) {
     64        foreach (var targetVariable in Content.ProblemData.TargetVariables)
     65          targetVariableComboBox.Items.Add(targetVariable);
     66
     67        targetVariableComboBox.SelectedIndex = 0;
     68      }
     69    }
     70
     71
     72
    5973    private void RedrawChart() {
    6074      this.chart.Series.Clear();
     
    6276        this.chart.ChartAreas[0].AxisX.Minimum = 0;
    6377        this.chart.ChartAreas[0].AxisX.Maximum = Content.ProblemData.Dataset.Rows - 1;
     78        string targetVariable = (string)targetVariableComboBox.SelectedItem;
     79        int varIndex = Content.ProblemData.TargetVariables.ToList().IndexOf(targetVariable);
    6480
    6581        this.chart.Series.Add(TARGETVARIABLE_SERIES_NAME);
    66         this.chart.Series[TARGETVARIABLE_SERIES_NAME].LegendText = Content.ProblemData.TargetVariable;
     82        this.chart.Series[TARGETVARIABLE_SERIES_NAME].LegendText = targetVariable;
    6783        this.chart.Series[TARGETVARIABLE_SERIES_NAME].ChartType = SeriesChartType.FastLine;
    6884        this.chart.Series[TARGETVARIABLE_SERIES_NAME].Points.DataBindXY(Enumerable.Range(0, Content.ProblemData.Dataset.Rows).ToArray(),
    69           Content.ProblemData.Dataset.GetDoubleValues(Content.ProblemData.TargetVariable).ToArray());
     85          Content.ProblemData.Dataset.GetDoubleValues(targetVariable).ToArray());
    7086
    7187        this.chart.Series.Add(PROGNOSEDVALUES_TRAINING_SERIES_NAME);
    7288        this.chart.Series[PROGNOSEDVALUES_TRAINING_SERIES_NAME].LegendText = PROGNOSEDVALUES_TRAINING_SERIES_NAME;
    7389        this.chart.Series[PROGNOSEDVALUES_TRAINING_SERIES_NAME].ChartType = SeriesChartType.FastLine;
    74         this.chart.Series[PROGNOSEDVALUES_TRAINING_SERIES_NAME].Points.DataBindXY(Content.ProblemData.TrainingIndizes.ToArray(), Content.PrognosedTrainingValues.ToArray());
     90        if (prognosedValuesCheckbox.Checked) {
     91          this.chart.Series[PROGNOSEDVALUES_TRAINING_SERIES_NAME].Points
     92            .DataBindXY(Content.ProblemData.TrainingIndizes.ToArray(),
     93                        Content.PrognosedTrainingValues.ElementAt(varIndex).ToArray());
     94        } else {
     95          this.chart.Series[PROGNOSEDVALUES_TRAINING_SERIES_NAME].Points
     96            .DataBindXY(Content.ProblemData.TrainingIndizes.ToArray(),
     97                        Content.GetPrognosedValues(Content.ProblemData.TrainingIndizes, 1).Select(v => v.ElementAt(varIndex).First()).ToArray());
     98        }
    7599        this.chart.Series[PROGNOSEDVALUES_TRAINING_SERIES_NAME].Tag = Content;
    76100        this.chart.DataManipulator.InsertEmptyPoints(1, IntervalType.Number, PROGNOSEDVALUES_TRAINING_SERIES_NAME);
     
    82106        this.chart.Series[PROGNOSEDVALUES_TEST_SERIES_NAME].LegendText = PROGNOSEDVALUES_TEST_SERIES_NAME;
    83107        this.chart.Series[PROGNOSEDVALUES_TEST_SERIES_NAME].ChartType = SeriesChartType.FastLine;
    84         this.chart.Series[PROGNOSEDVALUES_TEST_SERIES_NAME].Points.DataBindXY(Content.ProblemData.TestIndizes.ToArray(), Content.PrognosedTestValues.ToArray());
     108        if (prognosedValuesCheckbox.Checked) {
     109          this.chart.Series[PROGNOSEDVALUES_TEST_SERIES_NAME].Points
     110            .DataBindXY(Content.ProblemData.TestIndizes.ToArray(),
     111                        Content.PrognosedTestValues.ElementAt(varIndex).ToArray());
     112        } else {
     113          this.chart.Series[PROGNOSEDVALUES_TEST_SERIES_NAME].Points
     114            .DataBindXY(Content.ProblemData.TestIndizes.ToArray(),
     115                        Content.GetPrognosedValues(Content.ProblemData.TestIndizes, 1).Select(
     116                          v => v.ElementAt(varIndex).First()).ToArray());
     117        }
    85118        this.chart.Series[PROGNOSEDVALUES_TEST_SERIES_NAME].Tag = Content;
    86 
    87 
    88         int[] allIndizes = Enumerable.Range(0, Content.ProblemData.Dataset.Rows).Except(Content.ProblemData.TrainingIndizes).Except(Content.ProblemData.TestIndizes).ToArray();
    89         var estimatedValues = Content.PrognosedValues.ToArray();
    90         List<double> allEstimatedValues = allIndizes.Select(index => estimatedValues[index]).ToList();
    91 
    92         this.chart.Series.Add(PROGNOSEDVALUES_ALL_SERIES_NAME);
    93         this.chart.Series[PROGNOSEDVALUES_ALL_SERIES_NAME].LegendText = PROGNOSEDVALUES_ALL_SERIES_NAME;
    94         this.chart.Series[PROGNOSEDVALUES_ALL_SERIES_NAME].ChartType = SeriesChartType.FastLine;
    95         this.chart.Series[PROGNOSEDVALUES_ALL_SERIES_NAME].Points.DataBindXY(allIndizes, allEstimatedValues);
    96         this.chart.Series[PROGNOSEDVALUES_ALL_SERIES_NAME].Tag = Content;
    97         this.chart.DataManipulator.InsertEmptyPoints(1, IntervalType.Number, PROGNOSEDVALUES_ALL_SERIES_NAME);
    98         this.chart.Series[PROGNOSEDVALUES_TRAINING_SERIES_NAME].EmptyPointStyle.BorderWidth = 0;
    99         this.chart.Series[PROGNOSEDVALUES_TRAINING_SERIES_NAME].EmptyPointStyle.MarkerStyle = MarkerStyle.None;
    100         this.ToggleSeriesData(this.chart.Series[PROGNOSEDVALUES_ALL_SERIES_NAME]);
    101119
    102120        UpdateCursorInterval();
     
    130148    protected override void OnContentChanged() {
    131149      base.OnContentChanged();
     150      UpdateTargetVariables();
     151    }
     152
     153    private void Content_ProblemDataChanged(object sender, EventArgs e) {
     154      UpdateTargetVariables();
     155    }
     156    private void Content_ModelChanged(object sender, EventArgs e) {
    132157      RedrawChart();
    133158    }
    134     private void Content_ProblemDataChanged(object sender, EventArgs e) {
     159
     160    private void targetVariableComboBox_SelectedIndexChanged(object sender, EventArgs e) {
    135161      RedrawChart();
    136162    }
    137     private void Content_ModelChanged(object sender, EventArgs e) {
     163    private void prognosedValuesCheckbox_CheckedChanged(object sender, EventArgs e) {
    138164      RedrawChart();
    139165    }
     
    207233        }
    208234      } else if (Content != null) {
    209         string targetVariableName = Content.ProblemData.TargetVariable;
     235        string targetVariable = (string)targetVariableComboBox.SelectedItem;
     236        int varIndex = Content.ProblemData.TargetVariables.ToList().IndexOf(targetVariable);
     237
    210238
    211239        IEnumerable<int> indizes = null;
    212240        IEnumerable<double> predictedValues = null;
    213241        switch (series.Name) {
    214           case PROGNOSEDVALUES_ALL_SERIES_NAME:
    215             indizes = Enumerable.Range(0, Content.ProblemData.Dataset.Rows).Except(Content.ProblemData.TrainingIndizes).Except(Content.ProblemData.TestIndizes).ToArray();
    216             var estimatedValues = Content.PrognosedValues.ToArray();
    217             predictedValues = indizes.Select(index => estimatedValues[index]).ToList();
    218             break;
    219242          case PROGNOSEDVALUES_TRAINING_SERIES_NAME:
    220243            indizes = Content.ProblemData.TrainingIndizes.ToArray();
    221             predictedValues = Content.PrognosedTrainingValues.ToArray();
     244            predictedValues = Content.PrognosedTrainingValues.ElementAt(varIndex).ToArray();
    222245            break;
    223246          case PROGNOSEDVALUES_TEST_SERIES_NAME:
    224247            indizes = Content.ProblemData.TestIndizes.ToArray();
    225             predictedValues = Content.PrognosedTestValues.ToArray();
     248            predictedValues = Content.PrognosedTestValues.ElementAt(varIndex).ToArray();
    226249            break;
    227250        }
     
    255278      e.LegendItems[3].Cells[1].ForeColor = this.chart.Series[PROGNOSEDVALUES_ALL_SERIES_NAME].Points.Count == 0 ? Color.Gray : Color.Black;
    256279    }
     280
    257281  }
    258282}
Note: See TracChangeset for help on using the changeset viewer.