Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/21/16 17:59:36 (8 years ago)
Author:
gkronber
Message:

#2690: implemented methods to generate symbolic expression tree solutions for decision tree models (random forest and gradient boosted) as well as views which make it possible to inspect each of the individual trees in a GBT and RF solution

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeLinearInterpreter.cs

    r14282 r14345  
    126126    private readonly object syncRoot = new object();
    127127    public IEnumerable<double> GetSymbolicExpressionTreeValues(ISymbolicExpressionTree tree, IDataset dataset, IEnumerable<int> rows) {
     128      if (!rows.Any()) return Enumerable.Empty<double>();
    128129      if (CheckExpressionsWithIntervalArithmetic)
    129130        throw new NotSupportedException("Interval arithmetic is not yet supported in the symbolic data analysis interpreter.");
     
    159160          if (row < 0 || row >= dataset.Rows) instr.value = double.NaN;
    160161          var variableConditionTreeNode = (VariableConditionTreeNode)instr.dynamicNode;
    161           double variableValue = ((IList<double>)instr.data)[row];
    162           double x = variableValue - variableConditionTreeNode.Threshold;
    163           double p = 1 / (1 + Math.Exp(-variableConditionTreeNode.Slope * x));
    164 
    165           double trueBranch = code[instr.childIndex].value;
    166           double falseBranch = code[instr.childIndex + 1].value;
    167 
    168           instr.value = trueBranch * p + falseBranch * (1 - p);
     162          if (!variableConditionTreeNode.Symbol.IgnoreSlope) {
     163            double variableValue = ((IList<double>)instr.data)[row];
     164            double x = variableValue - variableConditionTreeNode.Threshold;
     165            double p = 1 / (1 + Math.Exp(-variableConditionTreeNode.Slope * x));
     166
     167            double trueBranch = code[instr.childIndex].value;
     168            double falseBranch = code[instr.childIndex + 1].value;
     169
     170            instr.value = trueBranch * p + falseBranch * (1 - p);
     171          } else {
     172            double variableValue = ((IList<double>)instr.data)[row];
     173            if (variableValue <= variableConditionTreeNode.Threshold) {
     174              instr.value = code[instr.childIndex].value;
     175            } else {
     176              instr.value = code[instr.childIndex + 1].value;
     177            }
     178          }
    169179        } else if (instr.opCode == OpCodes.Add) {
    170180          double s = code[instr.childIndex].value;
     
    411421              for (int j = 1; j != seq.Length; ++j)
    412422                seq[j].skip = true;
    413             }
    414             break;
     423              break;
     424            }
    415425        }
    416426        #endregion
Note: See TracChangeset for help on using the changeset viewer.