Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.GeneticProgramming.BloodGlucosePrediction/Model.cs @ 16724

Last change on this file since 16724 was 14311, checked in by gkronber, 8 years ago

simplification of grammar and problem and bug fixes related to precalculated smoothed features

File size: 2.1 KB
RevLine 
[13865]1using System;
2using System.Collections.Generic;
3using System.Drawing;
4using System.Linq;
5using System.Text;
6using System.Threading.Tasks;
7using HeuristicLab.Common;
8using HeuristicLab.Core;
9using HeuristicLab.Data;
10using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
11using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
12using HeuristicLab.Problems.DataAnalysis;
[14310]13using Microsoft.Win32.SafeHandles;
[13865]14
15namespace HeuristicLab.Problems.GeneticProgramming.GlucosePrediction {
16  [StorableClass]
17  [Item("Model", "")]
18  public sealed class Model : NamedItem, IRegressionModel {
[14310]19    [Storable]
[13865]20    private readonly ISymbolicExpressionTree tree;
[14310]21    [Storable]
22    private string targetVariable;
23    [Storable]
24    private string[] variablesUsedForPrediction;
[13865]25
[14311]26    [StorableConstructor]
27    private Model(bool deserializing) : base(deserializing) {
28    }
29
[13865]30    private Model(Model original, Cloner cloner) {
31      this.tree = cloner.Clone(original.tree);
[14310]32      this.variablesUsedForPrediction = original.variablesUsedForPrediction;
33      this.targetVariable = original.targetVariable;
[13865]34    }
35
[14311]36    public Model(ISymbolicExpressionTree tree, string targetVariable, string[] variablesUsedForPrediction) {
[13865]37      this.tree = tree;
[14310]38      this.variablesUsedForPrediction = variablesUsedForPrediction;
39      this.targetVariable = targetVariable;
[13865]40    }
41
42    public override IDeepCloneable Clone(Cloner cloner) {
43      return new Model(this, cloner);
44    }
45
46    public IEnumerable<double> GetEstimatedValues(IDataset dataset, IEnumerable<int> rows) {
[14311]47      return Interpreter.Apply(tree.Root.GetSubtree(0).GetSubtree(0), dataset, rows);
[13865]48    }
49
50    public IRegressionSolution CreateRegressionSolution(IRegressionProblemData problemData) {
51      return new Solution(this, problemData);
52    }
[14310]53
54
55    public string TargetVariable {
56      get {
57        return targetVariable;
58      }
59      set {
60        throw new NotSupportedException();
61      }
62    }
63
64    public event EventHandler TargetVariableChanged;
65
66
67    public IEnumerable<string> VariablesUsedForPrediction {
68      get { return variablesUsedForPrediction; }
69    }
[13865]70  }
71}
Note: See TracBrowser for help on using the repository browser.