Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 17010 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
Line 
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;
13using Microsoft.Win32.SafeHandles;
14
15namespace HeuristicLab.Problems.GeneticProgramming.GlucosePrediction {
16  [StorableClass]
17  [Item("Model", "")]
18  public sealed class Model : NamedItem, IRegressionModel {
19    [Storable]
20    private readonly ISymbolicExpressionTree tree;
21    [Storable]
22    private string targetVariable;
23    [Storable]
24    private string[] variablesUsedForPrediction;
25
26    [StorableConstructor]
27    private Model(bool deserializing) : base(deserializing) {
28    }
29
30    private Model(Model original, Cloner cloner) {
31      this.tree = cloner.Clone(original.tree);
32      this.variablesUsedForPrediction = original.variablesUsedForPrediction;
33      this.targetVariable = original.targetVariable;
34    }
35
36    public Model(ISymbolicExpressionTree tree, string targetVariable, string[] variablesUsedForPrediction) {
37      this.tree = tree;
38      this.variablesUsedForPrediction = variablesUsedForPrediction;
39      this.targetVariable = targetVariable;
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) {
47      return Interpreter.Apply(tree.Root.GetSubtree(0).GetSubtree(0), dataset, rows);
48    }
49
50    public IRegressionSolution CreateRegressionSolution(IRegressionProblemData problemData) {
51      return new Solution(this, problemData);
52    }
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    }
70  }
71}
Note: See TracBrowser for help on using the repository browser.