Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/06/21 13:13:32 (3 years ago)
Author:
dpiringe
Message:

#3026

  • merged trunk into branch
Location:
branches/3026_IntegrationIntoSymSpace
Files:
10 edited
9 copied

Legend:

Unmodified
Added
Removed
  • branches/3026_IntegrationIntoSymSpace

  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.Problems.DataAnalysis.Views

  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.Problems.DataAnalysis.Views/3.4/Classification/ClassificationSolutionVariableImpactsView.Designer.cs

    r17180 r17928  
    192192      this.Name = "ClassificationSolutionVariableImpactsView";
    193193      this.Size = new System.Drawing.Size(712, 365);
    194       this.VisibleChanged += new System.EventHandler(this.ClassificationSolutionVariableImpactsView_VisibleChanged);
    195194      this.ResumeLayout(false);
    196195      this.PerformLayout();
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.Problems.DataAnalysis.Views/3.4/Classification/ClassificationSolutionVariableImpactsView.cs

    r17180 r17928  
    2525using System.Threading;
    2626using System.Threading.Tasks;
     27using System.Windows.Forms;
    2728using HeuristicLab.Common;
    2829using HeuristicLab.Data;
     
    8687      }
    8788    }
    88     private void ClassificationSolutionVariableImpactsView_VisibleChanged(object sender, EventArgs e) {
     89    protected override void OnVisibleChanged(EventArgs e) {
     90      base.OnVisibleChanged(e);
     91      if (!this.Visible) {
     92        cancellationToken.Cancel();
     93      }
     94    }
     95
     96    protected override void OnClosed(FormClosedEventArgs e) {
     97      base.OnClosed(e);
    8998      cancellationToken.Cancel();
    9099    }
     
    137146          .ToList();
    138147
    139         List<Tuple<string, double>> impacts = null;
    140         await Task.Run(() => { impacts = CalculateVariableImpacts(originalVariableOrdering, Content.Model, problemData, Content.EstimatedClassValues, dataPartition, replMethod, factorReplMethod, cancellationToken.Token, progress); });
    141         if (impacts == null) { return; }
     148        var impacts = await Task.Run(() => CalculateVariableImpacts(originalVariableOrdering, Content.Model, problemData, Content.EstimatedClassValues, dataPartition, replMethod, factorReplMethod, cancellationToken.Token, progress));
    142149
    143150        rawVariableImpacts.AddRange(impacts);
    144151        UpdateOrdering();
     152      } catch (OperationCanceledException) {
    145153      } finally {
    146154        Progress.Hide(this);
     
    169177      var clonedModel = (IClassificationModel)model.Clone();
    170178      foreach (var variableName in originalVariableOrdering) {
    171         if (cancellationToken.Token.IsCancellationRequested) { return null; }
     179        token.ThrowIfCancellationRequested();
    172180        progress.ProgressValue = (double)++i / count;
    173181        progress.Message = string.Format("Calculating impact for variable {0} ({1} of {2})", variableName, i, count);
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.Problems.DataAnalysis.Views/3.4/Controls/PartialDependencePlot.cs

    r17180 r17928  
    3636namespace HeuristicLab.Problems.DataAnalysis.Views {
    3737  public partial class PartialDependencePlot : UserControl, IPartialDependencePlot {
    38     private ModifiableDataset sharedFixedVariables; // used for syncronising variable values between charts
     38    private ModifiableDataset sharedFixedVariables; // used for synchronizing variable values between charts
    3939    private ModifiableDataset internalDataset; // holds the x values for each point drawn
    4040
     
    351351
    352352    private void RecalculateTrainingLimits(bool initializeAxisRanges) {
    353       trainingMin = solutions.Select(s => s.ProblemData.Dataset.GetDoubleValues(freeVariable, s.ProblemData.TrainingIndices).Where(x => !double.IsNaN(x)).Min()).Max();
    354       trainingMax = solutions.Select(s => s.ProblemData.Dataset.GetDoubleValues(freeVariable, s.ProblemData.TrainingIndices).Where(x => !double.IsNaN(x)).Max()).Min();
     353      //Set min and max to the interval ranges
     354      trainingMin = solutions.Select(s => s.ProblemData.VariableRanges.GetInterval(freeVariable).LowerBound).Max();
     355      trainingMax = solutions.Select(s => s.ProblemData.VariableRanges.GetInterval(freeVariable).UpperBound).Min();
    355356
    356357      if (initializeAxisRanges) {
     
    438439      chart.Palette = ChartColorPalette.None;
    439440
    440       // Add confidence interval series before its coresponding series for correct z index
     441      // Add confidence interval series before its corresponding series for correct z index
    441442      foreach (var solution in solutions) {
    442443        Series ciSeries;
     
    529530
    530531    public async Task AddSolutionAsync(IRegressionSolution solution) {
     532      if (solutions.Contains(solution))
     533        return;
    531534      if (!SolutionsCompatible(solutions.Concat(new[] { solution })))
    532535        throw new ArgumentException("The solution is not compatible with the problem data.");
    533       if (solutions.Contains(solution))
    534         return;
    535536
    536537      solutions.Add(solution);
     
    567568      var refSolution = solutions.First();
    568569      var refSolVars = refSolution.ProblemData.Dataset.VariableNames;
     570      var refFactorVars = refSolVars.Where(refSolution.ProblemData.Dataset.VariableHasType<string>);
     571      var distinctVals = refFactorVars.ToDictionary(fv => fv, fv => refSolution.ProblemData.Dataset.GetStringValues(fv).Distinct().ToArray());
    569572      foreach (var solution in solutions.Skip(1)) {
    570573        var variables1 = solution.ProblemData.Dataset.VariableNames;
     
    573576
    574577        foreach (var factorVar in variables1.Where(solution.ProblemData.Dataset.VariableHasType<string>)) {
    575           var distinctVals = refSolution.ProblemData.Dataset.GetStringValues(factorVar).Distinct();
    576           if (solution.ProblemData.Dataset.GetStringValues(factorVar).Any(val => !distinctVals.Contains(val))) return false;
     578          var refValues = distinctVals[factorVar];
     579          if (solution.ProblemData.Dataset.GetStringValues(factorVar).Distinct().Any(val => !refValues.Contains(val))) return false;
    577580        }
    578581      }
     
    645648
    646649    private void sharedFixedVariables_Reset(object sender, EventArgs e) {
     650      RecalculateInternalDataset();
    647651      var newValue = sharedFixedVariables.GetDoubleValue(FreeVariable, 0);
    648652      VerticalLineAnnotation.X = newValue;
    649       UpdateCursor(); // triggers update of InternalDataset
     653      UpdateCursor();
    650654    }
    651655
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.Problems.DataAnalysis.Views/3.4/HeuristicLab.Problems.DataAnalysis.Views-3.4.csproj

    r16658 r17928  
    103103      <Private>False</Private>
    104104    </Reference>
     105    <Reference Include="HEAL.Attic, Version=1.5.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     106      <SpecificVersion>False</SpecificVersion>
     107      <HintPath>..\..\bin\HEAL.Attic.dll</HintPath>
     108    </Reference>
    105109    <Reference Include="System" />
    106110    <Reference Include="System.Core">
     
    236240      <DependentUpon>ProblemDataView.cs</DependentUpon>
    237241    </Compile>
     242    <Compile Include="Properties\Resources.Designer.cs">
     243      <AutoGen>True</AutoGen>
     244      <DesignTime>True</DesignTime>
     245      <DependentUpon>Resources.resx</DependentUpon>
     246    </Compile>
    238247    <Compile Include="Regression\ConfidenceRegressionSolutionEstimatedValuesView.cs">
    239248      <SubType>UserControl</SubType>
     
    248257      <DependentUpon>ConfidenceRegressionSolutionLineChartView.cs</DependentUpon>
    249258    </Compile>
     259    <Compile Include="Regression\IntervalCollectionView.cs">
     260      <SubType>UserControl</SubType>
     261    </Compile>
     262    <Compile Include="Regression\IntervalCollectionView.Designer.cs">
     263      <DependentUpon>IntervalCollectionView.cs</DependentUpon>
     264    </Compile>
    250265    <Compile Include="Regression\RegressionEnsembleSolutionModelWeightsView.cs">
    251266      <SubType>UserControl</SubType>
     
    337352    <Compile Include="Regression\RegressionSolutionScatterPlotView.Designer.cs">
    338353      <DependentUpon>RegressionSolutionScatterPlotView.cs</DependentUpon>
     354    </Compile>
     355    <Compile Include="Regression\ShapeConstraintsView.cs">
     356      <SubType>UserControl</SubType>
     357    </Compile>
     358    <Compile Include="Regression\ShapeConstraintsView.Designer.cs">
     359      <DependentUpon>ShapeConstraintsView.cs</DependentUpon>
     360    </Compile>
     361    <Compile Include="Regression\ShapeConstraintView.cs">
     362      <SubType>UserControl</SubType>
     363    </Compile>
     364    <Compile Include="Regression\ShapeConstraintView.Designer.cs">
     365      <DependentUpon>ShapeConstraintView.cs</DependentUpon>
    339366    </Compile>
    340367    <Compile Include="Solution Views\ClassificationSolutionView.cs">
     
    599626      <DependentUpon>AbstractFeatureCorrelationView.cs</DependentUpon>
    600627    </EmbeddedResource>
     628    <EmbeddedResource Include="Properties\Resources.resx">
     629      <Generator>ResXFileCodeGenerator</Generator>
     630      <LastGenOutput>Resources.Designer.cs</LastGenOutput>
     631    </EmbeddedResource>
    601632  </ItemGroup>
    602633  <ItemGroup>
    603     <Reference Include="HEAL.Attic, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    604       <SpecificVersion>False</SpecificVersion>
    605       <HintPath>..\..\bin\HEAL.Attic.dll</HintPath>
    606       <Private>False</Private>
    607     </Reference>
     634    <EmbeddedResource Include="Resources\shapeConstraintsHelp.rtf" />
     635    <None Include="Resources\VS2008ImageLibrary_Annotations_Information.png" />
    608636  </ItemGroup>
    609637  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionLineChartViewBase.cs

    r17180 r17928  
    8181        this.chart.Series[ESTIMATEDVALUES_TRAINING_SERIES_NAME].LegendText = ESTIMATEDVALUES_TRAINING_SERIES_NAME;
    8282        this.chart.Series[ESTIMATEDVALUES_TRAINING_SERIES_NAME].ChartType = SeriesChartType.FastLine;
    83         this.chart.Series[ESTIMATEDVALUES_TRAINING_SERIES_NAME].EmptyPointStyle.Color = this.chart.Series[ESTIMATEDVALUES_TRAINING_SERIES_NAME].Color;
    8483        int[] trainingIdx;
    8584        double[] trainingY;
     
    120119        double min = double.MaxValue, max = double.MinValue;
    121120        foreach (var point in chart.Series.SelectMany(x => x.Points)) {
    122           if (!point.YValues.Any() || double.IsInfinity(point.YValues[0]) || double.IsNaN(point.YValues[0]))
     121          if (point.IsEmpty || !point.YValues.Any() || double.IsInfinity(point.YValues[0]) || double.IsNaN(point.YValues[0]))
    123122            continue;
    124123          var y = point.YValues[0];
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionResidualAnalysisView.cs

    r17180 r17928  
    8888      var ds = problemData.Dataset;
    8989      var runs = new RunCollection();
    90       // determine relevant variables (at least two different values)
    91       var doubleVars = ds.DoubleVariables.Where(vn => ds.GetDoubleValues(vn).Distinct().Skip(1).Any()).ToArray();
    92       var stringVars = ds.StringVariables.Where(vn => ds.GetStringValues(vn).Distinct().Skip(1).Any()).ToArray();
    93       var dateTimeVars = ds.DateTimeVariables.Where(vn => ds.GetDateTimeValues(vn).Distinct().Skip(1).Any()).ToArray();
    9490
    95       // produce training and test values separately as they might overlap (e.g. for ensembles)
    96       var predictedValuesTrain = Content.EstimatedTrainingValues.ToArray();
    97       int j = 0; // idx for predictedValues array
    98       foreach (var i in problemData.TrainingIndices) {
     91      var doubleVars = ds.DoubleVariables.ToArray();
     92      var stringVars = ds.StringVariables.ToArray();
     93      var dateTimeVars = ds.DateTimeVariables.ToArray();
     94
     95      var predictedValues = Content.EstimatedValues.ToArray();
     96      var targetValues = ds.GetReadOnlyDoubleValues(problemData.TargetVariable);
     97
     98      foreach (var i in problemData.AllIndices) {
    9999        var run = CreateRunForIdx(i, problemData, doubleVars, stringVars, dateTimeVars);
    100         var targetValue = ds.GetDoubleValue(problemData.TargetVariable, i);
    101         AddErrors(run, predictedValuesTrain[j++], targetValue);
    102         run.Results.Add(PartitionLabel, new StringValue("Training"));
    103         run.Color = Color.Gold;
     100        AddErrors(run, predictedValues[i], targetValues[i]);
     101
     102        if (problemData.IsTrainingSample(i) && problemData.IsTestSample(i)) {
     103          run.Results.Add(PartitionLabel, new StringValue("Training + Test"));
     104          run.Color = Color.Orange;
     105        } else if (problemData.IsTrainingSample(i)) {
     106          run.Results.Add(PartitionLabel, new StringValue("Training"));
     107          run.Color = Color.Gold;
     108        } else if (problemData.IsTestSample(i)) {
     109          run.Results.Add(PartitionLabel, new StringValue("Test"));
     110          run.Color = Color.Red;
     111        } else {
     112          run.Results.Add(PartitionLabel, new StringValue("Additional Data"));
     113          run.Color = Color.Black;
     114        }
    104115        runs.Add(run);
    105116      }
    106       var predictedValuesTest = Content.EstimatedTestValues.ToArray();
    107       j = 0;
    108       foreach (var i in problemData.TestIndices) {
    109         var run = CreateRunForIdx(i, problemData, doubleVars, stringVars, dateTimeVars);
    110         var targetValue = ds.GetDoubleValue(problemData.TargetVariable, i);
    111         AddErrors(run, predictedValuesTest[j++], targetValue);
    112         run.Results.Add(PartitionLabel, new StringValue("Test"));
    113         run.Color = Color.Red;
    114         runs.Add(run);
    115       }
     117
    116118      if (string.IsNullOrEmpty(selectedXAxis))
    117119        selectedXAxis = "Index";
     
    124126    }
    125127
    126     private void AddErrors(IRun run, double pred, double target) {
     128    private static void AddErrors(IRun run, double pred, double target) {
    127129      var residual = target - pred;
    128130      var relError = residual / target;
     
    135137    }
    136138
    137     private IRun CreateRunForIdx(int i, IRegressionProblemData problemData, IEnumerable<string> doubleVars, IEnumerable<string> stringVars, IEnumerable<string> dateTimeVars) {
     139    private static IRun CreateRunForIdx(int i, IRegressionProblemData problemData, IEnumerable<string> doubleVars, IEnumerable<string> stringVars, IEnumerable<string> dateTimeVars) {
    138140      var ds = problemData.Dataset;
    139141      var run = new Run();
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionVariableImpactsView.Designer.cs

    r17180 r17928  
    192192      this.Name = "RegressionSolutionVariableImpactsView";
    193193      this.Size = new System.Drawing.Size(712, 365);
    194       this.VisibleChanged += new System.EventHandler(this.RegressionSolutionVariableImpactsView_VisibleChanged);
    195194      this.ResumeLayout(false);
    196195      this.PerformLayout();
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionVariableImpactsView.cs

    r17180 r17928  
    2525using System.Threading;
    2626using System.Threading.Tasks;
     27using System.Windows.Forms;
    2728using HeuristicLab.Common;
    2829using HeuristicLab.Data;
     
    8687      }
    8788    }
    88     private void RegressionSolutionVariableImpactsView_VisibleChanged(object sender, EventArgs e) {
     89
     90    protected override void OnVisibleChanged(EventArgs e) {
     91      base.OnVisibleChanged(e);
     92      if (!this.Visible) {
     93        cancellationToken.Cancel();
     94      }
     95    }
     96
     97    protected override void OnClosed(FormClosedEventArgs e) {
     98      base.OnClosed(e);
    8999      cancellationToken.Cancel();
    90100    }
     
    135145          .ToList();
    136146
    137         List<Tuple<string, double>> impacts = null;
    138         await Task.Run(() => { impacts = CalculateVariableImpacts(originalVariableOrdering, Content.Model, problemData, Content.EstimatedValues, dataPartition, replMethod, factorReplMethod, cancellationToken.Token, progress); });
    139         if (impacts == null) { return; }
     147        var impacts = await Task.Run(() => CalculateVariableImpacts(originalVariableOrdering, Content.Model, problemData, Content.EstimatedValues, dataPartition, replMethod, factorReplMethod, cancellationToken.Token, progress));
    140148
    141149        rawVariableImpacts.AddRange(impacts);
    142150        UpdateOrdering();
    143       }
    144       finally {
     151      } catch (OperationCanceledException) {
     152      } finally {
    145153        Progress.Hide(this);
    146154      }
     
    168176
    169177      foreach (var variableName in originalVariableOrdering) {
    170         if (cancellationToken.Token.IsCancellationRequested) { return null; }
     178        token.ThrowIfCancellationRequested();
    171179        progress.ProgressValue = (double)++i / count;
    172180        progress.Message = string.Format("Calculating impact for variable {0} ({1} of {2})", variableName, i, count);
Note: See TracChangeset for help on using the changeset viewer.