Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/21/11 16:33:35 (13 years ago)
Author:
gkronber
Message:

#1325 Implemented MATLAB formatter rule for variable conditions and integrated handling of variable condition symbols into variable frequency analyzer and symbolic classification problem.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Formatters/SymbolicExpressionTreeMATLABFormatter.cs

    r5433 r5524  
    8484        foreach (string variableName in variableNames)
    8585          stringBuilder.AppendLine("  " + variableName + " = Data(:, ???);");
    86         stringBuilder.AppendLine("  for "+CurrentIndexVariable+" = size(Data,1):-1:1");
    87         stringBuilder.AppendLine("    Target_estimated("+CurrentIndexVariable+") = " + FormatRecursively(node.SubTrees[0]) + ";");
     86        stringBuilder.AppendLine("  for " + CurrentIndexVariable + " = size(Data,1):-1:1");
     87        stringBuilder.AppendLine("    Target_estimated(" + CurrentIndexVariable + ") = " + FormatRecursively(node.SubTrees[0]) + ";");
    8888        stringBuilder.AppendLine("  end");
    8989        stringBuilder.AppendLine("end");
     
    9898        stringBuilder.AppendLine("  y = (f0 + 2*f1 - 2*f3 - f4) / 8;");
    9999        stringBuilder.AppendLine("end");
     100        stringBuilder.AppendLine("function y = sigmoid(slope, x, threshold, a, b)");
     101        stringBuilder.AppendLine("  p = 1.0 / (1 + exp(-slope * (x - threshold)));");
     102        stringBuilder.AppendLine("  y = p * a + (1-p) * b;");
     103        stringBuilder.AppendLine("end");
     104
    100105        return stringBuilder.ToString();
    101106      }
     
    269274        stringBuilder.Append(FormatRecursively(node.SubTrees[0]));
    270275        currentLag -= laggedNode.Lag;
     276      } else if (symbol is VariableCondition) {
     277        var varConditionNode = node as VariableConditionTreeNode;
     278        stringBuilder.AppendLine(" sigmoid(" + varConditionNode.Slope.ToString(CultureInfo.InvariantCulture) + ", " +
     279          varConditionNode.VariableName + LagToString(currentLag) + ", " +
     280          varConditionNode.Threshold.ToString(CultureInfo.InvariantCulture) + ", " +
     281          FormatRecursively(varConditionNode.SubTrees[0]) + ", " +
     282          FormatRecursively(varConditionNode.SubTrees[1]) + ")");
    271283      } else {
    272284        stringBuilder.Append("ERROR");
Note: See TracChangeset for help on using the changeset viewer.