Changeset 14351 for branches/symbreg-factors-2650/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter
- Timestamp:
- 10/23/16 09:44:29 (8 years ago)
- Location:
- branches/symbreg-factors-2650
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/symbreg-factors-2650
- Property svn:mergeinfo changed
/trunk/sources merged: 14332,14340-14350
- Property svn:mergeinfo changed
-
branches/symbreg-factors-2650/HeuristicLab.Problems.DataAnalysis.Symbolic
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic merged: 14345,14347,14350
- Property svn:mergeinfo changed
-
branches/symbreg-factors-2650/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionCompiledTreeInterpreter.cs
r14185 r14351 614 614 case OpCodes.VariableCondition: { 615 615 var variableConditionTreeNode = (VariableConditionTreeNode)node; 616 if (variableConditionTreeNode.Symbol.IgnoreSlope) throw new NotSupportedException("Strict variable conditionals are not supported"); 616 617 var variableName = variableConditionTreeNode.VariableName; 617 618 var indexExpr = Expression.Constant(variableIndices[variableName]); -
branches/symbreg-factors-2650/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeInterpreter.cs
r14251 r14351 488 488 if (row < 0 || row >= dataset.Rows) return double.NaN; 489 489 var variableConditionTreeNode = (VariableConditionTreeNode)currentInstr.dynamicNode; 490 double variableValue = ((IList<double>)currentInstr.data)[row]; 491 double x = variableValue - variableConditionTreeNode.Threshold; 492 double p = 1 / (1 + Math.Exp(-variableConditionTreeNode.Slope * x)); 493 494 double trueBranch = Evaluate(dataset, ref row, state); 495 double falseBranch = Evaluate(dataset, ref row, state); 496 497 return trueBranch * p + falseBranch * (1 - p); 490 if (!variableConditionTreeNode.Symbol.IgnoreSlope) { 491 double variableValue = ((IList<double>)currentInstr.data)[row]; 492 double x = variableValue - variableConditionTreeNode.Threshold; 493 double p = 1 / (1 + Math.Exp(-variableConditionTreeNode.Slope * x)); 494 495 double trueBranch = Evaluate(dataset, ref row, state); 496 double falseBranch = Evaluate(dataset, ref row, state); 497 498 return trueBranch * p + falseBranch * (1 - p); 499 } else { 500 // strict threshold 501 double variableValue = ((IList<double>)currentInstr.data)[row]; 502 if (variableValue <= variableConditionTreeNode.Threshold) { 503 var left = Evaluate(dataset, ref row, state); 504 state.SkipInstructions(); 505 return left; 506 } else { 507 state.SkipInstructions(); 508 return Evaluate(dataset, ref row, state); 509 } 510 } 498 511 } 499 512 default: -
branches/symbreg-factors-2650/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeLinearInterpreter.cs
r14330 r14351 126 126 private readonly object syncRoot = new object(); 127 127 public IEnumerable<double> GetSymbolicExpressionTreeValues(ISymbolicExpressionTree tree, IDataset dataset, IEnumerable<int> rows) { 128 if (!rows.Any()) return Enumerable.Empty<double>(); 128 129 if (CheckExpressionsWithIntervalArithmetic) 129 130 throw new NotSupportedException("Interval arithmetic is not yet supported in the symbolic data analysis interpreter."); … … 171 172 if (row < 0 || row >= dataset.Rows) instr.value = double.NaN; 172 173 var variableConditionTreeNode = (VariableConditionTreeNode)instr.dynamicNode; 173 double variableValue = ((IList<double>)instr.data)[row]; 174 double x = variableValue - variableConditionTreeNode.Threshold; 175 double p = 1 / (1 + Math.Exp(-variableConditionTreeNode.Slope * x)); 176 177 double trueBranch = code[instr.childIndex].value; 178 double falseBranch = code[instr.childIndex + 1].value; 179 180 instr.value = trueBranch * p + falseBranch * (1 - p); 174 if (!variableConditionTreeNode.Symbol.IgnoreSlope) { 175 double variableValue = ((IList<double>)instr.data)[row]; 176 double x = variableValue - variableConditionTreeNode.Threshold; 177 double p = 1 / (1 + Math.Exp(-variableConditionTreeNode.Slope * x)); 178 179 double trueBranch = code[instr.childIndex].value; 180 double falseBranch = code[instr.childIndex + 1].value; 181 182 instr.value = trueBranch * p + falseBranch * (1 - p); 183 } else { 184 double variableValue = ((IList<double>)instr.data)[row]; 185 if (variableValue <= variableConditionTreeNode.Threshold) { 186 instr.value = code[instr.childIndex].value; 187 } else { 188 instr.value = code[instr.childIndex + 1].value; 189 } 190 } 181 191 } else if (instr.opCode == OpCodes.Add) { 182 192 double s = code[instr.childIndex].value; … … 433 443 for (int j = 1; j != seq.Length; ++j) 434 444 seq[j].skip = true; 435 }436 break;445 break; 446 } 437 447 } 438 448 #endregion
Note: See TracChangeset
for help on using the changeset viewer.