Changeset 14243
- Timestamp:
- 08/08/16 13:00:06 (8 years ago)
- Location:
- branches/symbreg-factors-2650
- Files:
-
- 15 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
branches/symbreg-factors-2650/HeuristicLab.Algorithms.DataAnalysis/3.4/Linear/LinearDiscriminantAnalysis.cs
r14240 r14243 103 103 var varName = kvp.Key; 104 104 foreach (var cat in kvp.Value) { 105 FactorVariableTreeNode vNode =106 ( FactorVariableTreeNode)new HeuristicLab.Problems.DataAnalysis.Symbolic.FactorVariable().CreateTreeNode();105 BinaryFactorVariableTreeNode vNode = 106 (BinaryFactorVariableTreeNode)new HeuristicLab.Problems.DataAnalysis.Symbolic.BinaryFactorVariable().CreateTreeNode(); 107 107 vNode.VariableName = varName; 108 108 vNode.VariableValue = cat; -
branches/symbreg-factors-2650/HeuristicLab.Algorithms.DataAnalysis/3.4/Linear/LinearRegression.cs
r14240 r14243 107 107 var varName = kvp.Key; 108 108 foreach (var cat in kvp.Value) { 109 FactorVariableTreeNode vNode =110 ( FactorVariableTreeNode)new HeuristicLab.Problems.DataAnalysis.Symbolic.FactorVariable().CreateTreeNode();109 BinaryFactorVariableTreeNode vNode = 110 (BinaryFactorVariableTreeNode)new HeuristicLab.Problems.DataAnalysis.Symbolic.BinaryFactorVariable().CreateTreeNode(); 111 111 vNode.VariableName = varName; 112 112 vNode.VariableValue = cat; -
branches/symbreg-factors-2650/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionConstantOptimizationEvaluator.cs
r14237 r14243 205 205 ConstantTreeNode constantTreeNode = node as ConstantTreeNode; 206 206 VariableTreeNode variableTreeNode = node as VariableTreeNode; 207 FactorVariableTreeNode factorVariableTreeNode = node asFactorVariableTreeNode;207 BinaryFactorVariableTreeNode factorVariableTreeNode = node as BinaryFactorVariableTreeNode; 208 208 if (constantTreeNode != null) 209 209 c[i++] = constantTreeNode.Value; … … 273 273 ConstantTreeNode constantTreeNode = node as ConstantTreeNode; 274 274 VariableTreeNode variableTreeNode = node as VariableTreeNode; 275 FactorVariableTreeNode factorVarTreeNode = node asFactorVariableTreeNode;275 BinaryFactorVariableTreeNode factorVarTreeNode = node as BinaryFactorVariableTreeNode; 276 276 if (constantTreeNode != null) 277 277 constantTreeNode.Value = constants[i++]; … … 305 305 return true; 306 306 } 307 if (node.Symbol is Variable || node.Symbol is FactorVariable) {307 if (node.Symbol is Variable || node.Symbol is BinaryFactorVariable) { 308 308 var varNode = node as VariableTreeNodeBase; 309 var factorVarNode = node as FactorVariableTreeNode;309 var factorVarNode = node as BinaryFactorVariableTreeNode; 310 310 // factor variable values are only 0 or 1 and set in x accordingly 311 311 var par = new AutoDiff.Variable(); … … 493 493 where 494 494 !(n.Symbol is Variable) && 495 !(n.Symbol is FactorVariable) &&495 !(n.Symbol is BinaryFactorVariable) && 496 496 !(n.Symbol is Constant) && 497 497 !(n.Symbol is Addition) && -
branches/symbreg-factors-2650/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/Symbols/VariableView.cs
r14238 r14243 35 35 [View("Variable View")] 36 36 [Content(typeof(Variable), true)] 37 [Content(typeof( FactorVariable), true)]37 [Content(typeof(BinaryFactorVariable), true)] 38 38 public partial class VariableView : SymbolView { 39 39 private CheckedItemCollectionView<StringValue> variableNamesView; -
branches/symbreg-factors-2650/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisVariableFrequencyAnalyzer.cs
r14238 r14243 168 168 tree.Root.ForEachNodePrefix(node => { 169 169 if (node is IVariableTreeNode) { 170 var factorNode = node as FactorVariableTreeNode;170 var factorNode = node as BinaryFactorVariableTreeNode; 171 171 if (factorNode != null && !aggregateFactorVariables) { 172 172 IncReferenceCount(references, factorNode.VariableName + "=" + factorNode.VariableValue); … … 186 186 if (node is IVariableTreeNode) { 187 187 var laggedVarTreeNode = node as LaggedVariableTreeNode; 188 var factorVarTreeNode = node as FactorVariableTreeNode;188 var factorVarTreeNode = node as BinaryFactorVariableTreeNode; 189 189 var varConditionTreeNode = node as VariableConditionTreeNode; 190 190 if (laggedVarTreeNode != null) { -
branches/symbreg-factors-2650/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Grammars/ArithmeticExpressionGrammar.cs
r14232 r14243 53 53 constant.MaxValue = 20; 54 54 var variableSymbol = new HeuristicLab.Problems.DataAnalysis.Symbolic.Variable(); 55 var factorVariableSymbol = new FactorVariable();55 var factorVariableSymbol = new BinaryFactorVariable(); 56 56 57 57 var allSymbols = new List<Symbol>() { add, sub, mul, div, constant, variableSymbol, factorVariableSymbol }; -
branches/symbreg-factors-2650/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Grammars/FullFunctionalExpressionGrammar.cs
r14232 r14243 115 115 constant.MaxValue = 20; 116 116 var variableSymbol = new HeuristicLab.Problems.DataAnalysis.Symbolic.Variable(); 117 var factorVariable = new FactorVariable();117 var factorVariable = new BinaryFactorVariable(); 118 118 var laggedVariable = new LaggedVariable(); 119 119 laggedVariable.InitialFrequency = 0.0; -
branches/symbreg-factors-2650/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Grammars/TypeCoherentExpressionGrammar.cs
r14232 r14243 104 104 constant.MaxValue = 20; 105 105 var variableSymbol = new Variable(); 106 var factorVariable = new FactorVariable();106 var factorVariable = new BinaryFactorVariable(); 107 107 var laggedVariable = new LaggedVariable(); 108 108 var autoregressiveVariable = new AutoregressiveTargetVariable(); -
branches/symbreg-factors-2650/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/OpCodes.cs
r14232 r14243 132 132 { typeof(Erf), OpCodes.Erf}, 133 133 { typeof(Bessel), OpCodes.Bessel}, 134 { typeof( FactorVariable), OpCodes.FactorVariable }134 { typeof(BinaryFactorVariable), OpCodes.FactorVariable } 135 135 }; 136 136 -
branches/symbreg-factors-2650/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeILEmittingInterpreter.cs
r14237 r14243 629 629 } 630 630 case OpCodes.FactorVariable: { 631 FactorVariableTreeNode varNode = currentInstr.dynamicNode asFactorVariableTreeNode;631 BinaryFactorVariableTreeNode varNode = currentInstr.dynamicNode as BinaryFactorVariableTreeNode; 632 632 il.Emit(System.Reflection.Emit.OpCodes.Ldarg_1); // load columns array 633 633 il.Emit(System.Reflection.Emit.OpCodes.Ldc_I4, (int)currentInstr.data); -
branches/symbreg-factors-2650/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeInterpreter.cs
r14237 r14243 145 145 instr.data = dataset.GetReadOnlyDoubleValues(variableTreeNode.VariableName); 146 146 } else if (instr.opCode == OpCodes.FactorVariable) { 147 var factorTreeNode = instr.dynamicNode as FactorVariableTreeNode;147 var factorTreeNode = instr.dynamicNode as BinaryFactorVariableTreeNode; 148 148 instr.data = dataset.GetReadOnlyStringValues(factorTreeNode.VariableName); 149 149 } else if (instr.opCode == OpCodes.LagVariable) { … … 461 461 case OpCodes.FactorVariable: { 462 462 if (row < 0 || row >= dataset.Rows) return double.NaN; 463 var factorVarTreeNode = currentInstr.dynamicNode as FactorVariableTreeNode;463 var factorVarTreeNode = currentInstr.dynamicNode as BinaryFactorVariableTreeNode; 464 464 return ((IList<string>)currentInstr.data)[row] == factorVarTreeNode.VariableValue ? factorVarTreeNode.Weight : 0; 465 465 } -
branches/symbreg-factors-2650/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeLinearInterpreter.cs
r14237 r14243 151 151 if (row < 0 || row >= dataset.Rows) instr.value = double.NaN; 152 152 else { 153 var factorTreeNode = instr.dynamicNode as FactorVariableTreeNode;153 var factorTreeNode = instr.dynamicNode as BinaryFactorVariableTreeNode; 154 154 instr.value = ((IList<string>)instr.data)[row] == factorTreeNode.VariableValue ? factorTreeNode.Weight : 0; 155 155 } … … 399 399 break; 400 400 case OpCodes.FactorVariable: { 401 var factorVariableTreeNode = instr.dynamicNode as FactorVariableTreeNode;401 var factorVariableTreeNode = instr.dynamicNode as BinaryFactorVariableTreeNode; 402 402 instr.data = dataset.GetReadOnlyStringValues(factorVariableTreeNode.VariableName); 403 403 } -
branches/symbreg-factors-2650/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisExpressionTreeSimplifier.cs
r14238 r14243 837 837 var groupedVarNodes = from node in subtrees.OfType<VariableTreeNodeBase>() 838 838 let lag = (node is LaggedVariableTreeNode) ? ((LaggedVariableTreeNode)node).Lag : 0 839 let cat = (node is FactorVariableTreeNode) ? ((FactorVariableTreeNode)node).VariableValue : string.Empty839 let cat = (node is BinaryFactorVariableTreeNode) ? ((BinaryFactorVariableTreeNode)node).VariableValue : string.Empty 840 840 group node by node.VariableName + cat + lag into g 841 841 select g; … … 947 947 return aVar.VariableName == bVar.VariableName; 948 948 } 949 var aFactor = a as FactorVariableTreeNode;950 var bFactor = b as FactorVariableTreeNode;949 var aFactor = a as BinaryFactorVariableTreeNode; 950 var bFactor = b as BinaryFactorVariableTreeNode; 951 951 if (aFactor != null && bFactor != null) { 952 952 return aFactor.VariableName == bFactor.VariableName && -
branches/symbreg-factors-2650/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisProblem.cs
r14238 r14243 219 219 } 220 220 } 221 foreach (var factorSymbol in grammar.Symbols.OfType< FactorVariable>()) {221 foreach (var factorSymbol in grammar.Symbols.OfType<BinaryFactorVariable>()) { 222 222 if (!factorSymbol.Fixed) { 223 223 factorSymbol.AllVariableNames = problemData.InputVariables.Select(x => x.Value).Where(x => ds.VariableHasType<string>(x)); -
branches/symbreg-factors-2650/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisSolutionImpactValuesCalculator.cs
r14232 r14243 43 43 //optimization: constant nodes return always the same value 44 44 ConstantTreeNode constantNode = node as ConstantTreeNode; 45 FactorVariableTreeNode factorNode = node asFactorVariableTreeNode;45 BinaryFactorVariableTreeNode factorNode = node as BinaryFactorVariableTreeNode; 46 46 if (constantNode != null) { 47 47 yield return constantNode.Value; -
branches/symbreg-factors-2650/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/BinaryFactorVariable.cs
r14242 r14243 29 29 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { 30 30 [StorableClass] 31 [Item(" FactorVariable", "Represents a categorical variable (comparable to factors as in R).")]32 public class FactorVariable : VariableBase {31 [Item("BinaryFactorVariable", "Represents a categorical variable (comparable to factors as in R) and it's value.")] 32 public class BinaryFactorVariable : VariableBase { 33 33 34 34 private Dictionary<string, List<string>> variableValues; … … 47 47 48 48 [StorableConstructor] 49 protected FactorVariable(bool deserializing)49 protected BinaryFactorVariable(bool deserializing) 50 50 : base(deserializing) { 51 51 variableValues = new Dictionary<string, List<string>>(); 52 52 } 53 protected FactorVariable(FactorVariable original, Cloner cloner)53 protected BinaryFactorVariable(BinaryFactorVariable original, Cloner cloner) 54 54 : base(original, cloner) { 55 55 variableValues = 56 56 original.variableValues.ToDictionary(kvp => kvp.Key, kvp => new List<string>(kvp.Value)); 57 57 } 58 public FactorVariable() : this("FactorVariable", "Represents a categorical variable (comparable to factors as in R).") { }59 public FactorVariable(string name, string description)58 public BinaryFactorVariable() : this("BinaryFactorVariable", "Represents a categorical variable (comparable to factors as in R) and it's value.") { } 59 public BinaryFactorVariable(string name, string description) 60 60 : base(name, description) { 61 61 variableValues = new Dictionary<string, List<string>>(); … … 67 67 68 68 public override IDeepCloneable Clone(Cloner cloner) { 69 return new FactorVariable(this, cloner);69 return new BinaryFactorVariable(this, cloner); 70 70 } 71 71 -
branches/symbreg-factors-2650/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/BinaryFactorVariableTreeNode.cs
r14242 r14243 22 22 using HeuristicLab.Common; 23 23 using HeuristicLab.Core; 24 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;25 24 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 25 using HeuristicLab.Random; 27 26 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { 28 27 [StorableClass] 29 public class FactorVariableTreeNode : VariableTreeNodeBase {30 public new FactorVariable Symbol {31 get { return ( FactorVariable)base.Symbol; }28 public class BinaryFactorVariableTreeNode : VariableTreeNodeBase { 29 public new BinaryFactorVariable Symbol { 30 get { return (BinaryFactorVariable)base.Symbol; } 32 31 } 33 32 … … 40 39 41 40 [StorableConstructor] 42 protected FactorVariableTreeNode(bool deserializing) : base(deserializing) { }43 protected FactorVariableTreeNode(FactorVariableTreeNode original, Cloner cloner)41 protected BinaryFactorVariableTreeNode(bool deserializing) : base(deserializing) { } 42 protected BinaryFactorVariableTreeNode(BinaryFactorVariableTreeNode original, Cloner cloner) 44 43 : base(original, cloner) { 45 44 variableValue = original.variableValue; 46 45 } 47 protected FactorVariableTreeNode() { }48 public FactorVariableTreeNode(FactorVariable variableSymbol) : base(variableSymbol) { }46 protected BinaryFactorVariableTreeNode() { } 47 public BinaryFactorVariableTreeNode(BinaryFactorVariable variableSymbol) : base(variableSymbol) { } 49 48 50 49 public override bool HasLocalParameters { … … 73 72 74 73 public override IDeepCloneable Clone(Cloner cloner) { 75 return new FactorVariableTreeNode(this, cloner);74 return new BinaryFactorVariableTreeNode(this, cloner); 76 75 } 77 76
Note: See TracChangeset
for help on using the changeset viewer.