Ignore:
Timestamp:
04/04/18 16:23:55 (3 years ago)
Author:
lkammere
Message:

#2886: Priorize phrases whose (fully expanded) terms result in high R².

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2886_SymRegGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration/GrammarEnumeration/Grammar.cs

    r15861 r15883  
    44using HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration.GrammarEnumeration;
    55using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
     6using HeuristicLab.Problems.DataAnalysis;
    67using HeuristicLab.Problems.DataAnalysis.Symbolic;
    78
     
    174175    }
    175176
     177    public double EvaluatePhrase(SymbolString s, IRegressionProblemData problemData, bool optimizeConstants) {
     178      // Create sentences without Expression symbols.
     179      Symbol[] sEval = new Symbol[s.Count()];
     180
     181      for (int i = 0; i < sEval.Length; i++) {
     182        Symbol currSym = s[i];
     183        if (currSym is NonterminalSymbol && currSym != Expr)
     184          return 0.0;
     185
     186        if (currSym == Expr) {
     187          sEval[i] = Const;
     188        } else {
     189          sEval[i] = currSym;
     190        }
     191      }
     192
     193      SymbolicExpressionTree tree = ParseSymbolicExpressionTree(new SymbolString(sEval));
     194      double r2 = RSquaredEvaluator.Evaluate(problemData, tree, optimizeConstants);
     195
     196      return r2;
     197    }
     198
    176199    #region Parse to SymbolicExpressionTree
    177200
Note: See TracChangeset for help on using the changeset viewer.