Changeset 17928 for branches/3026_IntegrationIntoSymSpace/HeuristicLab.Problems.DataAnalysis.Views/3.4
- Timestamp:
- 04/06/21 13:13:32 (3 years ago)
- Location:
- branches/3026_IntegrationIntoSymSpace
- Files:
-
- 10 edited
- 9 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/3026_IntegrationIntoSymSpace
- Property svn:mergeinfo changed
-
branches/3026_IntegrationIntoSymSpace/HeuristicLab.Problems.DataAnalysis.Views
- Property svn:mergeinfo changed
-
branches/3026_IntegrationIntoSymSpace/HeuristicLab.Problems.DataAnalysis.Views/3.4/Classification/ClassificationSolutionVariableImpactsView.Designer.cs
r17180 r17928 192 192 this.Name = "ClassificationSolutionVariableImpactsView"; 193 193 this.Size = new System.Drawing.Size(712, 365); 194 this.VisibleChanged += new System.EventHandler(this.ClassificationSolutionVariableImpactsView_VisibleChanged);195 194 this.ResumeLayout(false); 196 195 this.PerformLayout(); -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.Problems.DataAnalysis.Views/3.4/Classification/ClassificationSolutionVariableImpactsView.cs
r17180 r17928 25 25 using System.Threading; 26 26 using System.Threading.Tasks; 27 using System.Windows.Forms; 27 28 using HeuristicLab.Common; 28 29 using HeuristicLab.Data; … … 86 87 } 87 88 } 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); 89 98 cancellationToken.Cancel(); 90 99 } … … 137 146 .ToList(); 138 147 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)); 142 149 143 150 rawVariableImpacts.AddRange(impacts); 144 151 UpdateOrdering(); 152 } catch (OperationCanceledException) { 145 153 } finally { 146 154 Progress.Hide(this); … … 169 177 var clonedModel = (IClassificationModel)model.Clone(); 170 178 foreach (var variableName in originalVariableOrdering) { 171 if (cancellationToken.Token.IsCancellationRequested) { return null; }179 token.ThrowIfCancellationRequested(); 172 180 progress.ProgressValue = (double)++i / count; 173 181 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 36 36 namespace HeuristicLab.Problems.DataAnalysis.Views { 37 37 public partial class PartialDependencePlot : UserControl, IPartialDependencePlot { 38 private ModifiableDataset sharedFixedVariables; // used for sync ronising variable values between charts38 private ModifiableDataset sharedFixedVariables; // used for synchronizing variable values between charts 39 39 private ModifiableDataset internalDataset; // holds the x values for each point drawn 40 40 … … 351 351 352 352 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(); 355 356 356 357 if (initializeAxisRanges) { … … 438 439 chart.Palette = ChartColorPalette.None; 439 440 440 // Add confidence interval series before its cor esponding series for correct z index441 // Add confidence interval series before its corresponding series for correct z index 441 442 foreach (var solution in solutions) { 442 443 Series ciSeries; … … 529 530 530 531 public async Task AddSolutionAsync(IRegressionSolution solution) { 532 if (solutions.Contains(solution)) 533 return; 531 534 if (!SolutionsCompatible(solutions.Concat(new[] { solution }))) 532 535 throw new ArgumentException("The solution is not compatible with the problem data."); 533 if (solutions.Contains(solution))534 return;535 536 536 537 solutions.Add(solution); … … 567 568 var refSolution = solutions.First(); 568 569 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()); 569 572 foreach (var solution in solutions.Skip(1)) { 570 573 var variables1 = solution.ProblemData.Dataset.VariableNames; … … 573 576 574 577 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; 577 580 } 578 581 } … … 645 648 646 649 private void sharedFixedVariables_Reset(object sender, EventArgs e) { 650 RecalculateInternalDataset(); 647 651 var newValue = sharedFixedVariables.GetDoubleValue(FreeVariable, 0); 648 652 VerticalLineAnnotation.X = newValue; 649 UpdateCursor(); // triggers update of InternalDataset653 UpdateCursor(); 650 654 } 651 655 -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.Problems.DataAnalysis.Views/3.4/HeuristicLab.Problems.DataAnalysis.Views-3.4.csproj
r16658 r17928 103 103 <Private>False</Private> 104 104 </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> 105 109 <Reference Include="System" /> 106 110 <Reference Include="System.Core"> … … 236 240 <DependentUpon>ProblemDataView.cs</DependentUpon> 237 241 </Compile> 242 <Compile Include="Properties\Resources.Designer.cs"> 243 <AutoGen>True</AutoGen> 244 <DesignTime>True</DesignTime> 245 <DependentUpon>Resources.resx</DependentUpon> 246 </Compile> 238 247 <Compile Include="Regression\ConfidenceRegressionSolutionEstimatedValuesView.cs"> 239 248 <SubType>UserControl</SubType> … … 248 257 <DependentUpon>ConfidenceRegressionSolutionLineChartView.cs</DependentUpon> 249 258 </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> 250 265 <Compile Include="Regression\RegressionEnsembleSolutionModelWeightsView.cs"> 251 266 <SubType>UserControl</SubType> … … 337 352 <Compile Include="Regression\RegressionSolutionScatterPlotView.Designer.cs"> 338 353 <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> 339 366 </Compile> 340 367 <Compile Include="Solution Views\ClassificationSolutionView.cs"> … … 599 626 <DependentUpon>AbstractFeatureCorrelationView.cs</DependentUpon> 600 627 </EmbeddedResource> 628 <EmbeddedResource Include="Properties\Resources.resx"> 629 <Generator>ResXFileCodeGenerator</Generator> 630 <LastGenOutput>Resources.Designer.cs</LastGenOutput> 631 </EmbeddedResource> 601 632 </ItemGroup> 602 633 <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" /> 608 636 </ItemGroup> 609 637 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionLineChartViewBase.cs
r17180 r17928 81 81 this.chart.Series[ESTIMATEDVALUES_TRAINING_SERIES_NAME].LegendText = ESTIMATEDVALUES_TRAINING_SERIES_NAME; 82 82 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;84 83 int[] trainingIdx; 85 84 double[] trainingY; … … 120 119 double min = double.MaxValue, max = double.MinValue; 121 120 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])) 123 122 continue; 124 123 var y = point.YValues[0]; -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionResidualAnalysisView.cs
r17180 r17928 88 88 var ds = problemData.Dataset; 89 89 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();94 90 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) { 99 99 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 } 104 115 runs.Add(run); 105 116 } 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 116 118 if (string.IsNullOrEmpty(selectedXAxis)) 117 119 selectedXAxis = "Index"; … … 124 126 } 125 127 126 private void AddErrors(IRun run, double pred, double target) {128 private static void AddErrors(IRun run, double pred, double target) { 127 129 var residual = target - pred; 128 130 var relError = residual / target; … … 135 137 } 136 138 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) { 138 140 var ds = problemData.Dataset; 139 141 var run = new Run(); -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionVariableImpactsView.Designer.cs
r17180 r17928 192 192 this.Name = "RegressionSolutionVariableImpactsView"; 193 193 this.Size = new System.Drawing.Size(712, 365); 194 this.VisibleChanged += new System.EventHandler(this.RegressionSolutionVariableImpactsView_VisibleChanged);195 194 this.ResumeLayout(false); 196 195 this.PerformLayout(); -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionVariableImpactsView.cs
r17180 r17928 25 25 using System.Threading; 26 26 using System.Threading.Tasks; 27 using System.Windows.Forms; 27 28 using HeuristicLab.Common; 28 29 using HeuristicLab.Data; … … 86 87 } 87 88 } 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); 89 99 cancellationToken.Cancel(); 90 100 } … … 135 145 .ToList(); 136 146 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)); 140 148 141 149 rawVariableImpacts.AddRange(impacts); 142 150 UpdateOrdering(); 143 } 144 finally {151 } catch (OperationCanceledException) { 152 } finally { 145 153 Progress.Hide(this); 146 154 } … … 168 176 169 177 foreach (var variableName in originalVariableOrdering) { 170 if (cancellationToken.Token.IsCancellationRequested) { return null; }178 token.ThrowIfCancellationRequested(); 171 179 progress.ProgressValue = (double)++i / count; 172 180 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.