Free cookie consent management tool by TermsFeed Policy Generator

Changeset 5524 for trunk


Ignore:
Timestamp:
02/21/11 16:33:35 (14 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.

Location:
trunk/sources
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Classification/3.3/Symbolic/SymbolicClassificationProblem.cs

    r5445 r5524  
    279279        FunctionTreeGrammar.RemoveSymbol(symbol);
    280280      foreach (var varSymbol in FunctionTreeGrammar.Symbols.OfType<HeuristicLab.Problems.DataAnalysis.Symbolic.Symbols.Variable>()) {
     281        varSymbol.VariableNames = ClassificationProblemData.InputVariables.CheckedItems.Select(x => x.Value.Value);
     282      }
     283      foreach (var varSymbol in FunctionTreeGrammar.Symbols.OfType<HeuristicLab.Problems.DataAnalysis.Symbolic.Symbols.VariableCondition>()) {
    281284        varSymbol.VariableNames = ClassificationProblemData.InputVariables.CheckedItems.Select(x => x.Value.Value);
    282285      }
  • 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");
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Symbols/VariableConditionTreeNode.cs

    r5467 r5524  
    8888
    8989    public override string ToString() {
    90       return variableName + " > " + threshold.ToString("E4") + Environment.NewLine +
    91         "slope: " + slope.ToString("E4");
     90      string thresholdString = threshold > 0 ? "+" + threshold.ToString("E4") : threshold.ToString("E4");
     91      return "Sigmoid " + "(" + slope.ToString("E4") + ", " + variableName + thresholdString + ")";
    9292    }
    9393  }
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/VariableFrequencyAnalyser.cs

    r5445 r5524  
    112112      var variableNames = from node in tree.IterateNodesPrefix().OfType<VariableTreeNode>()
    113113                          select node.VariableName;
     114      var variableNamesInConditions = from node in tree.IterateNodesPrefix().OfType<VariableConditionTreeNode>()
     115                                      select node.VariableName;
    114116
    115       foreach (var variableName in variableNames) {
     117      foreach (var variableName in variableNames.Concat(variableNamesInConditions)) {
    116118        if (!references.ContainsKey(variableName)) {
    117119          references[variableName] = 1;
Note: See TracChangeset for help on using the changeset viewer.