Changeset 14869 for branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/NonlinearRegression
- Timestamp:
- 04/14/17 08:58:45 (8 years ago)
- Location:
- branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4
-
Property
svn:mergeinfo
set to
(toggle deleted branches)
/stable/HeuristicLab.Algorithms.DataAnalysis/3.4 merged eligible /trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4 merged eligible /branches/1721-RandomForestPersistence/HeuristicLab.Algorithms.DataAnalysis/3.4 10321-10322 /branches/Benchmarking/sources/HeuristicLab.Algorithms.DataAnalysis/3.4 6917-7005 /branches/ClassificationModelComparison/HeuristicLab.Algorithms.DataAnalysis/3.4 9070-13099 /branches/CloningRefactoring/HeuristicLab.Algorithms.DataAnalysis/3.4 4656-4721 /branches/DataAnalysis Refactoring/HeuristicLab.Algorithms.DataAnalysis/3.4 5471-5808 /branches/DataAnalysis SolutionEnsembles/HeuristicLab.Algorithms.DataAnalysis/3.4 5815-6180 /branches/DataAnalysis/HeuristicLab.Algorithms.DataAnalysis/3.4 4458-4459,4462,4464 /branches/DataPreprocessing/HeuristicLab.Algorithms.DataAnalysis/3.4 10085-11101 /branches/GP.Grammar.Editor/HeuristicLab.Algorithms.DataAnalysis/3.4 6284-6795 /branches/GP.Symbols (TimeLag, Diff, Integral)/HeuristicLab.Algorithms.DataAnalysis/3.4 5060 /branches/HeuristicLab.DatasetRefactor/sources/HeuristicLab.Algorithms.DataAnalysis/3.4 11570-12508 /branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Algorithms.DataAnalysis/3.4 11130-12721 /branches/HeuristicLab.RegressionSolutionGradientView/HeuristicLab.Algorithms.DataAnalysis/3.4 13819-14091 /branches/HeuristicLab.TimeSeries/HeuristicLab.Algorithms.DataAnalysis/3.4 8116-8789 /branches/LogResidualEvaluator/HeuristicLab.Algorithms.DataAnalysis/3.4 10202-10483 /branches/NET40/sources/HeuristicLab.Algorithms.DataAnalysis/3.4 5138-5162 /branches/ParallelEngine/HeuristicLab.Algorithms.DataAnalysis/3.4 5175-5192 /branches/ProblemInstancesRegressionAndClassification/HeuristicLab.Algorithms.DataAnalysis/3.4 7773-7810 /branches/QAPAlgorithms/HeuristicLab.Algorithms.DataAnalysis/3.4 6350-6627 /branches/Restructure trunk solution/HeuristicLab.Algorithms.DataAnalysis/3.4 6828 /branches/SpectralKernelForGaussianProcesses/HeuristicLab.Algorithms.DataAnalysis/3.4 10204-10479 /branches/SuccessProgressAnalysis/HeuristicLab.Algorithms.DataAnalysis/3.4 5370-5682 /branches/Trunk/HeuristicLab.Algorithms.DataAnalysis/3.4 6829-6865 /branches/VNS/HeuristicLab.Algorithms.DataAnalysis/3.4 5594-5752 /branches/histogram/HeuristicLab.Algorithms.DataAnalysis/3.4 5959-6341
-
Property
svn:mergeinfo
set to
(toggle deleted branches)
-
branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/NonlinearRegression/NonlinearRegression.cs
r14319 r14869 21 21 22 22 using System; 23 using System.Collections.Generic; 23 24 using System.Linq; 25 using System.Threading; 24 26 using HeuristicLab.Analysis; 25 27 using HeuristicLab.Common; … … 157 159 158 160 #region nonlinear regression 159 protected override void Run( ) {161 protected override void Run(CancellationToken cancellationToken) { 160 162 IRegressionSolution bestSolution = null; 161 163 if (InitializeParametersRandomly) { … … 207 209 var parser = new InfixExpressionParser(); 208 210 var tree = parser.Parse(modelStructure); 211 // parser handles double and string variables equally by creating a VariableTreeNode 212 // post-process to replace VariableTreeNodes by FactorVariableTreeNodes for all string variables 213 var factorSymbol = new FactorVariable(); 214 factorSymbol.VariableNames = 215 problemData.AllowedInputVariables.Where(name => problemData.Dataset.VariableHasType<string>(name)); 216 factorSymbol.AllVariableNames = factorSymbol.VariableNames; 217 factorSymbol.VariableValues = 218 factorSymbol.VariableNames.Select(name => 219 new KeyValuePair<string, Dictionary<string, int>>(name, 220 problemData.Dataset.GetReadOnlyStringValues(name).Distinct() 221 .Select((n, i) => Tuple.Create(n, i)) 222 .ToDictionary(tup => tup.Item1, tup => tup.Item2))); 223 224 foreach (var parent in tree.IterateNodesPrefix().ToArray()) { 225 for (int i = 0; i < parent.SubtreeCount; i++) { 226 var varChild = parent.GetSubtree(i) as VariableTreeNode; 227 var factorVarChild = parent.GetSubtree(i) as FactorVariableTreeNode; 228 if (varChild != null && factorSymbol.VariableNames.Contains(varChild.VariableName)) { 229 parent.RemoveSubtree(i); 230 var factorTreeNode = (FactorVariableTreeNode)factorSymbol.CreateTreeNode(); 231 factorTreeNode.VariableName = varChild.VariableName; 232 factorTreeNode.Weights = 233 factorTreeNode.Symbol.GetVariableValues(factorTreeNode.VariableName).Select(_ => 1.0).ToArray(); 234 // weight = 1.0 for each value 235 parent.InsertSubtree(i, factorTreeNode); 236 } else if (factorVarChild != null && factorSymbol.VariableNames.Contains(factorVarChild.VariableName)) { 237 if (factorSymbol.GetVariableValues(factorVarChild.VariableName).Count() != factorVarChild.Weights.Length) 238 throw new ArgumentException( 239 string.Format("Factor variable {0} needs exactly {1} weights", 240 factorVarChild.VariableName, 241 factorSymbol.GetVariableValues(factorVarChild.VariableName).Count())); 242 parent.RemoveSubtree(i); 243 var factorTreeNode = (FactorVariableTreeNode)factorSymbol.CreateTreeNode(); 244 factorTreeNode.VariableName = factorVarChild.VariableName; 245 factorTreeNode.Weights = factorVarChild.Weights; 246 parent.InsertSubtree(i, factorTreeNode); 247 } 248 } 249 } 209 250 210 251 if (!SymbolicRegressionConstantOptimizationEvaluator.CanOptimizeConstants(tree)) throw new ArgumentException("The optimizer does not support the specified model structure.");
Note: See TracChangeset
for help on using the changeset viewer.