Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/16/16 12:04:56 (8 years ago)
Author:
pfleck
Message:

#2632

  • Added the name of the target variable in plots and charts (scatter, line, ...).
  • Renamed MathSymbolicDataAnalysisModelView and added two subclasses for regression and classification that shows the name of the target variable in the equation. (added and used a new Format method to the LatexFormatter that uses the actual target name when encountering the StartSymbol)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionLatexFormatter.cs

    r14185 r14255  
    3636    private int targetCount;
    3737    private int currentLag;
     38    private string targetVariable;
     39    private bool containsTimeSeriesSymbol;
    3840
    3941    [StorableConstructor]
     
    5557
    5658    public string Format(ISymbolicExpressionTree symbolicExpressionTree) {
     59      return Format(symbolicExpressionTree, null);
     60    }
     61    public string Format(ISymbolicExpressionTree symbolicExpressionTree, string targetVariable) {
    5762      try {
    5863        StringBuilder strBuilder = new StringBuilder();
    5964        constants.Clear();
     65        this.targetVariable = targetVariable;
     66        containsTimeSeriesSymbol = symbolicExpressionTree.IterateNodesBreadth().Any(n => IsTimeSeriesSymbol(n.Symbol));
    6067        strBuilder.AppendLine(FormatRecursively(symbolicExpressionTree.Root));
    6168        return strBuilder.ToString();
     
    6471        return ex.Message + Environment.NewLine + ex.StackTrace;
    6572      }
     73    }
     74    static bool IsTimeSeriesSymbol(ISymbol s) {
     75      return s is TimeLag || s is Integral || s is Derivative || s is LaggedVariable;
    6676    }
    6777
     
    197207        strBuilder.Append(invokeNode.Symbol.FunctionName + @" \left( ");
    198208      } else if (node.Symbol is StartSymbol) {
    199         strBuilder.Append("target_" + (targetCount++) + "(t) & = ");
     209        FormatStartSymbol(strBuilder);
    200210      } else if (node.Symbol is Argument) {
    201211        var argSym = node.Symbol as Argument;
     
    303313      } else if (node.Symbol is StartSymbol) {
    304314        strBuilder.Append(@"\\" + Environment.NewLine);
    305         strBuilder.Append("target_" + (targetCount++) + "(t) & = ");
     315        FormatStartSymbol(strBuilder);
    306316      } else if (node.Symbol is Power) {
    307317        strBuilder.Append(@"\right) ^ { \operatorname{round} \left(");
     
    433443    }
    434444
     445    private void FormatStartSymbol(StringBuilder strBuilder) {
     446      strBuilder.Append(targetVariable ?? "target_" + (targetCount++));
     447      if (containsTimeSeriesSymbol)
     448        strBuilder.Append("(t)");
     449      strBuilder.Append(" & = ");
     450    }
     451
    435452    private string LagToString(int lag) {
    436453      if (lag < 0) {
Note: See TracChangeset for help on using the changeset viewer.