Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/14/11 13:59:25 (13 years ago)
Author:
epitzer
Message:

#1530 integrate changes from trunk

Location:
branches/PersistenceSpeedUp
Files:
20 deleted
17 edited
30 copied

Legend:

Unmodified
Added
Removed
  • branches/PersistenceSpeedUp

  • branches/PersistenceSpeedUp/HeuristicLab.Problems.DataAnalysis.Views/3.3/HeuristicLabProblemsDataAnalysisViewsPlugin.cs.frame

    r6099 r6760  
    2626
    2727namespace HeuristicLab.Problems.DataAnalysis.Views {
    28   [Plugin("HeuristicLab.Problems.DataAnalysis.Views", "3.3.4.$WCREV$")]
     28  [Plugin("HeuristicLab.Problems.DataAnalysis.Views", "3.3.5.$WCREV$")]
    2929  [PluginFile("HeuristicLab.Problems.DataAnalysis.Views-3.3.dll", PluginFileType.Assembly)]
    3030  [PluginDependency("HeuristicLab.ALGLIB","3.1.0.0")]
  • branches/PersistenceSpeedUp/HeuristicLab.Problems.DataAnalysis.Views/3.3/Properties/AssemblyInfo.frame

    r6099 r6760  
    5353// by using the '*' as shown below:
    5454[assembly: AssemblyVersion("3.3.0.0")]
    55 [assembly: AssemblyFileVersion("3.3.4.$WCREV$")]
     55[assembly: AssemblyFileVersion("3.3.5.$WCREV$")]
  • branches/PersistenceSpeedUp/HeuristicLab.Problems.DataAnalysis.Views/3.4/Classification/ClassificationSolutionConfusionMatrixView.cs

    r5975 r6760  
    2424using System.Linq;
    2525using System.Windows.Forms;
    26 using HeuristicLab.Core.Views;
    2726using HeuristicLab.MainForm;
    2827using HeuristicLab.MainForm.WindowsForms;
     
    3130  [View("Confusion Matrix")]
    3231  [Content(typeof(IClassificationSolution))]
    33   public partial class ClassificationSolutionConfusionMatrixView : ItemView, IClassificationSolutionEvaluationView {
     32  public partial class ClassificationSolutionConfusionMatrixView : DataAnalysisSolutionEvaluationView {
    3433    private const string TrainingSamples = "Training";
    3534    private const string TestSamples = "Test";
     
    7877          dataGridView.ColumnCount = 1;
    7978        } else {
    80           dataGridView.ColumnCount = Content.ProblemData.Classes;
    81           dataGridView.RowCount = Content.ProblemData.Classes;
     79          dataGridView.ColumnCount = Content.ProblemData.Classes + 1;
     80          dataGridView.RowCount = Content.ProblemData.Classes + 1;
    8281
    8382          int i = 0;
     
    8786            i++;
    8887          }
     88          dataGridView.Columns[i].HeaderText = "Actual not classified";
     89          dataGridView.Rows[i].HeaderCell.Value = "Predicted not classified";
     90
    8991          dataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.ColumnHeader);
    9092          dataGridView.AutoResizeRowHeadersWidth(DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders);
     
    100102        if (Content == null) return;
    101103
    102         double[,] confusionMatrix = new double[Content.ProblemData.Classes, Content.ProblemData.Classes];
     104        double[,] confusionMatrix = new double[Content.ProblemData.Classes + 1, Content.ProblemData.Classes + 1];
    103105        IEnumerable<int> rows;
    104106
     107        double[] predictedValues;
    105108        if (cmbSamples.SelectedItem.ToString() == TrainingSamples) {
    106109          rows = Content.ProblemData.TrainingIndizes;
     110          predictedValues = Content.EstimatedTrainingClassValues.ToArray();
    107111        } else if (cmbSamples.SelectedItem.ToString() == TestSamples) {
    108112          rows = Content.ProblemData.TestIndizes;
     113          predictedValues = Content.EstimatedTestClassValues.ToArray();
    109114        } else throw new InvalidOperationException();
     115
     116        double[] targetValues = Content.ProblemData.Dataset.GetDoubleValues(Content.ProblemData.TargetVariable, rows).ToArray();
    110117
    111118        Dictionary<double, int> classValueIndexMapping = new Dictionary<double, int>();
     
    116123        }
    117124
    118         double[] targetValues = Content.ProblemData.Dataset.GetEnumeratedVariableValues(Content.ProblemData.TargetVariable, rows).ToArray();
    119         double[] predictedValues = Content.GetEstimatedClassValues(rows).ToArray();
    120 
    121125        for (int i = 0; i < targetValues.Length; i++) {
    122126          double targetValue = targetValues[i];
    123127          double predictedValue = predictedValues[i];
    124           int targetIndex = classValueIndexMapping[targetValue];
    125           int predictedIndex = classValueIndexMapping[predictedValue];
     128          int targetIndex;
     129          int predictedIndex;
     130          if (!classValueIndexMapping.TryGetValue(targetValue, out targetIndex)) {
     131            targetIndex = Content.ProblemData.Classes;
     132          }
     133          if (!classValueIndexMapping.TryGetValue(predictedValue, out predictedIndex)) {
     134            predictedIndex = Content.ProblemData.Classes;
     135          }
    126136
    127137          confusionMatrix[predictedIndex, targetIndex] += 1;
  • branches/PersistenceSpeedUp/HeuristicLab.Problems.DataAnalysis.Views/3.4/Classification/ClassificationSolutionEstimatedClassValuesView.cs

    r5975 r6760  
    2222using System.Linq;
    2323using System.Windows.Forms;
    24 using HeuristicLab.Core.Views;
    2524using HeuristicLab.Data;
    2625using HeuristicLab.Data.Views;
     
    3130  [View("Estimated Class Values")]
    3231  [Content(typeof(IClassificationSolution))]
    33   public partial class ClassificationSolutionEstimatedClassValuesView : ItemView, IClassificationSolutionEvaluationView {
    34     private const string TARGETVARIABLE_SERIES_NAME = "TargetVariable";
    35     private const string ESTIMATEDVALUES_SERIES_NAME = "EstimatedClassValues";
     32  public partial class ClassificationSolutionEstimatedClassValuesView : DataAnalysisSolutionEvaluationView {
     33    private const string TARGETVARIABLE_SERIES_NAME = "Target Variable";
     34    private const string ESTIMATEDVALUES_SERIES_NAME = "Estimated Class Values (all)";
     35    private const string ESTIMATEDVALUES_TRAINING_SERIES_NAME = "Estimated Class Values (training)";
     36    private const string ESTIMATEDVALUES_TEST_SERIES_NAME = "Estimated Class Values (test)";
    3637
    3738    public new IClassificationSolution Content {
    3839      get { return (IClassificationSolution)base.Content; }
    39       set {
    40         base.Content = value;
    41       }
     40      set { base.Content = value; }
    4241    }
    4342
    44     private StringConvertibleMatrixView matrixView;
     43    protected StringConvertibleMatrixView matrixView;
    4544
    4645    public ClassificationSolutionEstimatedClassValuesView()
     
    8079    }
    8180
    82     private void UpdateEstimatedValues() {
     81    protected virtual void UpdateEstimatedValues() {
    8382      if (InvokeRequired) Invoke((Action)UpdateEstimatedValues);
    8483      else {
    85         DoubleMatrix matrix = null;
     84        StringMatrix matrix = null;
    8685        if (Content != null) {
    87           double[,] values = new double[Content.ProblemData.Dataset.Rows, 2];
     86          string[,] values = new string[Content.ProblemData.Dataset.Rows, 5];
    8887
    89           double[] target = Content.ProblemData.Dataset.GetVariableValues(Content.ProblemData.TargetVariable);
     88          double[] target = Content.ProblemData.Dataset.GetDoubleValues(Content.ProblemData.TargetVariable).ToArray();
    9089          double[] estimated = Content.EstimatedClassValues.ToArray();
    9190          for (int row = 0; row < target.Length; row++) {
    92             values[row, 0] = target[row];
    93             values[row, 1] = estimated[row];
     91            values[row, 0] = row.ToString();
     92            values[row, 1] = target[row].ToString();
     93            values[row, 2] = estimated[row].ToString();
    9494          }
    9595
    96           matrix = new DoubleMatrix(values);
    97           matrix.ColumnNames = new string[] { TARGETVARIABLE_SERIES_NAME, ESTIMATEDVALUES_SERIES_NAME };
     96          var estimatedTraining = Content.EstimatedTrainingClassValues.GetEnumerator();
     97          estimatedTraining.MoveNext();
     98          foreach (var trainingRow in Content.ProblemData.TrainingIndizes) {
     99            values[trainingRow, 3] = estimatedTraining.Current.ToString();
     100            estimatedTraining.MoveNext();
     101          }
     102          var estimatedTest = Content.EstimatedTestClassValues.GetEnumerator();
     103          estimatedTest.MoveNext();
     104          foreach (var testRow in Content.ProblemData.TestIndizes) {
     105            values[testRow, 4] = estimatedTest.Current.ToString();
     106            estimatedTest.MoveNext();
     107          }
     108
     109          matrix = new StringMatrix(values);
     110          matrix.ColumnNames = new string[] { "Id", TARGETVARIABLE_SERIES_NAME, ESTIMATEDVALUES_SERIES_NAME, ESTIMATEDVALUES_TRAINING_SERIES_NAME, ESTIMATEDVALUES_TEST_SERIES_NAME };
     111          matrix.SortableView = true;
    98112        }
    99113        matrixView.Content = matrix;
  • branches/PersistenceSpeedUp/HeuristicLab.Problems.DataAnalysis.Views/3.4/Classification/DiscriminantFunctionClassificationRocCurvesView.cs

    r5975 r6760  
    2828using System.Windows.Forms.DataVisualization.Charting;
    2929using HeuristicLab.Common;
    30 using HeuristicLab.Core.Views;
    3130using HeuristicLab.MainForm;
    3231using HeuristicLab.MainForm.WindowsForms;
     
    3433  [View("ROC Curves")]
    3534  [Content(typeof(IDiscriminantFunctionClassificationSolution))]
    36   public partial class DiscriminantFunctionClassificationRocCurvesView : ItemView, IDiscriminantFunctionClassificationSolutionEvaluationView {
     35  public partial class DiscriminantFunctionClassificationRocCurvesView : DataAnalysisSolutionEvaluationView {
    3736    private const string xAxisTitle = "False Positive Rate";
    3837    private const string yAxisTitle = "True Positive Rate";
     
    108107
    109108        double[] estimatedValues = Content.GetEstimatedValues(rows).ToArray();
    110         double[] targetClassValues = Content.ProblemData.Dataset.GetEnumeratedVariableValues(Content.ProblemData.TargetVariable, rows).ToArray();
     109        double[] targetClassValues = Content.ProblemData.Dataset.GetDoubleValues(Content.ProblemData.TargetVariable, rows).ToArray();
    111110        double minThreshold = estimatedValues.Min();
    112111        double maxThreshold = estimatedValues.Max();
  • branches/PersistenceSpeedUp/HeuristicLab.Problems.DataAnalysis.Views/3.4/Classification/DiscriminantFunctionClassificationSolutionEstimatedClassValuesView.cs

    r5975 r6760  
    2222using System.Linq;
    2323using System.Windows.Forms;
    24 using HeuristicLab.Core.Views;
    2524using HeuristicLab.Data;
    26 using HeuristicLab.Data.Views;
    2725using HeuristicLab.MainForm;
    2826using HeuristicLab.MainForm.WindowsForms;
     
    3129  [View("Estimated Class Values")]
    3230  [Content(typeof(IDiscriminantFunctionClassificationSolution))]
    33   public partial class DiscriminantFunctionClassificationSolutionEstimatedClassValuesView : ItemView, IDiscriminantFunctionClassificationSolutionEvaluationView {
     31  public partial class DiscriminantFunctionClassificationSolutionEstimatedClassValuesView : ClassificationSolutionEstimatedClassValuesView {
    3432    private const string TargetClassValuesSeriesname = "TargetVariable";
    3533    private const string EstimatedClassValuesSeriesName = "EstimatedClassValues";
     
    3836    public new IDiscriminantFunctionClassificationSolution Content {
    3937      get { return (IDiscriminantFunctionClassificationSolution)base.Content; }
    40       set {
    41         base.Content = value;
    42       }
     38      set { base.Content = value; }
    4339    }
    44 
    45     private StringConvertibleMatrixView matrixView;
    4640
    4741    public DiscriminantFunctionClassificationSolutionEstimatedClassValuesView()
    4842      : base() {
    4943      InitializeComponent();
    50       matrixView = new StringConvertibleMatrixView();
    51       matrixView.ShowRowsAndColumnsTextBox = false;
    52       matrixView.ShowStatisticalInformation = false;
    53       matrixView.Dock = DockStyle.Fill;
    54       this.Controls.Add(matrixView);
    5544    }
    5645
    57     #region events
    58     protected override void RegisterContentEvents() {
    59       base.RegisterContentEvents();
    60       Content.ModelChanged += new EventHandler(Content_ModelChanged);
    61       Content.ProblemDataChanged += new EventHandler(Content_ProblemDataChanged);
    62     }
    63 
    64     protected override void DeregisterContentEvents() {
    65       base.DeregisterContentEvents();
    66       Content.ModelChanged -= new EventHandler(Content_ModelChanged);
    67       Content.ProblemDataChanged -= new EventHandler(Content_ProblemDataChanged);
    68     }
    69 
    70     private void Content_ProblemDataChanged(object sender, EventArgs e) {
    71       OnContentChanged();
    72     }
    73 
    74     private void Content_ModelChanged(object sender, EventArgs e) {
    75       OnContentChanged();
    76     }
    77 
    78     protected override void OnContentChanged() {
    79       base.OnContentChanged();
    80       UpdateEstimatedValues();
    81     }
    82 
    83     private void UpdateEstimatedValues() {
     46    protected override void UpdateEstimatedValues() {
    8447      if (InvokeRequired) Invoke((Action)UpdateEstimatedValues);
    8548      else {
    86         DoubleMatrix matrix = null;
     49        StringMatrix matrix = null;
    8750        if (Content != null) {
    88           double[,] values = new double[Content.ProblemData.Dataset.Rows, 3];
     51          string[,] values = new string[Content.ProblemData.Dataset.Rows, 4];
    8952
    90           double[] target = Content.ProblemData.Dataset.GetVariableValues(Content.ProblemData.TargetVariable);
     53          double[] target = Content.ProblemData.Dataset.GetDoubleValues(Content.ProblemData.TargetVariable).ToArray();
    9154          double[] estimatedClassValues = Content.EstimatedClassValues.ToArray();
    9255          double[] estimatedValues = Content.EstimatedValues.ToArray();
    9356          for (int row = 0; row < target.Length; row++) {
    94             values[row, 0] = target[row];
    95             values[row, 1] = estimatedClassValues[row];
    96             values[row, 2] = estimatedValues[row];
     57            values[row, 0] = row.ToString();
     58            values[row, 1] = target[row].ToString();
     59            values[row, 2] = estimatedClassValues[row].ToString();
     60            values[row, 3] = estimatedValues[row].ToString();
    9761          }
    9862
    99           matrix = new DoubleMatrix(values);
    100           matrix.ColumnNames = new string[] { TargetClassValuesSeriesname, EstimatedClassValuesSeriesName, EstimatedValuesSeriesName };
     63          matrix = new StringMatrix(values);
     64          matrix.ColumnNames = new string[] { "Id", TargetClassValuesSeriesname, EstimatedClassValuesSeriesName, EstimatedValuesSeriesName };
     65          matrix.SortableView = true;
    10166        }
    10267        matrixView.Content = matrix;
    10368      }
    10469    }
    105     #endregion
    10670  }
    10771}
  • branches/PersistenceSpeedUp/HeuristicLab.Problems.DataAnalysis.Views/3.4/Classification/DiscriminantFunctionClassificationSolutionThresholdView.cs

    r5975 r6760  
    2727using System.Windows.Forms.DataVisualization.Charting;
    2828using HeuristicLab.Common;
    29 using HeuristicLab.Core.Views;
    3029using HeuristicLab.MainForm;
    3130using HeuristicLab.MainForm.WindowsForms;
     
    3332namespace HeuristicLab.Problems.DataAnalysis.Views {
    3433  [View("Classification Threshold")]
    35   [Content(typeof(IDiscriminantFunctionClassificationSolution), true)]
    36   public sealed partial class DiscriminantFunctionClassificationSolutionThresholdView : ItemView, IDiscriminantFunctionClassificationSolutionEvaluationView {
     34  [Content(typeof(IDiscriminantFunctionClassificationSolution), false)]
     35  public sealed partial class DiscriminantFunctionClassificationSolutionThresholdView : DataAnalysisSolutionEvaluationView {
    3736    private const double TrainingAxisValue = 0.0;
    3837    private const double TestAxisValue = 10.0;
     
    136135    private void FillSeriesWithDataPoints(Series series) {
    137136      List<double> estimatedValues = Content.EstimatedValues.ToList();
     137      var targetValues = Content.ProblemData.Dataset.GetDoubleValues(Content.ProblemData.TargetVariable).ToList();
     138
    138139      foreach (int row in Content.ProblemData.TrainingIndizes) {
    139140        double estimatedValue = estimatedValues[row];
    140         double targetValue = Content.ProblemData.Dataset[Content.ProblemData.TargetVariable, row];
     141        double targetValue = targetValues[row];
    141142        if (targetValue.IsAlmost((double)series.Tag)) {
    142143          double jitterValue = random.NextDouble() * 2.0 - 1.0;
     
    151152      foreach (int row in Content.ProblemData.TestIndizes) {
    152153        double estimatedValue = estimatedValues[row];
    153         double targetValue = Content.ProblemData.Dataset[Content.ProblemData.TargetVariable, row];
    154         if (targetValue == (double)series.Tag) {
     154        double targetValue = targetValues[row];
     155        if (targetValue.IsAlmost((double)series.Tag)) {
    155156          double jitterValue = random.NextDouble() * 2.0 - 1.0;
    156157          DataPoint point = new DataPoint();
  • branches/PersistenceSpeedUp/HeuristicLab.Problems.DataAnalysis.Views/3.4/Clustering/ClusteringSolutionEstimatedClusterView.cs

    r6003 r6760  
    2222using System.Linq;
    2323using System.Windows.Forms;
    24 using HeuristicLab.Core.Views;
    2524using HeuristicLab.Data;
    2625using HeuristicLab.Data.Views;
     
    3130  [View("Estimated Clusters")]
    3231  [Content(typeof(IClusteringSolution))]
    33   public partial class ClusteringSolutionEstimatedClusterView : ItemView, IClusteringSolutionEvaluationView {
     32  public partial class ClusteringSolutionEstimatedClusterView : DataAnalysisSolutionEvaluationView {
    3433    private const string CLUSTER_NAMES = "Cluster";
    3534
     
    8685          int[] clusters = Content.Model.GetClusterValues(Content.ProblemData.Dataset, Enumerable.Range(0, Content.ProblemData.Dataset.Rows)).ToArray();
    8786          var dataset = Content.ProblemData.Dataset;
    88           int columns = Content.ProblemData.AllowedInputVariables.Count() + 1;
    89           var columnsIndixes = Content.ProblemData.AllowedInputVariables.Select(x => dataset.GetVariableIndex(x)).ToList();
     87          int columns = Content.ProblemData.AllowedInputVariables.Count() + 1;         
    9088
    9189          double[,] values = new double[dataset.Rows, columns];
     
    9492
    9593            int column = 1;
    96             foreach (int columnIndex in columnsIndixes) {
    97               values[row, column] = dataset[row, columnIndex];
     94            foreach (var columnName in Content.ProblemData.AllowedInputVariables) {
     95              values[row, column] = dataset.GetDoubleValue(columnName, row);
    9896              column++;
    9997            }
  • branches/PersistenceSpeedUp/HeuristicLab.Problems.DataAnalysis.Views/3.4/HeuristicLab.Problems.DataAnalysis.Views-3.4.csproj

    r6184 r6760  
    110110  </ItemGroup>
    111111  <ItemGroup>
    112     <Compile Include="ClassificationSolutionView.cs">
    113       <SubType>UserControl</SubType>
    114     </Compile>
    115     <Compile Include="ClassificationSolutionView.Designer.cs">
     112    <Compile Include="Classification\ClassificationEnsembleSolutionEstimatedClassValuesView.cs">
     113      <SubType>UserControl</SubType>
     114    </Compile>
     115    <Compile Include="Classification\ClassificationEnsembleSolutionEstimatedClassValuesView.Designer.cs">
     116      <DependentUpon>ClassificationEnsembleSolutionEstimatedClassValuesView.cs</DependentUpon>
     117    </Compile>
     118    <Compile Include="Classification\ClassificationEnsembleSolutionModelView.cs">
     119      <SubType>UserControl</SubType>
     120    </Compile>
     121    <Compile Include="Classification\ClassificationEnsembleSolutionModelView.Designer.cs">
     122      <DependentUpon>ClassificationEnsembleSolutionModelView.cs</DependentUpon>
     123    </Compile>
     124    <Compile Include="DataAnalysisSolutionEvaluationView.cs">
     125      <SubType>UserControl</SubType>
     126    </Compile>
     127    <Compile Include="DataAnalysisSolutionEvaluationView.Designer.cs">
     128      <DependentUpon>DataAnalysisSolutionEvaluationView.cs</DependentUpon>
     129    </Compile>
     130    <Compile Include="Regression\RegressionSolutionErrorCharacteristicsCurveView.cs">
     131      <SubType>UserControl</SubType>
     132    </Compile>
     133    <Compile Include="Regression\RegressionSolutionErrorCharacteristicsCurveView.Designer.cs">
     134      <DependentUpon>RegressionSolutionErrorCharacteristicsCurveView.cs</DependentUpon>
     135    </Compile>
     136    <Compile Include="Regression\RegressionEnsembleSolutionModelView.cs">
     137      <SubType>UserControl</SubType>
     138    </Compile>
     139    <Compile Include="Regression\RegressionEnsembleSolutionModelView.Designer.cs">
     140      <DependentUpon>RegressionEnsembleSolutionModelView.cs</DependentUpon>
     141    </Compile>
     142    <Compile Include="Solution Views\ClassificationSolutionView.cs">
     143      <SubType>UserControl</SubType>
     144    </Compile>
     145    <Compile Include="Solution Views\ClassificationSolutionView.Designer.cs">
    116146      <DependentUpon>ClassificationSolutionView.cs</DependentUpon>
    117147    </Compile>
     
    152182      <DependentUpon>ClusteringSolutionEstimatedClusterView.cs</DependentUpon>
    153183    </Compile>
    154     <Compile Include="ClusteringSolutionView.cs">
    155       <SubType>UserControl</SubType>
    156     </Compile>
    157     <Compile Include="ClusteringSolutionView.Designer.cs">
     184    <Compile Include="Solution Views\ClusteringSolutionView.cs">
     185      <SubType>UserControl</SubType>
     186    </Compile>
     187    <Compile Include="Solution Views\ClusteringSolutionView.Designer.cs">
    158188      <DependentUpon>ClusteringSolutionView.cs</DependentUpon>
    159189    </Compile>
    160     <Compile Include="Interfaces\IRegressionEnsembleSolutionEvaluationView.cs" />
    161     <Compile Include="RegressionEnsembleSolutionView.cs">
    162       <SubType>UserControl</SubType>
    163     </Compile>
    164     <Compile Include="RegressionEnsembleSolutionView.Designer.cs">
    165       <DependentUpon>RegressionEnsembleSolutionView.cs</DependentUpon>
    166     </Compile>
    167     <Compile Include="DiscriminantFunctionClassificationSolutionView.cs">
    168       <SubType>UserControl</SubType>
    169     </Compile>
    170     <Compile Include="DiscriminantFunctionClassificationSolutionView.Designer.cs">
     190    <Compile Include="Solution Views\ClassificationEnsembleSolutionView.cs">
     191      <SubType>UserControl</SubType>
     192    </Compile>
     193    <Compile Include="Solution Views\ClassificationEnsembleSolutionView.Designer.cs">
     194      <DependentUpon>ClassificationEnsembleSolutionView.cs</DependentUpon>
     195    </Compile>
     196    <Compile Include="Solution Views\DiscriminantFunctionClassificationSolutionView.cs">
     197      <SubType>UserControl</SubType>
     198    </Compile>
     199    <Compile Include="Solution Views\DiscriminantFunctionClassificationSolutionView.Designer.cs">
    171200      <DependentUpon>DiscriminantFunctionClassificationSolutionView.cs</DependentUpon>
    172201    </Compile>
    173     <Compile Include="Interfaces\IDataAnalysisSolutionEvaluationView.cs" />
    174     <Compile Include="Interfaces\IDiscriminantFunctionClassificationSolutionEvaluationView.cs" />
    175     <Compile Include="Interfaces\IClusteringSolutionEvaluationView.cs" />
    176     <Compile Include="Interfaces\IClassificationSolutionEvaluationView.cs" />
    177     <Compile Include="DataAnalysisSolutionView.cs">
    178       <SubType>UserControl</SubType>
    179     </Compile>
    180     <Compile Include="DataAnalysisSolutionView.Designer.cs">
     202    <Compile Include="Solution Views\DataAnalysisSolutionView.cs">
     203      <SubType>UserControl</SubType>
     204    </Compile>
     205    <Compile Include="Solution Views\DataAnalysisSolutionView.Designer.cs">
    181206      <DependentUpon>DataAnalysisSolutionView.cs</DependentUpon>
    182207    </Compile>
     
    187212      <DependentUpon>DoubleLimitView.cs</DependentUpon>
    188213    </Compile>
    189     <Compile Include="Interfaces\IRegressionSolutionEvaluationView.cs" />
    190     <Compile Include="RegressionSolutionView.cs">
    191       <SubType>UserControl</SubType>
    192     </Compile>
    193     <Compile Include="RegressionSolutionView.Designer.cs">
     214    <Compile Include="Interfaces\IDataAnalysisSolutionEvaluationView.cs" />
     215    <Compile Include="MenuItems\CreateEnsembleMenuItem.cs" />
     216    <Compile Include="Solution Views\NamedDataAnalysisSolutionView.cs">
     217      <SubType>UserControl</SubType>
     218    </Compile>
     219    <Compile Include="Solution Views\NamedDataAnalysisSolutionView.Designer.cs">
     220      <DependentUpon>NamedDataAnalysisSolutionView.cs</DependentUpon>
     221    </Compile>
     222    <Compile Include="Solution Views\RegressionEnsembleSolutionView.cs">
     223      <SubType>UserControl</SubType>
     224    </Compile>
     225    <Compile Include="Solution Views\RegressionEnsembleSolutionView.Designer.cs">
     226      <DependentUpon>RegressionEnsembleSolutionView.cs</DependentUpon>
     227    </Compile>
     228    <Compile Include="Solution Views\RegressionSolutionView.cs">
     229      <SubType>UserControl</SubType>
     230    </Compile>
     231    <Compile Include="Solution Views\RegressionSolutionView.Designer.cs">
    194232      <DependentUpon>RegressionSolutionView.cs</DependentUpon>
    195     </Compile>
    196     <Compile Include="Regression\RegressionEnsembleSolutionLineChartView.cs">
    197       <SubType>UserControl</SubType>
    198     </Compile>
    199     <Compile Include="Regression\RegressionEnsembleSolutionLineChartView.Designer.cs">
    200       <DependentUpon>RegressionEnsembleSolutionLineChartView.cs</DependentUpon>
    201     </Compile>
    202     <Compile Include="Regression\RegressionEnsembleSolutionScatterPlotView.cs">
    203       <SubType>UserControl</SubType>
    204     </Compile>
    205     <Compile Include="Regression\RegressionEnsembleSolutionScatterPlotView.Designer.cs">
    206       <DependentUpon>RegressionEnsembleSolutionScatterPlotView.cs</DependentUpon>
    207233    </Compile>
    208234    <Compile Include="Regression\RegressionSolutionEstimatedValuesView.cs">
     
    288314      <Project>{14AB8D24-25BC-400C-A846-4627AA945192}</Project>
    289315      <Name>HeuristicLab.Optimization-3.3</Name>
     316    </ProjectReference>
     317    <ProjectReference Include="..\..\HeuristicLab.Optimizer\3.3\HeuristicLab.Optimizer-3.3.csproj">
     318      <Project>{C664305E-497C-4533-A140-967DEDB05C19}</Project>
     319      <Name>HeuristicLab.Optimizer-3.3</Name>
    290320    </ProjectReference>
    291321    <ProjectReference Include="..\..\HeuristicLab.Parameters.Views\3.3\HeuristicLab.Parameters.Views-3.3.csproj">
     
    327357    </BootstrapperPackage>
    328358  </ItemGroup>
    329   <ItemGroup />
    330359  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
    331360  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
  • branches/PersistenceSpeedUp/HeuristicLab.Problems.DataAnalysis.Views/3.4/HeuristicLabProblemsDataAnalysisViewsPlugin.cs.frame

    r5869 r6760  
    2626
    2727namespace HeuristicLab.Problems.DataAnalysis.Views {
    28   [Plugin("HeuristicLab.Problems.DataAnalysis.Views", "Provides views for base classes for data analysis tasks.", "3.4.0.$WCREV$")]
     28  [Plugin("HeuristicLab.Problems.DataAnalysis.Views", "Provides views for base classes for data analysis tasks.", "3.4.1.$WCREV$")]
    2929  [PluginFile("HeuristicLab.Problems.DataAnalysis.Views-3.4.dll", PluginFileType.Assembly)]
    3030  [PluginDependency("HeuristicLab.ALGLIB","3.1.0.0")]
     
    3939  [PluginDependency("HeuristicLab.Optimization","3.3")]
    4040  [PluginDependency("HeuristicLab.Optimization.Views","3.3")]
     41  [PluginDependency("HeuristicLab.Optimizer", "3.3")]
    4142  [PluginDependency("HeuristicLab.Problems.DataAnalysis", "3.4")]
    4243  [PluginDependency("HeuristicLab.Visualization.ChartControlsExtensions", "3.3")]
  • branches/PersistenceSpeedUp/HeuristicLab.Problems.DataAnalysis.Views/3.4/Properties/AssemblyInfo.frame

    r5869 r6760  
    5353// by using the '*' as shown below:
    5454[assembly: AssemblyVersion("3.4.0.0")]
    55 [assembly: AssemblyFileVersion("3.4.0.$WCREV$")]
     55[assembly: AssemblyFileVersion("3.4.1.$WCREV$")]
  • branches/PersistenceSpeedUp/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionEstimatedValuesView.cs

    r6058 r6760  
    2222using System.Linq;
    2323using System.Windows.Forms;
    24 using HeuristicLab.Core.Views;
    2524using HeuristicLab.Data;
    2625using HeuristicLab.Data.Views;
     
    3130  [View("Estimated Values")]
    3231  [Content(typeof(IRegressionSolution))]
    33   public partial class RegressionSolutionEstimatedValuesView : ItemView, IRegressionSolutionEvaluationView {
    34     private const string TARGETVARIABLE_SERIES_NAME = "TargetVariable";
    35     private const string ESTIMATEDVALUES_SERIES_NAME = "EstimatedValues";
     32  public partial class RegressionSolutionEstimatedValuesView : DataAnalysisSolutionEvaluationView {
     33    private const string TARGETVARIABLE_SERIES_NAME = "Target Variable";
     34    private const string ESTIMATEDVALUES_SERIES_NAME = "Estimated Values (all)";
     35    private const string ESTIMATEDVALUES_TRAINING_SERIES_NAME = "Estimated Values (training)";
     36    private const string ESTIMATEDVALUES_TEST_SERIES_NAME = "Estimated Values (test)";
    3637
    3738    public new IRegressionSolution Content {
     
    8384      if (InvokeRequired) Invoke((Action)UpdateEstimatedValues);
    8485      else {
    85         DoubleMatrix matrix = null;
     86        StringMatrix matrix = null;
    8687        if (Content != null) {
    87           double[,] values = new double[Content.ProblemData.Dataset.Rows, 4];
     88          string[,] values = new string[Content.ProblemData.Dataset.Rows, 7];
    8889
    89           double[] target = Content.ProblemData.Dataset.GetVariableValues(Content.ProblemData.TargetVariable);
    90           double[] estimated = Content.EstimatedValues.ToArray();
    91           for (int row = 0; row < target.Length; row++) {
    92             values[row, 0] = target[row];
    93             values[row, 1] = estimated[row];
    94             values[row, 2] = Math.Abs(estimated[row] - target[row]);
    95             values[row, 3] = Math.Abs(values[row, 2] / target[row]);
     90          double[] target = Content.ProblemData.Dataset.GetDoubleValues(Content.ProblemData.TargetVariable).ToArray();
     91          var estimated = Content.EstimatedValues.GetEnumerator();
     92          var estimated_training = Content.EstimatedTrainingValues.GetEnumerator();
     93          var estimated_test = Content.EstimatedTestValues.GetEnumerator();
     94
     95          foreach (var row in Content.ProblemData.TrainingIndizes) {
     96            estimated_training.MoveNext();
     97            values[row, 3] = estimated_training.Current.ToString();
    9698          }
    9799
    98           matrix = new DoubleMatrix(values);
    99           matrix.ColumnNames = new string[] { TARGETVARIABLE_SERIES_NAME, ESTIMATEDVALUES_SERIES_NAME, "Absolute Error", "Relative Error" };
     100          foreach (var row in Content.ProblemData.TestIndizes) {
     101            estimated_test.MoveNext();
     102            values[row, 4] = estimated_test.Current.ToString();
     103          }
     104
     105          foreach (var row in Enumerable.Range(0, Content.ProblemData.Dataset.Rows)) {
     106            estimated.MoveNext();
     107            double est = estimated.Current;
     108            double res = Math.Abs(est - target[row]);
     109            values[row, 0] = row.ToString();
     110            values[row, 1] = target[row].ToString();
     111            values[row, 2] = est.ToString();
     112            values[row, 5] = Math.Abs(res).ToString();
     113            values[row, 6] = Math.Abs(res / est).ToString();
     114          }
     115
     116          matrix = new StringMatrix(values);
     117          matrix.ColumnNames = new string[] { "Id", TARGETVARIABLE_SERIES_NAME, ESTIMATEDVALUES_SERIES_NAME, ESTIMATEDVALUES_TRAINING_SERIES_NAME, ESTIMATEDVALUES_TEST_SERIES_NAME, "Absolute Error (all)", "Relative Error (all)" };
     118          matrix.SortableView = true;
    100119        }
    101120        matrixView.Content = matrix;
  • branches/PersistenceSpeedUp/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionLineChartView.Designer.cs

    r5809 r6760  
    6363      this.chart.Size = new System.Drawing.Size(358, 225);
    6464      this.chart.TabIndex = 0;
     65      this.chart.CustomizeLegend += new System.EventHandler<System.Windows.Forms.DataVisualization.Charting.CustomizeLegendEventArgs>(this.chart_CustomizeLegend);
    6566      this.chart.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.Chart_MouseDoubleClick);
     67      this.chart.MouseDown += new System.Windows.Forms.MouseEventHandler(this.chart_MouseDown);
     68      this.chart.MouseMove += new System.Windows.Forms.MouseEventHandler(this.chart_MouseMove);
    6669      //
    67       // LineChartView
     70      // RegressionSolutionLineChartView
    6871      //
    6972      this.AllowDrop = true;
     
    7174      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    7275      this.Controls.Add(this.chart);
    73       this.Name = "LineChartView";
     76      this.Name = "RegressionSolutionLineChartView";
    7477      this.Size = new System.Drawing.Size(358, 225);
    7578      ((System.ComponentModel.ISupportInitialize)(this.chart)).EndInit();
  • branches/PersistenceSpeedUp/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionLineChartView.cs

    r5975 r6760  
    2020#endregion
    2121using System;
     22using System.Collections.Generic;
    2223using System.Drawing;
    2324using System.Linq;
    2425using System.Windows.Forms;
    2526using System.Windows.Forms.DataVisualization.Charting;
    26 using HeuristicLab.Core.Views;
    2727using HeuristicLab.MainForm;
    2828using HeuristicLab.MainForm.WindowsForms;
     
    3131  [View("Line Chart")]
    3232  [Content(typeof(IRegressionSolution))]
    33   public partial class RegressionSolutionLineChartView : ItemView, IRegressionSolutionEvaluationView {
    34     private const string TARGETVARIABLE_SERIES_NAME = "TargetVariable";
    35     private const string ESTIMATEDVALUES_SERIES_NAME = "EstimatedValues";
     33  public partial class RegressionSolutionLineChartView : DataAnalysisSolutionEvaluationView {
     34    private const string TARGETVARIABLE_SERIES_NAME = "Target Variable";
     35    private const string ESTIMATEDVALUES_TRAINING_SERIES_NAME = "Estimated Values (training)";
     36    private const string ESTIMATEDVALUES_TEST_SERIES_NAME = "Estimated Values (test)";
     37    private const string ESTIMATEDVALUES_ALL_SERIES_NAME = "Estimated Values (all samples)";
    3638
    3739    public new IRegressionSolution Content {
     
    4749      this.chart.ChartAreas[0].CursorX.IsUserSelectionEnabled = true;
    4850      this.chart.ChartAreas[0].AxisX.ScaleView.Zoomable = true;
     51      this.chart.ChartAreas[0].AxisX.IsStartedFromZero = true;
    4952      this.chart.ChartAreas[0].CursorX.Interval = 1;
    5053
     
    5760      this.chart.Series.Clear();
    5861      if (Content != null) {
     62        this.chart.ChartAreas[0].AxisX.Minimum = 0;
     63        this.chart.ChartAreas[0].AxisX.Maximum = Content.ProblemData.Dataset.Rows - 1;
     64
    5965        this.chart.Series.Add(TARGETVARIABLE_SERIES_NAME);
    6066        this.chart.Series[TARGETVARIABLE_SERIES_NAME].LegendText = Content.ProblemData.TargetVariable;
    6167        this.chart.Series[TARGETVARIABLE_SERIES_NAME].ChartType = SeriesChartType.FastLine;
    62         this.chart.Series[TARGETVARIABLE_SERIES_NAME].Points.DataBindY(Content.ProblemData.Dataset.GetVariableValues(Content.ProblemData.TargetVariable));
     68        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());
     70
     71        this.chart.Series.Add(ESTIMATEDVALUES_TRAINING_SERIES_NAME);
     72        this.chart.Series[ESTIMATEDVALUES_TRAINING_SERIES_NAME].LegendText = ESTIMATEDVALUES_TRAINING_SERIES_NAME;
     73        this.chart.Series[ESTIMATEDVALUES_TRAINING_SERIES_NAME].ChartType = SeriesChartType.FastLine;
     74        this.chart.Series[ESTIMATEDVALUES_TRAINING_SERIES_NAME].Points.DataBindXY(Content.ProblemData.TrainingIndizes.ToArray(), Content.EstimatedTrainingValues.ToArray());
     75        this.chart.Series[ESTIMATEDVALUES_TRAINING_SERIES_NAME].Tag = Content;
     76        this.chart.DataManipulator.InsertEmptyPoints(1, IntervalType.Number, ESTIMATEDVALUES_TRAINING_SERIES_NAME);
     77        this.chart.Series[ESTIMATEDVALUES_TRAINING_SERIES_NAME].EmptyPointStyle.BorderWidth = 0;
     78        this.chart.Series[ESTIMATEDVALUES_TRAINING_SERIES_NAME].EmptyPointStyle.MarkerStyle = MarkerStyle.None;
     79
     80
     81        this.chart.Series.Add(ESTIMATEDVALUES_TEST_SERIES_NAME);
     82        this.chart.Series[ESTIMATEDVALUES_TEST_SERIES_NAME].LegendText = ESTIMATEDVALUES_TEST_SERIES_NAME;
     83        this.chart.Series[ESTIMATEDVALUES_TEST_SERIES_NAME].ChartType = SeriesChartType.FastLine;
     84        this.chart.Series[ESTIMATEDVALUES_TEST_SERIES_NAME].Points.DataBindXY(Content.ProblemData.TestIndizes.ToArray(), Content.EstimatedTestValues.ToArray());
     85        this.chart.Series[ESTIMATEDVALUES_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.EstimatedValues.ToArray();
     90        List<double> allEstimatedValues = allIndizes.Select(index => estimatedValues[index]).ToList();
     91
     92        this.chart.Series.Add(ESTIMATEDVALUES_ALL_SERIES_NAME);
     93        this.chart.Series[ESTIMATEDVALUES_ALL_SERIES_NAME].LegendText = ESTIMATEDVALUES_ALL_SERIES_NAME;
     94        this.chart.Series[ESTIMATEDVALUES_ALL_SERIES_NAME].ChartType = SeriesChartType.FastLine;
     95        this.chart.Series[ESTIMATEDVALUES_ALL_SERIES_NAME].Points.DataBindXY(allIndizes, allEstimatedValues);
     96        this.chart.Series[ESTIMATEDVALUES_ALL_SERIES_NAME].Tag = Content;
     97        this.chart.DataManipulator.InsertEmptyPoints(1, IntervalType.Number, ESTIMATEDVALUES_ALL_SERIES_NAME);
     98        this.chart.Series[ESTIMATEDVALUES_TRAINING_SERIES_NAME].EmptyPointStyle.BorderWidth = 0;
     99        this.chart.Series[ESTIMATEDVALUES_TRAINING_SERIES_NAME].EmptyPointStyle.MarkerStyle = MarkerStyle.None;
     100        this.ToggleSeriesData(this.chart.Series[ESTIMATEDVALUES_ALL_SERIES_NAME]);
     101
     102        UpdateCursorInterval();
    63103        this.UpdateStripLines();
    64 
    65         this.chart.Series.Add(ESTIMATEDVALUES_SERIES_NAME);
    66         this.chart.Series[ESTIMATEDVALUES_SERIES_NAME].LegendText = Content.ItemName;
    67         this.chart.Series[ESTIMATEDVALUES_SERIES_NAME].ChartType = SeriesChartType.FastLine;
    68         this.chart.Series[ESTIMATEDVALUES_SERIES_NAME].Points.DataBindY(Content.EstimatedValues.ToArray());
    69         this.chart.Series[ESTIMATEDVALUES_SERIES_NAME].Tag = Content;
    70         UpdateCursorInterval();
    71104      }
    72105    }
    73106
    74107    private void UpdateCursorInterval() {
    75       var estimatedValues = this.chart.Series[ESTIMATEDVALUES_SERIES_NAME].Points.Select(x => x.YValues[0]).DefaultIfEmpty(1.0);
     108      var estimatedValues = this.chart.Series[ESTIMATEDVALUES_TRAINING_SERIES_NAME].Points.Select(x => x.YValues[0]).DefaultIfEmpty(1.0);
    76109      var targetValues = this.chart.Series[TARGETVARIABLE_SERIES_NAME].Points.Select(x => x.YValues[0]).DefaultIfEmpty(1.0);
    77110      double estimatedValuesRange = estimatedValues.Max() - estimatedValues.Min();
     
    95128    }
    96129
    97     private void Content_ProblemDataChanged(object sender, EventArgs e) {
    98       RedrawChart();
    99     }
    100 
    101     private void Content_ModelChanged(object sender, EventArgs e) {
    102       UpdateEstimatedValuesLineChart();
    103     }
    104 
    105130    protected override void OnContentChanged() {
    106131      base.OnContentChanged();
    107132      RedrawChart();
    108133    }
    109 
    110     private void UpdateEstimatedValuesLineChart() {
    111       if (InvokeRequired) Invoke((Action)UpdateEstimatedValuesLineChart);
    112       else {
    113         if (this.chart.Series.Count > 0) {
    114           Series s = this.chart.Series.SingleOrDefault(x => x.Tag == Content);
    115           if (s != null) {
    116             s.Points.DataBindY(Content.EstimatedValues.ToArray());
    117             s.LegendText = Content.ItemName;
    118             this.UpdateStripLines();
    119             UpdateCursorInterval();
    120           }
    121         }
    122       }
    123     }
     134    private void Content_ProblemDataChanged(object sender, EventArgs e) {
     135      RedrawChart();
     136    }
     137    private void Content_ModelChanged(object sender, EventArgs e) {
     138      RedrawChart();
     139    }
     140
     141
    124142
    125143    private void Chart_MouseDoubleClick(object sender, MouseEventArgs e) {
     
    136154    private void UpdateStripLines() {
    137155      this.chart.ChartAreas[0].AxisX.StripLines.Clear();
    138       this.CreateAndAddStripLine("Training", Color.FromArgb(20, Color.Green),
    139         Content.ProblemData.TrainingPartition.Start,
    140         Content.ProblemData.TrainingPartition.End);
    141       this.CreateAndAddStripLine("Test", Color.FromArgb(20, Color.Red),
    142         Content.ProblemData.TestPartition.Start,
    143         Content.ProblemData.TestPartition.End);
    144     }
    145 
    146     private void CreateAndAddStripLine(string title, Color c, int start, int end) {
     156
     157      int[] attr = new int[Content.ProblemData.Dataset.Rows + 1]; // add a virtual last row that is again empty to simplify loop further down
     158      foreach (var row in Content.ProblemData.TrainingIndizes) {
     159        attr[row] += 1;
     160      }
     161      foreach (var row in Content.ProblemData.TestIndizes) {
     162        attr[row] += 2;
     163      }
     164      int start = 0;
     165      int curAttr = attr[start];
     166      for (int row = 0; row < attr.Length; row++) {
     167        if (attr[row] != curAttr) {
     168          switch (curAttr) {
     169            case 0: break;
     170            case 1:
     171              this.CreateAndAddStripLine("Training", start, row, Color.FromArgb(40, Color.Green), Color.Transparent);
     172              break;
     173            case 2:
     174              this.CreateAndAddStripLine("Test", start, row, Color.FromArgb(40, Color.Red), Color.Transparent);
     175              break;
     176            case 3:
     177              this.CreateAndAddStripLine("Training and Test", start, row, Color.FromArgb(40, Color.Green), Color.FromArgb(40, Color.Red), ChartHatchStyle.WideUpwardDiagonal);
     178              break;
     179            default:
     180              // should not happen
     181              break;
     182          }
     183          curAttr = attr[row];
     184          start = row;
     185        }
     186      }
     187    }
     188
     189    private void CreateAndAddStripLine(string title, int start, int end, Color color, Color secondColor, ChartHatchStyle hatchStyle = ChartHatchStyle.None) {
    147190      StripLine stripLine = new StripLine();
    148       stripLine.BackColor = c;
     191      stripLine.BackColor = color;
     192      stripLine.BackSecondaryColor = secondColor;
     193      stripLine.BackHatchStyle = hatchStyle;
    149194      stripLine.Text = title;
    150195      stripLine.Font = new Font("Times New Roman", 12, FontStyle.Bold);
     196      // strip range is [start .. end] inclusive, but we evaluate [start..end[ (end is exclusive)
     197      // the strip should be by one longer (starting at start - 0.5 and ending at end + 0.5)
    151198      stripLine.StripWidth = end - start;
    152       stripLine.IntervalOffset = start;
     199      stripLine.IntervalOffset = start - 0.5; // start slightly to the left of the first point to clearly indicate the first point in the partition
    153200      this.chart.ChartAreas[0].AxisX.StripLines.Add(stripLine);
     201    }
     202
     203    private void ToggleSeriesData(Series series) {
     204      if (series.Points.Count > 0) {  //checks if series is shown
     205        if (this.chart.Series.Any(s => s != series && s.Points.Count > 0)) {
     206          series.Points.Clear();
     207        }
     208      } else if (Content != null) {
     209        string targetVariableName = Content.ProblemData.TargetVariable;
     210
     211        IEnumerable<int> indizes = null;
     212        IEnumerable<double> predictedValues = null;
     213        switch (series.Name) {
     214          case ESTIMATEDVALUES_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.EstimatedValues.ToArray();
     217            predictedValues = indizes.Select(index => estimatedValues[index]).ToList();
     218            break;
     219          case ESTIMATEDVALUES_TRAINING_SERIES_NAME:
     220            indizes = Content.ProblemData.TrainingIndizes.ToArray();
     221            predictedValues = Content.EstimatedTrainingValues.ToArray();
     222            break;
     223          case ESTIMATEDVALUES_TEST_SERIES_NAME:
     224            indizes = Content.ProblemData.TestIndizes.ToArray();
     225            predictedValues = Content.EstimatedTestValues.ToArray();
     226            break;
     227        }
     228        series.Points.DataBindXY(indizes, predictedValues);
     229        chart.DataManipulator.InsertEmptyPoints(1, IntervalType.Number, series.Name);
     230        chart.Legends[series.Legend].ForeColor = Color.Black;
     231        UpdateCursorInterval();
     232      }
     233    }
     234
     235    private void chart_MouseMove(object sender, MouseEventArgs e) {
     236      HitTestResult result = chart.HitTest(e.X, e.Y);
     237      if (result.ChartElementType == ChartElementType.LegendItem && result.Series.Name != TARGETVARIABLE_SERIES_NAME)
     238        Cursor = Cursors.Hand;
     239      else
     240        Cursor = Cursors.Default;
     241    }
     242    private void chart_MouseDown(object sender, MouseEventArgs e) {
     243      HitTestResult result = chart.HitTest(e.X, e.Y);
     244      if (result.ChartElementType == ChartElementType.LegendItem && result.Series.Name != TARGETVARIABLE_SERIES_NAME) {
     245        ToggleSeriesData(result.Series);
     246      }
     247    }
     248
     249    private void chart_CustomizeLegend(object sender, CustomizeLegendEventArgs e) {
     250      if (chart.Series.Count != 4) return;
     251      e.LegendItems[0].Cells[1].ForeColor = this.chart.Series[TARGETVARIABLE_SERIES_NAME].Points.Count == 0 ? Color.Gray : Color.Black;
     252      e.LegendItems[1].Cells[1].ForeColor = this.chart.Series[ESTIMATEDVALUES_TRAINING_SERIES_NAME].Points.Count == 0 ? Color.Gray : Color.Black;
     253      e.LegendItems[2].Cells[1].ForeColor = this.chart.Series[ESTIMATEDVALUES_TEST_SERIES_NAME].Points.Count == 0 ? Color.Gray : Color.Black;
     254      e.LegendItems[3].Cells[1].ForeColor = this.chart.Series[ESTIMATEDVALUES_ALL_SERIES_NAME].Points.Count == 0 ? Color.Gray : Color.Black;
    154255    }
    155256  }
  • branches/PersistenceSpeedUp/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionScatterPlotView.Designer.cs

    r5809 r6760  
    6464      this.chart.Size = new System.Drawing.Size(527, 392);
    6565      this.chart.TabIndex = 1;
     66      this.chart.PostPaint += new System.EventHandler<System.Windows.Forms.DataVisualization.Charting.ChartPaintEventArgs>(this.chart_PostPaint);
     67      this.chart.CustomizeLegend += new System.EventHandler<System.Windows.Forms.DataVisualization.Charting.CustomizeLegendEventArgs>(this.chart_CustomizeLegend);
     68      this.chart.MouseDown += new System.Windows.Forms.MouseEventHandler(this.chart_MouseDown);
    6669      this.chart.MouseMove += new System.Windows.Forms.MouseEventHandler(this.chart_MouseMove);
    67       this.chart.MouseDown += new System.Windows.Forms.MouseEventHandler(this.chart_MouseDown);
    68       this.chart.CustomizeLegend += new System.EventHandler<System.Windows.Forms.DataVisualization.Charting.CustomizeLegendEventArgs>(chart_CustomizeLegend);
    6970      //
    70       // ScatterPlotView
     71      // RegressionSolutionScatterPlotView
    7172      //
     73      this.AllowDrop = true;
    7274      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    7375      this.Controls.Add(this.chart);
    74       this.Name = "ScatterPlotView";
    75       this.AllowDrop = true;
     76      this.Name = "RegressionSolutionScatterPlotView";
    7677      this.Size = new System.Drawing.Size(527, 392);
    7778      ((System.ComponentModel.ISupportInitialize)(this.chart)).EndInit();
  • branches/PersistenceSpeedUp/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionScatterPlotView.cs

    r5975 r6760  
    2525using System.Windows.Forms;
    2626using System.Windows.Forms.DataVisualization.Charting;
    27 using HeuristicLab.Core.Views;
    2827using HeuristicLab.MainForm;
    2928using HeuristicLab.MainForm.WindowsForms;
     
    3231  [View("Scatter Plot")]
    3332  [Content(typeof(IRegressionSolution))]
    34   public partial class RegressionSolutionScatterPlotView : ItemView, IRegressionSolutionEvaluationView {
     33  public partial class RegressionSolutionScatterPlotView : DataAnalysisSolutionEvaluationView {
    3534    private const string ALL_SERIES = "All samples";
    3635    private const string TRAINING_SERIES = "Training samples";
     
    131130        if (this.chart.Series[ALL_SERIES].Points.Count > 0)
    132131          this.chart.Series[ALL_SERIES].Points.DataBindXY(Content.EstimatedValues.ToArray(), "",
    133             dataset.GetVariableValues(targetVariableName), "");
     132            dataset.GetDoubleValues(targetVariableName).ToArray(), "");
    134133        if (this.chart.Series[TRAINING_SERIES].Points.Count > 0)
    135134          this.chart.Series[TRAINING_SERIES].Points.DataBindXY(Content.EstimatedTrainingValues.ToArray(), "",
    136             dataset.GetEnumeratedVariableValues(targetVariableName, Content.ProblemData.TrainingIndizes).ToArray(), "");
     135            dataset.GetDoubleValues(targetVariableName, Content.ProblemData.TrainingIndizes).ToArray(), "");
    137136        if (this.chart.Series[TEST_SERIES].Points.Count > 0)
    138137          this.chart.Series[TEST_SERIES].Points.DataBindXY(Content.EstimatedTestValues.ToArray(), "",
    139            dataset.GetEnumeratedVariableValues(targetVariableName, Content.ProblemData.TestIndizes).ToArray(), "");
    140 
    141         double max = Math.Max(Content.EstimatedValues.Max(), dataset.GetVariableValues(targetVariableName).Max());
    142         double min = Math.Min(Content.EstimatedValues.Min(), dataset.GetVariableValues(targetVariableName).Min());
     138           dataset.GetDoubleValues(targetVariableName, Content.ProblemData.TestIndizes).ToArray(), "");
     139
     140        double max = Content.EstimatedTrainingValues.Concat(Content.EstimatedTestValues.Concat(Content.EstimatedValues.Concat(dataset.GetDoubleValues(targetVariableName)))).Max();
     141        double min = Content.EstimatedTrainingValues.Concat(Content.EstimatedTestValues.Concat(Content.EstimatedValues.Concat(dataset.GetDoubleValues(targetVariableName)))).Min();
    143142
    144143        max = max + 0.2 * Math.Abs(max);
     
    178177          case ALL_SERIES:
    179178            predictedValues = Content.EstimatedValues.ToArray();
    180             targetValues = Content.ProblemData.Dataset.GetVariableValues(targetVariableName);
     179            targetValues = Content.ProblemData.Dataset.GetDoubleValues(targetVariableName).ToArray();
    181180            break;
    182181          case TRAINING_SERIES:
    183182            predictedValues = Content.EstimatedTrainingValues.ToArray();
    184             targetValues = Content.ProblemData.Dataset.GetEnumeratedVariableValues(targetVariableName, Content.ProblemData.TrainingIndizes).ToArray();
     183            targetValues = Content.ProblemData.Dataset.GetDoubleValues(targetVariableName, Content.ProblemData.TrainingIndizes).ToArray();
    185184            break;
    186185          case TEST_SERIES:
    187186            predictedValues = Content.EstimatedTestValues.ToArray();
    188             targetValues = Content.ProblemData.Dataset.GetEnumeratedVariableValues(targetVariableName, Content.ProblemData.TestIndizes).ToArray();
     187            targetValues = Content.ProblemData.Dataset.GetDoubleValues(targetVariableName, Content.ProblemData.TestIndizes).ToArray();
    189188            break;
    190189        }
     
    220219      e.LegendItems[2].Cells[1].ForeColor = this.chart.Series[TEST_SERIES].Points.Count == 0 ? Color.Gray : Color.Black;
    221220    }
     221
     222    private void chart_PostPaint(object sender, ChartPaintEventArgs e) {
     223      var chartArea = e.ChartElement as ChartArea;
     224      if (chartArea != null) {
     225        ChartGraphics chartGraphics = e.ChartGraphics;
     226        using (Pen p = new Pen(Color.DarkGray)) {
     227          double xmin = chartArea.AxisX.ScaleView.ViewMinimum;
     228          double xmax = chartArea.AxisX.ScaleView.ViewMaximum;
     229          double ymin = chartArea.AxisY.ScaleView.ViewMinimum;
     230          double ymax = chartArea.AxisY.ScaleView.ViewMaximum;
     231
     232          if (xmin > ymax || ymin > xmax) return;
     233
     234          PointF start = PointF.Empty;
     235          start.X = (float)chartGraphics.GetPositionFromAxis(chartArea.Name, chartArea.AxisX.AxisName, Math.Max(xmin, ymin));
     236          start.Y = (float)chartGraphics.GetPositionFromAxis(chartArea.Name, chartArea.AxisY.AxisName, Math.Max(xmin, ymin));
     237          PointF end = PointF.Empty;
     238          end.X = (float)chartGraphics.GetPositionFromAxis(chartArea.Name, chartArea.AxisX.AxisName, Math.Min(xmax, ymax));
     239          end.Y = (float)chartGraphics.GetPositionFromAxis(chartArea.Name, chartArea.AxisY.AxisName, Math.Min(xmax, ymax));
     240
     241          chartGraphics.Graphics.DrawLine(p, chartGraphics.GetAbsolutePoint(start), chartGraphics.GetAbsolutePoint(end));
     242        }
     243      }
     244    }
    222245  }
    223246}
Note: See TracChangeset for help on using the changeset viewer.