Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/11/11 15:03:46 (14 years ago)
Author:
gkronber
Message:

Merged changes from trunk to data analysis exploration branch and added fractional distance metric evaluator. #1142

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/SymbolicRegressionModel.cs

    r4068 r5275  
    3232  [StorableClass]
    3333  [Item("SymbolicRegressionModel", "A symbolic regression model represents an entity that provides estimated values based on input values.")]
    34   public class SymbolicRegressionModel : NamedItem, IDataAnalysisModel {
    35     private SymbolicRegressionModel() : base() { } // for cloning
     34  public sealed class SymbolicRegressionModel : NamedItem, IDataAnalysisModel {
    3635    [StorableConstructor]
    37     protected SymbolicRegressionModel(bool deserializing)
    38       : base(deserializing) {
     36    private SymbolicRegressionModel(bool deserializing) : base(deserializing) { }
     37    private SymbolicRegressionModel(SymbolicRegressionModel original, Cloner cloner)
     38      : base(original, cloner) {
     39      tree = (SymbolicExpressionTree)cloner.Clone(original.tree);
     40      interpreter = (ISymbolicExpressionTreeInterpreter)cloner.Clone(original.interpreter);
     41      inputVariables = new List<string>(original.inputVariables);
    3942    }
     43
    4044    public SymbolicRegressionModel(ISymbolicExpressionTreeInterpreter interpreter, SymbolicExpressionTree tree)
    4145      : base() {
     
    4347      this.interpreter = interpreter;
    4448      this.inputVariables = tree.IterateNodesPrefix().OfType<VariableTreeNode>().Select(var => var.VariableName).Distinct().ToList();
     49    }
     50
     51    public override IDeepCloneable Clone(Cloner cloner) {
     52      return new SymbolicRegressionModel(this, cloner);
     53    }
     54
     55    [StorableHook(HookType.AfterDeserialization)]
     56    private void AfterDeserialization() {
     57      if (inputVariables == null)
     58        this.inputVariables = tree.IterateNodesPrefix().OfType<VariableTreeNode>().Select(var => var.VariableName).Distinct().ToList();
    4559    }
    4660
     
    6276
    6377    public IEnumerable<double> GetEstimatedValues(DataAnalysisProblemData problemData, int start, int end) {
    64       return interpreter.GetSymbolicExpressionTreeValues(tree, problemData.Dataset, Enumerable.Range(start, end - start));
     78      return GetEstimatedValues(problemData, Enumerable.Range(start, end - start));
    6579    }
    66 
    67     public override IDeepCloneable Clone(Cloner cloner) {
    68       var clone = (SymbolicRegressionModel)base.Clone(cloner);
    69       clone.tree = (SymbolicExpressionTree)cloner.Clone(tree);
    70       clone.interpreter = (ISymbolicExpressionTreeInterpreter)cloner.Clone(interpreter);
    71       clone.inputVariables = new List<string>(inputVariables);
    72       return clone;
     80    public IEnumerable<double> GetEstimatedValues(DataAnalysisProblemData problemData, IEnumerable<int> rows) {
     81      return interpreter.GetSymbolicExpressionTreeValues(tree, problemData.Dataset, rows);
    7382    }
    7483  }
Note: See TracChangeset for help on using the changeset viewer.