Changeset 16692 for branches/2521_ProblemRefactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4
- Timestamp:
- 03/18/19 17:24:30 (6 years ago)
- Location:
- branches/2521_ProblemRefactoring
- Files:
-
- 15 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/2521_ProblemRefactoring
- Property svn:ignore
-
old new 24 24 protoc.exe 25 25 obj 26 .vs
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/2521_ProblemRefactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views
- Property svn:mergeinfo changed
-
branches/2521_ProblemRefactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views-3.4.csproj
r11623 r16692 121 121 <Compile Include="InteractiveSymbolicRegressionSolutionSimplifierView.Designer.cs"> 122 122 <DependentUpon>InteractiveSymbolicRegressionSolutionSimplifierView.cs</DependentUpon> 123 </Compile> 124 <Compile Include="SymbolicRegressionModelMathView.cs"> 125 <SubType>UserControl</SubType> 126 </Compile> 127 <Compile Include="SymbolicRegressionModelMathView.designer.cs"> 128 <DependentUpon>SymbolicRegressionModelMathView.cs</DependentUpon> 123 129 </Compile> 124 130 <Compile Include="Plugin.cs" /> -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/InteractiveSymbolicRegressionSolutionSimplifierView.Designer.cs
r12012 r16692 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/InteractiveSymbolicRegressionSolutionSimplifierView.cs
r12720 r16692 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 21 21 22 22 using System; 23 using System.Collections.Generic;24 using System.Linq;25 23 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 24 using HeuristicLab.MainForm; 26 25 using HeuristicLab.Problems.DataAnalysis.Symbolic.Views; 27 26 28 27 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views { 29 28 public partial class InteractiveSymbolicRegressionSolutionSimplifierView : InteractiveSymbolicDataAnalysisSolutionSimplifierView { 30 private readonly SymbolicRegressionSolutionImpactValuesCalculator calculator;31 32 29 public new SymbolicRegressionSolution Content { 33 30 get { return (SymbolicRegressionSolution)base.Content; } … … 36 33 37 34 public InteractiveSymbolicRegressionSolutionSimplifierView() 38 : base( ) {35 : base(new SymbolicRegressionSolutionImpactValuesCalculator()) { 39 36 InitializeComponent(); 40 37 this.Caption = "Interactive Regression Solution Simplifier"; 41 calculator = new SymbolicRegressionSolutionImpactValuesCalculator();42 38 } 43 39 44 40 protected override void UpdateModel(ISymbolicExpressionTree tree) { 45 var model = new SymbolicRegressionModel( tree, Content.Model.Interpreter, Content.Model.LowerEstimationLimit, Content.Model.UpperEstimationLimit);41 var model = new SymbolicRegressionModel(Content.ProblemData.TargetVariable, tree, Content.Model.Interpreter, Content.Model.LowerEstimationLimit, Content.Model.UpperEstimationLimit); 46 42 model.Scale(Content.ProblemData); 47 43 Content.Model = model; 48 44 } 49 45 50 protected override Dictionary<ISymbolicExpressionTreeNode, double> CalculateReplacementValues(ISymbolicExpressionTree tree) { 51 return tree.Root.GetSubtree(0).GetSubtree(0).IterateNodesPrefix().ToDictionary( 52 n => n, 53 n => calculator.CalculateReplacementValue(Content.Model, n, Content.ProblemData, Content.ProblemData.TrainingIndices) 54 ); 55 } 56 57 protected override Dictionary<ISymbolicExpressionTreeNode, double> CalculateImpactValues(ISymbolicExpressionTree tree) { 58 var values = CalculateImpactAndReplacementValues(tree); 59 return values.ToDictionary(x => x.Key, x => x.Value.Item1); 60 } 61 62 protected override Dictionary<ISymbolicExpressionTreeNode, Tuple<double, double>> CalculateImpactAndReplacementValues(ISymbolicExpressionTree tree) { 63 var impactAndReplacementValues = new Dictionary<ISymbolicExpressionTreeNode, Tuple<double, double>>(); 64 foreach (var node in tree.Root.GetSubtree(0).GetSubtree(0).IterateNodesPrefix()) { 65 double impactValue, replacementValue, newQualityForImpactsCalculation; 66 calculator.CalculateImpactAndReplacementValues(Content.Model, node, Content.ProblemData, Content.ProblemData.TrainingIndices, out impactValue, out replacementValue, out newQualityForImpactsCalculation); 67 impactAndReplacementValues.Add(node, new Tuple<double, double>(impactValue, replacementValue)); 68 } 69 return impactAndReplacementValues; 70 } 71 72 protected override void btnOptimizeConstants_Click(object sender, EventArgs e) { 46 protected override ISymbolicExpressionTree OptimizeConstants(ISymbolicExpressionTree tree, IProgress progress) { 47 const int constOptIterations = 50; 48 var regressionProblemData = Content.ProblemData; 73 49 var model = Content.Model; 74 SymbolicRegressionConstantOptimizationEvaluator.OptimizeConstants(model.Interpreter, model.SymbolicExpressionTree, Content.ProblemData, Content.ProblemData.TrainingIndices, 75 applyLinearScaling: true, maxIterations: 50, upperEstimationLimit: model.UpperEstimationLimit, lowerEstimationLimit: model.LowerEstimationLimit); 76 UpdateModel(Content.Model.SymbolicExpressionTree); 50 SymbolicRegressionConstantOptimizationEvaluator.OptimizeConstants(model.Interpreter, tree, regressionProblemData, regressionProblemData.TrainingIndices, 51 applyLinearScaling: true, maxIterations: constOptIterations, updateVariableWeights: true, lowerEstimationLimit: model.LowerEstimationLimit, upperEstimationLimit: model.UpperEstimationLimit, 52 iterationCallback: (args, func, obj) => { 53 double newProgressValue = progress.ProgressValue + 1.0 / (constOptIterations + 2); // (maxIterations + 2) iterations are reported 54 progress.ProgressValue = Math.Min(newProgressValue, 1.0); 55 }); 56 return tree; 77 57 } 78 58 } -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/Plugin.cs.frame
r13321 r16692 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 26 26 27 27 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views { 28 [Plugin("HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views", "Provides views for symbolic regression problem classes.", "3.4. 9.$WCREV$")]28 [Plugin("HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views", "Provides views for symbolic regression problem classes.", "3.4.11.$WCREV$")] 29 29 [PluginFile("HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views-3.4.dll",PluginFileType.Assembly)] 30 30 [PluginDependency("HeuristicLab.Algorithms.DataAnalysis", "3.4")] 31 [PluginDependency("HeuristicLab.Collections", "3.3")]32 31 [PluginDependency("HeuristicLab.Common", "3.3")] 33 32 [PluginDependency("HeuristicLab.Common.Resources", "3.3")] -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/Properties/AssemblyInfo.cs.frame
r13321 r16692 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 31 31 [assembly: AssemblyCompany("")] 32 32 [assembly: AssemblyProduct("HeuristicLab")] 33 [assembly: AssemblyCopyright("(c) 2002-201 5HEAL")]33 [assembly: AssemblyCopyright("(c) 2002-2018 HEAL")] 34 34 [assembly: AssemblyTrademark("")] 35 35 [assembly: AssemblyCulture("")] … … 53 53 // by using the '*' as shown below: 54 54 [assembly: AssemblyVersion("3.4.0.0")] 55 [assembly: AssemblyFileVersion("3.4. 9.$WCREV$")]55 [assembly: AssemblyFileVersion("3.4.11.$WCREV$")] -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/SymbolicRegressionSolutionErrorCharacteristicsCurveView.Designer.cs
r12012 r16692 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/SymbolicRegressionSolutionErrorCharacteristicsCurveView.cs
r13003 r16692 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 21 21 22 22 using System; 23 using System.Collections; 23 24 using System.Collections.Generic; 25 using System.Diagnostics.Contracts; 24 26 using System.Linq; 25 27 using HeuristicLab.Algorithms.DataAnalysis; … … 46 48 if (!problemData.TrainingIndices.Any()) return null; // don't create an LR model if the problem does not have a training set (e.g. loaded into an existing model) 47 49 48 //clear checked inputVariables 49 foreach (var inputVariable in problemData.InputVariables.CheckedItems) { 50 problemData.InputVariables.SetItemCheckedState(inputVariable.Value, false); 51 } 50 var usedVariables = Content.Model.VariablesUsedForPrediction; 52 51 53 //check inputVariables used in the symbolic regression model 54 var usedVariables = 55 Content.Model.SymbolicExpressionTree.IterateNodesPostfix().OfType<VariableTreeNode>().Select( 56 node => node.VariableName).Distinct(); 57 foreach (var variable in usedVariables) { 58 problemData.InputVariables.SetItemCheckedState( 59 problemData.InputVariables.First(x => x.Value == variable), true); 60 } 52 var usedDoubleVariables = usedVariables 53 .Where(name => problemData.Dataset.VariableHasType<double>(name)) 54 .Distinct(); 61 55 62 var solution = LinearRegression.CreateLinearRegressionSolution(problemData, out rmse, out cvRmsError); 56 var usedFactorVariables = usedVariables 57 .Where(name => problemData.Dataset.VariableHasType<string>(name)) 58 .Distinct(); 59 60 // gkronber: for binary factors we actually produce a binary variable in the new dataset 61 // but only if the variable is not used as a full factor anyway (LR creates binary columns anyway) 62 var usedBinaryFactors = 63 Content.Model.SymbolicExpressionTree.IterateNodesPostfix().OfType<BinaryFactorVariableTreeNode>() 64 .Where(node => !usedFactorVariables.Contains(node.VariableName)) 65 .Select(node => Tuple.Create(node.VariableValue, node.VariableValue)); 66 67 // create a new problem and dataset 68 var variableNames = 69 usedDoubleVariables 70 .Concat(usedFactorVariables) 71 .Concat(usedBinaryFactors.Select(t => t.Item1 + "=" + t.Item2)) 72 .Concat(new string[] { problemData.TargetVariable }) 73 .ToArray(); 74 var variableValues = 75 usedDoubleVariables.Select(name => (IList)problemData.Dataset.GetDoubleValues(name).ToList()) 76 .Concat(usedFactorVariables.Select(name => problemData.Dataset.GetStringValues(name).ToList())) 77 .Concat( 78 // create binary variable 79 usedBinaryFactors.Select(t => problemData.Dataset.GetReadOnlyStringValues(t.Item1).Select(val => val == t.Item2 ? 1.0 : 0.0).ToList()) 80 ) 81 .Concat(new[] { problemData.Dataset.GetDoubleValues(problemData.TargetVariable).ToList() }); 82 83 var newDs = new Dataset(variableNames, variableValues); 84 var newProblemData = new RegressionProblemData(newDs, variableNames.Take(variableNames.Length - 1), variableNames.Last()); 85 newProblemData.TrainingPartition.Start = problemData.TrainingPartition.Start; 86 newProblemData.TrainingPartition.End = problemData.TrainingPartition.End; 87 newProblemData.TestPartition.Start = problemData.TestPartition.Start; 88 newProblemData.TestPartition.End = problemData.TestPartition.End; 89 90 var solution = LinearRegression.CreateLinearRegressionSolution(newProblemData, out rmse, out cvRmsError); 63 91 solution.Name = "Baseline (linear subset)"; 64 92 return solution; … … 68 96 protected override IEnumerable<IRegressionSolution> CreateBaselineSolutions() { 69 97 foreach (var sol in base.CreateBaselineSolutions()) yield return sol; 98 99 // does not support lagged variables 100 if (Content.Model.SymbolicExpressionTree.IterateNodesPrefix().OfType<LaggedVariableTreeNode>().Any()) yield break; 101 70 102 yield return CreateLinearRegressionSolution(); 71 103 } -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/SymbolicRegressionSolutionResponseFunctionView.Designer.cs
r12012 r16692 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/SymbolicRegressionSolutionResponseFunctionView.cs
r12012 r16692 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/SymbolicRegressionSolutionView.Designer.cs
r12012 r16692 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/SymbolicRegressionSolutionView.cs
r12012 r16692 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 51 51 private void btn_SimplifyModel_Click(object sender, EventArgs e) { 52 52 var view = new InteractiveSymbolicRegressionSolutionSimplifierView(); 53 view.Show(); // open view first that a progress can be displayed when setting the content 53 54 view.Content = (SymbolicRegressionSolution)this.Content.Clone(); 54 view.Show();55 55 } 56 56 -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/VariableTrackbar.Designer.cs
r12012 r16692 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/VariableTrackbar.cs
r12012 r16692 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab.
Note: See TracChangeset
for help on using the changeset viewer.