Free cookie consent management tool by TermsFeed Policy Generator

Changeset 8513


Ignore:
Timestamp:
08/21/12 14:10:35 (10 years ago)
Author:
sforsten
Message:

#1758: merged r8023:8509 from trunk to branch to make it useable again

Location:
branches/ChangeDatasetOfRegressionModel
Files:
27 edited
2 copied

Legend:

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

  • branches/ChangeDatasetOfRegressionModel/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4

    • Property svn:ignore
      •  

        old new  
        55*.vs10x
        66Plugin.cs
        7 *.resx
         7*.user
  • branches/ChangeDatasetOfRegressionModel/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/InteractiveSymbolicRegressionSolutionSimplifierView.Designer.cs

    r8032 r8513  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/ChangeDatasetOfRegressionModel/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/InteractiveSymbolicRegressionSolutionSimplifierView.cs

    r7259 r8513  
    6666      var interpreter = Content.Model.Interpreter;
    6767      var dataset = Content.ProblemData.Dataset;
    68       var rows = Content.ProblemData.TrainingIndizes;
     68      var rows = Content.ProblemData.TrainingIndices;
    6969      string targetVariable = Content.ProblemData.TargetVariable;
    7070      Dictionary<ISymbolicExpressionTreeNode, double> impactValues = new Dictionary<ISymbolicExpressionTreeNode, double>();
     
    106106      start.AddSubtree((ISymbolicExpressionTreeNode)node.Clone());
    107107      var interpreter = Content.Model.Interpreter;
    108       var rows = Content.ProblemData.TrainingIndizes;
     108      var rows = Content.ProblemData.TrainingIndices;
    109109      return interpreter.GetSymbolicExpressionTreeValues(tempTree, Content.ProblemData.Dataset, rows).Median();
    110110    }
     
    122122
    123123    protected override void btnOptimizeConstants_Click(object sender, EventArgs e) {
    124       SymbolicRegressionConstantOptimizationEvaluator.OptimizeConstants(Content.Model.Interpreter, Content.Model.SymbolicExpressionTree, Content.ProblemData, Content.ProblemData.TrainingIndizes, 0.001, 0, 0.0001);
     124      SymbolicRegressionConstantOptimizationEvaluator.OptimizeConstants(Content.Model.Interpreter, Content.Model.SymbolicExpressionTree, Content.ProblemData, Content.ProblemData.TrainingIndices, 0.001, 0, 0.0001);
    125125      UpdateModel(Content.Model.SymbolicExpressionTree);
    126126    }
  • branches/ChangeDatasetOfRegressionModel/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/Plugin.cs.frame

    r7259 r8513  
    2626
    2727namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views {
    28   [Plugin("HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views", "Provides views for symbolic regression problem classes.", "3.4.2.$WCREV$")]
     28  [Plugin("HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views", "Provides views for symbolic regression problem classes.", "3.4.3.$WCREV$")]
    2929  [PluginFile("HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views-3.4.dll",PluginFileType.Assembly)]
    3030  [PluginDependency("HeuristicLab.Algorithms.DataAnalysis", "3.4")]
  • branches/ChangeDatasetOfRegressionModel/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/Properties/AssemblyInfo.cs.frame

    r7259 r8513  
    5353// by using the '*' as shown below:
    5454[assembly: AssemblyVersion("3.4.0.0")]
    55 [assembly: AssemblyFileVersion("3.4.2.$WCREV$")]
     55[assembly: AssemblyFileVersion("3.4.3.$WCREV$")]
  • branches/ChangeDatasetOfRegressionModel/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/SymbolicRegressionSolutionErrorCharacteristicsCurveView.Designer.cs

    r8032 r8513  
    2626      ((System.ComponentModel.ISupportInitialize)(this.chart)).BeginInit();
    2727      this.SuspendLayout();
    28       //
    29       // chart
    30       //
    31       this.chart.MouseDown += new System.Windows.Forms.MouseEventHandler(this.chart_MouseDown);
    32       //
     28      //
    3329      // SymbolicRegressionSolutionErrorCharacteristicsCurveView
    3430      //
  • branches/ChangeDatasetOfRegressionModel/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/SymbolicRegressionSolutionErrorCharacteristicsCurveView.cs

    r7259 r8513  
    2323using System.Linq;
    2424using System.Windows.Forms;
    25 using System.Windows.Forms.DataVisualization.Charting;
    2625using HeuristicLab.Algorithms.DataAnalysis;
    2726using HeuristicLab.MainForm;
     
    7372      foreach (var variable in usedVariables) {
    7473        problemData.InputVariables.SetItemCheckedState(
    75           problemData.InputVariables.Where(x => x.Value == variable).First(), true);
     74          problemData.InputVariables.First(x => x.Value == variable), true);
    7675      }
    7776
     
    9089      base.Content_ProblemDataChanged(sender, e);
    9190    }
    92 
    93     private void chart_MouseDown(object sender, MouseEventArgs e) {
    94       if (e.Clicks < 2) return;
    95       HitTestResult result = chart.HitTest(e.X, e.Y);
    96       if (result.ChartElementType != ChartElementType.LegendItem) return;
    97       if (result.Series.Name != linearRegressionSolution.Name) return;
    98 
    99       MainFormManager.MainForm.ShowContent((IRegressionSolution)result.Series.Tag);
    100     }
    10191  }
    10292}
  • branches/ChangeDatasetOfRegressionModel/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/SymbolicRegressionSolutionResponseFunctionView.Designer.cs

    r8032 r8513  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/ChangeDatasetOfRegressionModel/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/SymbolicRegressionSolutionResponseFunctionView.cs

    r7259 r8513  
    142142      };
    143143
    144       var mainTrainingIndizes = (from row in Content.ProblemData.TrainingIndizes
     144      var mainTrainingIndices = (from row in Content.ProblemData.TrainingIndices
    145145                                 where NearMedianValue(row)
    146146                                 select row)
    147147        .ToArray();
    148       var mainTestIndizes = (from row in Content.ProblemData.TestIndizes
     148      var mainTestIndices = (from row in Content.ProblemData.TestIndices
    149149                             where NearMedianValue(row)
    150150                             select row)
    151151        .ToArray();
    152152
    153       var freeVariableValues = Content.ProblemData.Dataset.GetDoubleValues(freeVariable, mainTrainingIndizes).ToArray();
     153      var freeVariableValues = Content.ProblemData.Dataset.GetDoubleValues(freeVariable, mainTrainingIndices).ToArray();
    154154      var trainingValues = Content.ProblemData.Dataset.GetDoubleValues(Content.ProblemData.TargetVariable,
    155                                                                      mainTrainingIndizes).ToArray();
     155                                                                     mainTrainingIndices).ToArray();
    156156      Array.Sort(freeVariableValues, trainingValues);
    157157      responseChart.Series["Training Data"].Points.DataBindXY(freeVariableValues, trainingValues);
    158158
    159       freeVariableValues = Content.ProblemData.Dataset.GetDoubleValues(freeVariable, mainTestIndizes).ToArray();
     159      freeVariableValues = Content.ProblemData.Dataset.GetDoubleValues(freeVariable, mainTestIndices).ToArray();
    160160      var testValues = Content.ProblemData.Dataset.GetDoubleValues(Content.ProblemData.TargetVariable,
    161                                                                      mainTestIndizes).ToArray();
     161                                                                     mainTestIndices).ToArray();
    162162      Array.Sort(freeVariableValues, testValues);
    163163      responseChart.Series["Test Data"].Points.DataBindXY(freeVariableValues, testValues);
    164164
    165165      // draw scatter plots of remaining values
    166       freeVariableValues = Content.ProblemData.Dataset.GetDoubleValues(freeVariable, Content.ProblemData.TrainingIndizes).ToArray();
     166      freeVariableValues = Content.ProblemData.Dataset.GetDoubleValues(freeVariable, Content.ProblemData.TrainingIndices).ToArray();
    167167      trainingValues = Content.ProblemData.Dataset.GetDoubleValues(Content.ProblemData.TargetVariable,
    168                                                                      Content.ProblemData.TrainingIndizes).ToArray();
     168                                                                     Content.ProblemData.TrainingIndices).ToArray();
    169169      Array.Sort(freeVariableValues, trainingValues);
    170170      responseChart.Series["Training Data (edge)"].Points.DataBindXY(freeVariableValues, trainingValues);
    171171
    172       freeVariableValues = Content.ProblemData.Dataset.GetDoubleValues(freeVariable, Content.ProblemData.TestIndizes).ToArray();
     172      freeVariableValues = Content.ProblemData.Dataset.GetDoubleValues(freeVariable, Content.ProblemData.TestIndices).ToArray();
    173173      testValues = Content.ProblemData.Dataset.GetDoubleValues(Content.ProblemData.TargetVariable,
    174                                                                      Content.ProblemData.TestIndizes).ToArray();
     174                                                                     Content.ProblemData.TestIndices).ToArray();
    175175      Array.Sort(freeVariableValues, testValues);
    176176      responseChart.Series["Test Data (edge)"].Points.DataBindXY(freeVariableValues, testValues);
     
    187187      string freeVariable = (string)comboBox.SelectedItem;
    188188
    189       var freeVariableValues = Content.ProblemData.Dataset.GetDoubleValues(freeVariable, Content.ProblemData.TrainingIndizes).ToArray();
     189      var freeVariableValues = Content.ProblemData.Dataset.GetDoubleValues(freeVariable, Content.ProblemData.TrainingIndices).ToArray();
    190190      var responseValues = Content.Model.Interpreter.GetSymbolicExpressionTreeValues(clonedTree,
    191191                                                                              Content.ProblemData.Dataset,
    192                                                                               Content.ProblemData.TrainingIndizes)
     192                                                                              Content.ProblemData.TrainingIndices)
    193193                                                                              .ToArray();
    194194      Array.Sort(freeVariableValues, responseValues);
  • branches/ChangeDatasetOfRegressionModel/HeuristicLab.Problems.DataAnalysis.Views

  • branches/ChangeDatasetOfRegressionModel/HeuristicLab.Problems.DataAnalysis.Views/3.4/Classification/ClassificationEnsembleSolutionEstimatedClassValuesView.cs

    r7259 r8513  
    7373      }
    7474
    75       int[] indizes;
     75      int[] indices;
    7676      double[] estimatedClassValues;
    7777
    7878      switch (SamplesComboBox.SelectedItem.ToString()) {
    7979        case SamplesComboBoxAllSamples: {
    80             indizes = Enumerable.Range(0, Content.ProblemData.Dataset.Rows).ToArray();
     80            indices = Enumerable.Range(0, Content.ProblemData.Dataset.Rows).ToArray();
    8181            estimatedClassValues = Content.EstimatedClassValues.ToArray();
    8282            break;
    8383          }
    8484        case SamplesComboBoxTrainingSamples: {
    85             indizes = Content.ProblemData.TrainingIndizes.ToArray();
     85            indices = Content.ProblemData.TrainingIndices.ToArray();
    8686            estimatedClassValues = Content.EstimatedTrainingClassValues.ToArray();
    8787            break;
    8888          }
    8989        case SamplesComboBoxTestSamples: {
    90             indizes = Content.ProblemData.TestIndizes.ToArray();
     90            indices = Content.ProblemData.TestIndices.ToArray();
    9191            estimatedClassValues = Content.EstimatedTestClassValues.ToArray();
    9292            break;
     
    9898      int classValuesCount = Content.ProblemData.ClassValues.Count;
    9999      int solutionsCount = Content.ClassificationSolutions.Count();
    100       string[,] values = new string[indizes.Length, 5 + classValuesCount + solutionsCount];
     100      string[,] values = new string[indices.Length, 5 + classValuesCount + solutionsCount];
    101101      double[] target = Content.ProblemData.Dataset.GetDoubleValues(Content.ProblemData.TargetVariable).ToArray();
    102       List<List<double?>> estimatedValuesVector = GetEstimatedValues(SamplesComboBox.SelectedItem.ToString(), indizes,
     102      List<List<double?>> estimatedValuesVector = GetEstimatedValues(SamplesComboBox.SelectedItem.ToString(), indices,
    103103                                                            Content.ClassificationSolutions);
    104104
    105       for (int i = 0; i < indizes.Length; i++) {
    106         int row = indizes[i];
     105      for (int i = 0; i < indices.Length; i++) {
     106        int row = indices[i];
    107107        values[i, 0] = row.ToString();
    108108        values[i, 1] = target[i].ToString();
  • branches/ChangeDatasetOfRegressionModel/HeuristicLab.Problems.DataAnalysis.Views/3.4/Classification/ClassificationSolutionConfusionMatrixView.cs

    r7259 r8513  
    107107        double[] predictedValues;
    108108        if (cmbSamples.SelectedItem.ToString() == TrainingSamples) {
    109           rows = Content.ProblemData.TrainingIndizes;
     109          rows = Content.ProblemData.TrainingIndices;
    110110          predictedValues = Content.EstimatedTrainingClassValues.ToArray();
    111111        } else if (cmbSamples.SelectedItem.ToString() == TestSamples) {
    112           rows = Content.ProblemData.TestIndizes;
     112          rows = Content.ProblemData.TestIndices;
    113113          predictedValues = Content.EstimatedTestClassValues.ToArray();
    114114        } else throw new InvalidOperationException();
  • branches/ChangeDatasetOfRegressionModel/HeuristicLab.Problems.DataAnalysis.Views/3.4/Classification/ClassificationSolutionEstimatedClassValuesView.cs

    r7259 r8513  
    9696          var estimatedTraining = Content.EstimatedTrainingClassValues.GetEnumerator();
    9797          estimatedTraining.MoveNext();
    98           foreach (var trainingRow in Content.ProblemData.TrainingIndizes) {
     98          foreach (var trainingRow in Content.ProblemData.TrainingIndices) {
    9999            values[trainingRow, 3] = estimatedTraining.Current.ToString();
    100100            estimatedTraining.MoveNext();
     
    102102          var estimatedTest = Content.EstimatedTestClassValues.GetEnumerator();
    103103          estimatedTest.MoveNext();
    104           foreach (var testRow in Content.ProblemData.TestIndizes) {
     104          foreach (var testRow in Content.ProblemData.TestIndices) {
    105105            values[testRow, 4] = estimatedTest.Current.ToString();
    106106            estimatedTest.MoveNext();
  • branches/ChangeDatasetOfRegressionModel/HeuristicLab.Problems.DataAnalysis.Views/3.4/Classification/DiscriminantFunctionClassificationRocCurvesView.cs

    r7259 r8513  
    101101
    102102        if (cmbSamples.SelectedItem.ToString() == TrainingSamples) {
    103           rows = Content.ProblemData.TrainingIndizes;
     103          rows = Content.ProblemData.TrainingIndices;
    104104        } else if (cmbSamples.SelectedItem.ToString() == TestSamples) {
    105           rows = Content.ProblemData.TestIndizes;
     105          rows = Content.ProblemData.TestIndices;
    106106        } else throw new InvalidOperationException();
    107107
  • branches/ChangeDatasetOfRegressionModel/HeuristicLab.Problems.DataAnalysis.Views/3.4/Classification/DiscriminantFunctionClassificationSolutionThresholdView.cs

    r7259 r8513  
    137137      var targetValues = Content.ProblemData.Dataset.GetDoubleValues(Content.ProblemData.TargetVariable).ToList();
    138138
    139       foreach (int row in Content.ProblemData.TrainingIndizes) {
     139      foreach (int row in Content.ProblemData.TrainingIndices) {
    140140        double estimatedValue = estimatedValues[row];
    141141        double targetValue = targetValues[row];
     
    150150      }
    151151
    152       foreach (int row in Content.ProblemData.TestIndizes) {
     152      foreach (int row in Content.ProblemData.TestIndices) {
    153153        double estimatedValue = estimatedValues[row];
    154154        double targetValue = targetValues[row];
  • branches/ChangeDatasetOfRegressionModel/HeuristicLab.Problems.DataAnalysis.Views/3.4/HeuristicLab.Problems.DataAnalysis.Views-3.4.csproj

    r8032 r8513  
    9393  </PropertyGroup>
    9494  <ItemGroup>
     95    <Reference Include="ALGLIB-3.6.0, Version=3.6.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     96      <HintPath>..\..\..\..\trunk\sources\bin\ALGLIB-3.6.0.dll</HintPath>
     97      <Private>False</Private>
     98    </Reference>
     99    <Reference Include="HeuristicLab.Analysis-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     100      <Private>False</Private>
     101    </Reference>
    95102    <Reference Include="HeuristicLab.Collections-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    96103      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Collections-3.3.dll</HintPath>
     
    192199    <Compile Include="Classification\ClassificationEnsembleSolutionModelView.Designer.cs">
    193200      <DependentUpon>ClassificationEnsembleSolutionModelView.cs</DependentUpon>
     201    </Compile>
     202    <Compile Include="Clustering\ClusteringSolutionVisualizationView.cs">
     203      <SubType>UserControl</SubType>
     204    </Compile>
     205    <Compile Include="Clustering\ClusteringSolutionVisualizationView.Designer.cs">
     206      <DependentUpon>ClusteringSolutionVisualizationView.cs</DependentUpon>
    194207    </Compile>
    195208    <Compile Include="DataAnalysisSolutionEvaluationView.cs">
  • branches/ChangeDatasetOfRegressionModel/HeuristicLab.Problems.DataAnalysis.Views/3.4/Plugin.cs.frame

    r7294 r8513  
    2626
    2727namespace HeuristicLab.Problems.DataAnalysis.Views {
    28   [Plugin("HeuristicLab.Problems.DataAnalysis.Views", "Provides views for base classes for data analysis tasks.", "3.4.2.$WCREV$")]
     28  [Plugin("HeuristicLab.Problems.DataAnalysis.Views", "Provides views for base classes for data analysis tasks.", "3.4.3.$WCREV$")]
    2929  [PluginFile("HeuristicLab.Problems.DataAnalysis.Views-3.4.dll", PluginFileType.Assembly)]
     30  [PluginDependency("HeuristicLab.ALGLIB", "3.6.0")]
     31  [PluginDependency("HeuristicLab.Analysis", "3.3")]
     32  [PluginDependency("HeuristicLab.Collections", "3.3")]
    3033  [PluginDependency("HeuristicLab.Common", "3.3")]
    3134  [PluginDependency("HeuristicLab.Common.Resources", "3.3")]
  • branches/ChangeDatasetOfRegressionModel/HeuristicLab.Problems.DataAnalysis.Views/3.4/Properties/AssemblyInfo.cs.frame

    r7259 r8513  
    5353// by using the '*' as shown below:
    5454[assembly: AssemblyVersion("3.4.0.0")]
    55 [assembly: AssemblyFileVersion("3.4.2.$WCREV$")]
     55[assembly: AssemblyFileVersion("3.4.3.$WCREV$")]
  • branches/ChangeDatasetOfRegressionModel/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionErrorCharacteristicsCurveView.Designer.cs

    r8032 r8513  
    3636      //
    3737      this.chart.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    38             | System.Windows.Forms.AnchorStyles.Left)
    39             | System.Windows.Forms.AnchorStyles.Right)));
     38                  | System.Windows.Forms.AnchorStyles.Left)
     39                  | System.Windows.Forms.AnchorStyles.Right)));
    4040      chartArea1.Name = "ChartArea1";
    4141      this.chart.ChartAreas.Add(chartArea1);
     
    7373      // RegressionSolutionErrorCharacteristicsCurveView
    7474      //
    75       this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    7675      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
    7776      this.Controls.Add(this.label1);
  • branches/ChangeDatasetOfRegressionModel/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionErrorCharacteristicsCurveView.cs

    r8032 r8513  
    2626using System.Windows.Forms.DataVisualization.Charting;
    2727using HeuristicLab.MainForm;
    28 using HeuristicLab.MainForm.WindowsForms;
    2928
    3029namespace HeuristicLab.Problems.DataAnalysis.Views {
     
    3231  [Content(typeof(IRegressionSolution))]
    3332  public partial class RegressionSolutionErrorCharacteristicsCurveView : DataAnalysisSolutionEvaluationView {
    34     private IRegressionSolution constantModel;
    3533    protected const string TrainingSamples = "Training";
    3634    protected const string TestSamples = "Test";
     
    103101      if (Content == null) return;
    104102
     103      var constantModel = CreateConstantModel();
    105104      var originalValues = GetOriginalValues().ToList();
    106       constantModel = CreateConstantModel();
    107105      var baselineEstimatedValues = GetEstimatedValues(constantModel);
    108106      var baselineResiduals = GetResiduals(originalValues, baselineEstimatedValues);
     
    117115      baselineSeries.ToolTip = "Area over Curve: " + CalculateAreaOverCurve(baselineSeries);
    118116      baselineSeries.Tag = constantModel;
     117      baselineSeries.LegendToolTip = "Double-click to open model";
    119118      chart.Series.Add(baselineSeries);
    120119
     
    131130      UpdateSeries(estimatedValues, solutionSeries);
    132131      solutionSeries.ToolTip = "Area over Curve: " + CalculateAreaOverCurve(solutionSeries);
     132      solutionSeries.LegendToolTip = "Double-click to open model";
    133133      chart.Series.Add(solutionSeries);
    134134    }
     
    169169      switch (cmbSamples.SelectedItem.ToString()) {
    170170        case TrainingSamples:
    171           originalValues = ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable, ProblemData.TrainingIndizes);
     171          originalValues = ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable, ProblemData.TrainingIndices);
    172172          break;
    173173        case TestSamples:
    174           originalValues = ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable, ProblemData.TestIndizes);
     174          originalValues = ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable, ProblemData.TestIndices);
    175175          break;
    176176        case AllSamples:
     
    201201    }
    202202
    203     protected IEnumerable<double> GetbaselineEstimatedValues(IEnumerable<double> originalValues) {
    204       double averageTrainingTarget = ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable, ProblemData.TrainingIndizes).Average();
    205       return Enumerable.Repeat(averageTrainingTarget, originalValues.Count());
    206     }
    207 
    208203    protected virtual List<double> GetResiduals(IEnumerable<double> originalValues, IEnumerable<double> estimatedValues) {
    209204      return originalValues.Zip(estimatedValues, (x, y) => Math.Abs(x - y)).ToList();
     
    239234
    240235    private IRegressionSolution CreateConstantModel() {
    241       double averageTrainingTarget = ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable, ProblemData.TrainingIndizes).Average();
     236      double averageTrainingTarget = ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable, ProblemData.TrainingIndices).Average();
    242237      var solution = new ConstantRegressionModel(averageTrainingTarget).CreateRegressionSolution(ProblemData);
    243238      solution.Name = "Baseline";
     
    248243    private void chart_MouseMove(object sender, MouseEventArgs e) {
    249244      HitTestResult result = chart.HitTest(e.X, e.Y);
    250       if (result.ChartElementType == ChartElementType.LegendItem)
     245      if (result.ChartElementType == ChartElementType.LegendItem) {
    251246        Cursor = Cursors.Hand;
    252       else
     247      } else {
    253248        Cursor = Cursors.Default;
     249      }
    254250    }
    255251  }
  • branches/ChangeDatasetOfRegressionModel/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionEstimatedValuesView.cs

    r7259 r8513  
    9393          var estimated_test = Content.EstimatedTestValues.GetEnumerator();
    9494
    95           foreach (var row in Content.ProblemData.TrainingIndizes) {
     95          foreach (var row in Content.ProblemData.TrainingIndices) {
    9696            estimated_training.MoveNext();
    9797            values[row, 3] = estimated_training.Current.ToString();
    9898          }
    9999
    100           foreach (var row in Content.ProblemData.TestIndizes) {
     100          foreach (var row in Content.ProblemData.TestIndices) {
    101101            estimated_test.MoveNext();
    102102            values[row, 4] = estimated_test.Current.ToString();
  • branches/ChangeDatasetOfRegressionModel/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionLineChartView.cs

    r8032 r8513  
    7272        this.chart.Series[ESTIMATEDVALUES_TRAINING_SERIES_NAME].ChartType = SeriesChartType.FastLine;
    7373        this.chart.Series[ESTIMATEDVALUES_TRAINING_SERIES_NAME].EmptyPointStyle.Color = this.chart.Series[ESTIMATEDVALUES_TRAINING_SERIES_NAME].Color;
    74         this.chart.Series[ESTIMATEDVALUES_TRAINING_SERIES_NAME].Points.DataBindXY(Content.ProblemData.TrainingIndizes.ToArray(), Content.EstimatedTrainingValues.ToArray());
     74        this.chart.Series[ESTIMATEDVALUES_TRAINING_SERIES_NAME].Points.DataBindXY(Content.ProblemData.TrainingIndices.ToArray(), Content.EstimatedTrainingValues.ToArray());
    7575        this.InsertEmptyPoints(this.chart.Series[ESTIMATEDVALUES_TRAINING_SERIES_NAME]);
    7676        this.chart.Series[ESTIMATEDVALUES_TRAINING_SERIES_NAME].Tag = Content;
     
    7979        this.chart.Series[ESTIMATEDVALUES_TEST_SERIES_NAME].LegendText = ESTIMATEDVALUES_TEST_SERIES_NAME;
    8080        this.chart.Series[ESTIMATEDVALUES_TEST_SERIES_NAME].ChartType = SeriesChartType.FastLine;
    81         this.chart.Series[ESTIMATEDVALUES_TEST_SERIES_NAME].Points.DataBindXY(Content.ProblemData.TestIndizes.ToArray(), Content.EstimatedTestValues.ToArray());
     81        this.chart.Series[ESTIMATEDVALUES_TEST_SERIES_NAME].Points.DataBindXY(Content.ProblemData.TestIndices.ToArray(), Content.EstimatedTestValues.ToArray());
    8282        this.InsertEmptyPoints(this.chart.Series[ESTIMATEDVALUES_TEST_SERIES_NAME]);
    8383        this.chart.Series[ESTIMATEDVALUES_TEST_SERIES_NAME].Tag = Content;
    8484        // series of remaining points
    85         int[] allIndizes = Enumerable.Range(0, Content.ProblemData.Dataset.Rows).Except(Content.ProblemData.TrainingIndizes).Except(Content.ProblemData.TestIndizes).ToArray();
     85        int[] allIndices = Enumerable.Range(0, Content.ProblemData.Dataset.Rows).Except(Content.ProblemData.TrainingIndices).Except(Content.ProblemData.TestIndices).ToArray();
    8686        var estimatedValues = Content.EstimatedValues.ToArray();
    87         List<double> allEstimatedValues = allIndizes.Select(index => estimatedValues[index]).ToList();
     87        List<double> allEstimatedValues = allIndices.Select(index => estimatedValues[index]).ToList();
    8888        this.chart.Series.Add(ESTIMATEDVALUES_ALL_SERIES_NAME);
    8989        this.chart.Series[ESTIMATEDVALUES_ALL_SERIES_NAME].LegendText = ESTIMATEDVALUES_ALL_SERIES_NAME;
    9090        this.chart.Series[ESTIMATEDVALUES_ALL_SERIES_NAME].ChartType = SeriesChartType.FastLine;
    91         this.chart.Series[ESTIMATEDVALUES_ALL_SERIES_NAME].Points.DataBindXY(allIndizes, allEstimatedValues);
    92         this.InsertEmptyPoints(this.chart.Series[ESTIMATEDVALUES_ALL_SERIES_NAME]);
     91        if (allEstimatedValues.Count > 0) {
     92          this.chart.Series[ESTIMATEDVALUES_ALL_SERIES_NAME].Points.DataBindXY(allIndices, allEstimatedValues);
     93          this.InsertEmptyPoints(this.chart.Series[ESTIMATEDVALUES_ALL_SERIES_NAME]);
     94        }
    9395        this.chart.Series[ESTIMATEDVALUES_ALL_SERIES_NAME].Tag = Content;
    9496        this.ToggleSeriesData(this.chart.Series[ESTIMATEDVALUES_ALL_SERIES_NAME]);
     
    170172
    171173      int[] attr = new int[Content.ProblemData.Dataset.Rows + 1]; // add a virtual last row that is again empty to simplify loop further down
    172       foreach (var row in Content.ProblemData.TrainingIndizes) {
     174      foreach (var row in Content.ProblemData.TrainingIndices) {
    173175        attr[row] += 1;
    174176      }
    175       foreach (var row in Content.ProblemData.TestIndizes) {
     177      foreach (var row in Content.ProblemData.TestIndices) {
    176178        attr[row] += 2;
    177179      }
     
    223225        string targetVariableName = Content.ProblemData.TargetVariable;
    224226
    225         IEnumerable<int> indizes = null;
    226         IEnumerable<double> predictedValues = null;
     227        IEnumerable<int> indices = null;
     228        double[] predictedValues = null;
    227229        switch (series.Name) {
    228230          case ESTIMATEDVALUES_ALL_SERIES_NAME:
    229             indizes = Enumerable.Range(0, Content.ProblemData.Dataset.Rows).Except(Content.ProblemData.TrainingIndizes).Except(Content.ProblemData.TestIndizes).ToArray();
     231            indices = Enumerable.Range(0, Content.ProblemData.Dataset.Rows).Except(Content.ProblemData.TrainingIndices).Except(Content.ProblemData.TestIndices).ToArray();
    230232            var estimatedValues = Content.EstimatedValues.ToArray();
    231             predictedValues = indizes.Select(index => estimatedValues[index]).ToList();
     233            predictedValues = indices.Select(index => estimatedValues[index]).ToArray();
    232234            break;
    233235          case ESTIMATEDVALUES_TRAINING_SERIES_NAME:
    234             indizes = Content.ProblemData.TrainingIndizes.ToArray();
     236            indices = Content.ProblemData.TrainingIndices.ToArray();
    235237            predictedValues = Content.EstimatedTrainingValues.ToArray();
    236238            break;
    237239          case ESTIMATEDVALUES_TEST_SERIES_NAME:
    238             indizes = Content.ProblemData.TestIndizes.ToArray();
     240            indices = Content.ProblemData.TestIndices.ToArray();
    239241            predictedValues = Content.EstimatedTestValues.ToArray();
    240242            break;
    241243        }
    242         series.Points.DataBindXY(indizes, predictedValues);
    243         this.InsertEmptyPoints(series);
     244        if (predictedValues.Length > 0) {
     245          series.Points.DataBindXY(indices, predictedValues);
     246          this.InsertEmptyPoints(series);
     247        }
    244248        chart.Legends[series.Legend].ForeColor = Color.Black;
    245249        UpdateCursorInterval();
  • branches/ChangeDatasetOfRegressionModel/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionResidualHistogram.Designer.cs

    r8032 r8513  
    4141      this.chart.Location = new System.Drawing.Point(0, 0);
    4242      this.chart.Name = "chart";
    43       this.chart.Size = new System.Drawing.Size(358, 225);
     43      this.chart.Size = new System.Drawing.Size(289, 220);
    4444      this.chart.TabIndex = 0;
    4545      this.chart.CustomizeLegend += new System.EventHandler<System.Windows.Forms.DataVisualization.Charting.CustomizeLegendEventArgs>(this.chart_CustomizeLegend);
     
    5050      //
    5151      this.AllowDrop = true;
    52       this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    5352      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
    5453      this.Controls.Add(this.chart);
  • branches/ChangeDatasetOfRegressionModel/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionResidualHistogram.cs

    r8032 r8513  
    3939    protected const string TEST_SAMPLES = "Test samples";
    4040    /// <summary>
    41     /// used to reduce code duplication
    42     /// </summary>
    43     protected static string[] ALL_SERIES = new string[] { ALL_SAMPLES, TRAINING_SAMPLES, TEST_SAMPLES };
    44     /// <summary>
    4541    /// approximate amount of bins
    4642    /// </summary>
    4743    protected const double bins = 25;
    48     /// <summary>
    49     ///  keeps for all series a list for every bin with the position of the bin, the relative frequency of the
    50     ///  residuals and the beginning and the end of the interval of the bin
    51     ///  </summary>
    52     protected Dictionary<string, List<List<double>>> relativeFrequencies;
    5344    #endregion
    5445
     
    6152      : base() {
    6253      InitializeComponent();
    63       relativeFrequencies = new Dictionary<string, List<List<double>>>();
    64       foreach (string series in ALL_SERIES) {
     54      foreach (string series in new List<String>() { ALL_SAMPLES, TRAINING_SAMPLES, TEST_SAMPLES }) {
    6555        chart.Series.Add(series);
    6656        chart.Series[series].LegendText = series;
     
    7161        chart.Series[series].BorderColor = Color.Black;
    7262        chart.Series[series].ToolTip = series + " Y = #VALY from #CUSTOMPROPERTY(from) to #CUSTOMPROPERTY(to)";
    73         relativeFrequencies[series] = new List<List<double>>();
    7463      }
    7564      //configure axis
     
    8776
    8877    private void RedrawChart() {
    89       foreach (string series in ALL_SERIES) {
    90         chart.Series[series].Points.Clear();
    91         relativeFrequencies[series].Clear();
     78      foreach (Series series in chart.Series) {
     79        series.Points.Clear();
    9280      }
    9381      if (Content != null) {
    94         Dictionary<string, List<double>> residuals = CalculateResiduals();
    95         double realMax = Math.Max(Math.Abs(residuals[ALL_SAMPLES].Min()), Math.Abs(residuals[ALL_SAMPLES].Max()));
    96         double roundedMax = HumanRoundMax(realMax);
    97         double intervalWidth = (roundedMax * 2.0) / bins;
    98         intervalWidth = HumanRoundMax(intervalWidth);
    99         // sets roundedMax to a value, so that zero will be in the middle of the x axis
    100         double help = realMax / intervalWidth;
    101         help = help % 1 < 0.5 ? (int)help : (int)help + 1;
    102         roundedMax = help * intervalWidth;
    103 
    104         foreach (string series in ALL_SERIES) {
    105           CalculateFrequencies(residuals[series], series, roundedMax, intervalWidth);
    106           if (!series.Equals(ALL_SAMPLES))
    107             ShowValues(chart.Series[series], relativeFrequencies[series]);
     82        List<double> residuals = CalculateResiduals(Content);
     83
     84        double max = 0.0;
     85        foreach (Series series in chart.Series) {
     86          CalculateFrequencies(residuals, series);
     87          double seriesMax = series.Points.Select(p => p.YValues.First()).Max();
     88          max = max < seriesMax ? seriesMax : max;
    10889        }
     90
     91        // ALL_SAMPLES has to be calculated to know its highest frequency, but it is not shown in the beginning
     92        chart.Series.First(s => s.Name.Equals(ALL_SAMPLES)).Points.Clear();
     93
     94        double roundedMax, intervalWidth;
     95        CalculateResidualParameters(residuals, out roundedMax, out intervalWidth);
    10996
    11097        ChartArea chartArea = chart.ChartAreas[0];
     
    11299        chartArea.AxisX.Maximum = roundedMax + intervalWidth;
    113100        // get the highest frequency of a residual of any series
    114         chartArea.AxisY.Maximum = (from series in relativeFrequencies.Values
    115                                    select (from residual in series
    116                                            select residual.ElementAt(1)).Max()).Max();
     101        chartArea.AxisY.Maximum = max;
    117102        if (chartArea.AxisY.Maximum < 0.1) {
    118103          chartArea.AxisY.Interval = 0.01;
     
    132117    }
    133118
    134     private Dictionary<string, List<double>> CalculateResiduals() {
    135       Dictionary<string, List<double>> residuals = new Dictionary<string, List<double>>();
    136 
    137       foreach (string series in ALL_SERIES) {
    138         residuals[series] = new List<double>();
    139       }
     119    private List<double> CalculateResiduals(IRegressionSolution solution) {
     120      List<double> residuals = new List<double>();
     121
     122      IRegressionProblemData problemdata = solution.ProblemData;
     123      List<double> targetValues = problemdata.Dataset.GetDoubleValues(Content.ProblemData.TargetVariable).ToList();
     124      List<double> estimatedValues = solution.EstimatedValues.ToList();
     125
     126      for (int i = 0; i < solution.ProblemData.Dataset.Rows; i++) {
     127        double residual = estimatedValues[i] - targetValues[i];
     128        residuals.Add(residual);
     129      }
     130      return residuals;
     131    }
     132
     133    private void CalculateFrequencies(List<double> residualValues, Series series) {
     134      double roundedMax, intervalWidth;
     135      CalculateResidualParameters(residualValues, out roundedMax, out intervalWidth);
     136
     137      IEnumerable<double> relevantResiduals = residualValues;
    140138      IRegressionProblemData problemdata = Content.ProblemData;
    141       List<double> targetValues = problemdata.Dataset.GetDoubleValues(Content.ProblemData.TargetVariable).ToList();
    142       List<double> estimatedValues = Content.EstimatedValues.ToList();
    143 
    144       for (int i = 0; i < Content.ProblemData.Dataset.Rows; i++) {
    145         double residual = estimatedValues[i] - targetValues[i];
    146         residuals[ALL_SAMPLES].Add(residual);
    147         if (i >= problemdata.TrainingPartition.Start && i < problemdata.TrainingPartition.End)
    148           residuals[TRAINING_SAMPLES].Add(residual);
    149         if (i >= problemdata.TestPartition.Start && i < problemdata.TestPartition.End)
    150           residuals[TEST_SAMPLES].Add(residual);
    151       }
    152       return residuals;
    153     }
    154 
    155     private void CalculateFrequencies(List<double> residualValues, string series, double max, double intervalWidth) {
     139      if (series.Name.Equals(TRAINING_SAMPLES)) {
     140        relevantResiduals = residualValues.Skip(problemdata.TrainingPartition.Start).Take(problemdata.TrainingPartition.Size);
     141      } else if (series.Name.Equals(TEST_SAMPLES)) {
     142        relevantResiduals = residualValues.Skip(problemdata.TestPartition.Start).Take(problemdata.TestPartition.Size);
     143      }
     144
    156145      double intervalCenter = intervalWidth / 2.0;
    157       double sampleCount = residualValues.Count();
    158       double current = -max;
     146      double sampleCount = relevantResiduals.Count();
     147      double current = -roundedMax;
     148      DataPointCollection seriesPoints = series.Points;
    159149
    160150      for (int i = 0; i <= bins; i++) {
    161         IEnumerable<double> help = residualValues.Where(x => x >= (current - intervalCenter) && x < (current + intervalCenter));
    162         relativeFrequencies[series].Add(new List<double>() { current, help.Count() / sampleCount, current - intervalCenter, current + intervalCenter });
     151        IEnumerable<double> help = relevantResiduals.Where(x => x >= (current - intervalCenter) && x < (current + intervalCenter));
     152        seriesPoints.AddXY(current, help.Count() / sampleCount);
     153        seriesPoints[seriesPoints.Count - 1]["from"] = (current - intervalCenter).ToString();
     154        seriesPoints[seriesPoints.Count - 1]["to"] = (current + intervalCenter).ToString();
    163155        current += intervalWidth;
    164156      }
    165157    }
    166158
    167     private double HumanRoundMax(double max) {
     159    private void ToggleSeriesData(Series series) {
     160      if (series.Points.Count > 0) {  //checks if series is shown
     161        if (chart.Series.Any(s => s != series && s.Points.Count > 0)) {
     162          series.Points.Clear();
     163        }
     164      } else if (Content != null) {
     165        List<double> residuals = CalculateResiduals(Content);
     166        CalculateFrequencies(residuals, series);
     167        chart.Legends[series.Legend].ForeColor = Color.Black;
     168        chart.Refresh();
     169      }
     170    }
     171
     172    private static void CalculateResidualParameters(List<double> residuals, out double roundedMax, out double intervalWidth) {
     173      double realMax = Math.Max(Math.Abs(residuals.Min()), Math.Abs(residuals.Max()));
     174      roundedMax = HumanRoundMax(realMax);
     175      intervalWidth = (roundedMax * 2.0) / bins;
     176      intervalWidth = HumanRoundMax(intervalWidth);
     177      // sets roundedMax to a value, so that zero will be in the middle of the x axis
     178      double help = realMax / intervalWidth;
     179      help = help % 1 < 0.5 ? (int)help : (int)help + 1;
     180      roundedMax = help * intervalWidth;
     181    }
     182
     183    private static double HumanRoundMax(double max) {
    168184      double base10;
    169185      if (max > 0) base10 = Math.Pow(10.0, Math.Floor(Math.Log10(max)));
     
    216232    }
    217233    #endregion
    218 
    219     private void ToggleSeriesData(Series series) {
    220       if (series.Points.Count > 0) {  //checks if series is shown
    221         if (chart.Series.Any(s => s != series && s.Points.Count > 0)) {
    222           series.Points.Clear();
    223         }
    224       } else if (Content != null) {
    225         ShowValues(series, relativeFrequencies[series.Name]);
    226         chart.Legends[series.Legend].ForeColor = Color.Black;
    227         chart.Refresh();
    228       }
    229     }
    230     private void ShowValues(Series series, List<List<double>> relativeSeriesFrequencies) {
    231       DataPointCollection seriesPoints = series.Points;
    232 
    233       foreach (var valueList in relativeSeriesFrequencies) {
    234         seriesPoints.AddXY(valueList[0], valueList[1]);
    235         seriesPoints[seriesPoints.Count - 1]["from"] = valueList[2].ToString();
    236         seriesPoints[seriesPoints.Count - 1]["to"] = valueList[3].ToString();
    237       }
    238     }
    239234  }
    240235}
  • branches/ChangeDatasetOfRegressionModel/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionScatterPlotView.cs

    r8032 r8513  
    148148        if (this.chart.Series[TRAINING_SERIES].Points.Count > 0)
    149149          this.chart.Series[TRAINING_SERIES].Points.DataBindXY(Content.EstimatedTrainingValues.ToArray(), "",
    150             dataset.GetDoubleValues(targetVariableName, Content.ProblemData.TrainingIndizes).ToArray(), "");
     150            dataset.GetDoubleValues(targetVariableName, Content.ProblemData.TrainingIndices).ToArray(), "");
    151151        if (this.chart.Series[TEST_SERIES].Points.Count > 0)
    152152          this.chart.Series[TEST_SERIES].Points.DataBindXY(Content.EstimatedTestValues.ToArray(), "",
    153            dataset.GetDoubleValues(targetVariableName, Content.ProblemData.TestIndizes).ToArray(), "");
     153           dataset.GetDoubleValues(targetVariableName, Content.ProblemData.TestIndices).ToArray(), "");
    154154
    155155        double max = Content.EstimatedTrainingValues.Concat(Content.EstimatedTestValues.Concat(Content.EstimatedValues.Concat(dataset.GetDoubleValues(targetVariableName)))).Max();
     
    196196          case TRAINING_SERIES:
    197197            predictedValues = Content.EstimatedTrainingValues.ToArray();
    198             targetValues = Content.ProblemData.Dataset.GetDoubleValues(targetVariableName, Content.ProblemData.TrainingIndizes).ToArray();
     198            targetValues = Content.ProblemData.Dataset.GetDoubleValues(targetVariableName, Content.ProblemData.TrainingIndices).ToArray();
    199199            break;
    200200          case TEST_SERIES:
    201201            predictedValues = Content.EstimatedTestValues.ToArray();
    202             targetValues = Content.ProblemData.Dataset.GetDoubleValues(targetVariableName, Content.ProblemData.TestIndizes).ToArray();
     202            targetValues = Content.ProblemData.Dataset.GetDoubleValues(targetVariableName, Content.ProblemData.TestIndices).ToArray();
    203203            break;
    204204        }
  • branches/ChangeDatasetOfRegressionModel/HeuristicLab.Problems.DataAnalysis.Views/3.4/Solution Views/DataAnalysisSolutionView.cs

    r7404 r8513  
    132132    }
    133133
     134    protected override void showDetailsCheckBox_CheckedChanged(object sender, EventArgs e) {
     135      if (showDetailsCheckBox.Checked && itemsListView.SelectedItems.Count == 1 && itemsListView.SelectedItems[0].Tag is Type) {
     136        Type viewType = (Type)itemsListView.SelectedItems[0].Tag;
     137        viewHost.ViewType = viewType;
     138        viewHost.Content = Content;
     139        splitContainer.Panel2Collapsed = false;
     140        detailsGroupBox.Enabled = true;
     141      } else base.showDetailsCheckBox_CheckedChanged(sender, e);
     142    }
     143
    134144    #region drag and drop
    135145    protected override void itemsListView_DragEnter(object sender, DragEventArgs e) {
Note: See TracChangeset for help on using the changeset viewer.