Changeset 14251 for branches/symbreg-factors-2650/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views
- Timestamp:
- 08/10/16 20:10:25 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/symbreg-factors-2650/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/SymbolicRegressionSolutionErrorCharacteristicsCurveView.cs
r14249 r14251 21 21 22 22 using System; 23 using System.Collections; 23 24 using System.Collections.Generic; 24 25 using System.Diagnostics.Contracts; … … 47 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) 48 49 49 var usedDoubleVariables = 50 Content.Model.SymbolicExpressionTree.IterateNodesPostfix() 51 .OfType<VariableTreeNode>() 52 .Select(node => node.VariableName) 53 .Concat( 54 Content.Model.SymbolicExpressionTree.IterateNodesPostfix() 55 .OfType<VariableConditionTreeNode>() 56 .Select(node => node.VariableName) 57 ) 50 var usedVariables = Content.Model.SymbolicExpressionTree.IterateNodesPostfix() 51 .OfType<IVariableTreeNode>() 52 .Select(node => node.VariableName).ToArray(); 53 54 var usedDoubleVariables = usedVariables 55 .Where(name => problemData.Dataset.VariableHasType<double>(name)) 58 56 .Distinct(); 59 57 60 var usedFactorVariables = 61 Content.Model.SymbolicExpressionTree.IterateNodesPostfix() 62 .OfType<BinaryFactorVariableTreeNode>() 63 .Select(node => Tuple.Create(node.VariableName, node.VariableValue)) 58 var usedFactorVariables = usedVariables 59 .Where(name => problemData.Dataset.VariableHasType<string>(name)) 64 60 .Distinct(); 61 62 // gkronber: for binary factors we actually produce a binary variable in the new dataset 63 // but only if the variable is not used as a full factor anyway (LR creates binary columns anyway) 64 var usedBinaryFactors = 65 Content.Model.SymbolicExpressionTree.IterateNodesPostfix().OfType<BinaryFactorVariableTreeNode>() 66 .Where(node => !usedFactorVariables.Contains(node.VariableName)) 67 .Select(node => Tuple.Create(node.VariableValue, node.VariableValue)); 65 68 66 69 // create a new problem and dataset 67 70 var variableNames = 68 71 usedDoubleVariables 69 .Concat(usedFactorVariables.Select(t => t.Item1 + "=" + t.Item2)) 72 .Concat(usedFactorVariables) 73 .Concat(usedBinaryFactors.Select(t => t.Item1 + "=" + t.Item2)) 70 74 .Concat(new string[] { problemData.TargetVariable }) 71 75 .ToArray(); 72 76 var variableValues = 73 usedDoubleVariables.Select(name => problemData.Dataset.GetDoubleValues(name).ToList()) 77 usedDoubleVariables.Select(name => (IList)problemData.Dataset.GetDoubleValues(name).ToList()) 78 .Concat(usedFactorVariables.Select(name => problemData.Dataset.GetStringValues(name).ToList())) 74 79 .Concat( 75 // create binary variable76 used FactorVariables.Select(t => problemData.Dataset.GetReadOnlyStringValues(t.Item1).Select(val => val == t.Item2 ? 1.0 : 0.0).ToList())80 // create binary variable 81 usedBinaryFactors.Select(t => problemData.Dataset.GetReadOnlyStringValues(t.Item1).Select(val => val == t.Item2 ? 1.0 : 0.0).ToList()) 77 82 ) 78 83 .Concat(new[] { problemData.Dataset.GetDoubleValues(problemData.TargetVariable).ToList() });
Note: See TracChangeset
for help on using the changeset viewer.