Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 14122 was 13865, checked in by gkronber, 8 years ago

#2608 first import of project

File size: 1.5 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;
13
14namespace HeuristicLab.Problems.GeneticProgramming.GlucosePrediction {
15  [StorableClass]
16  [Item("Model", "")]
17  public sealed class Model : NamedItem, IRegressionModel {
18    private readonly IRegressionProblemData problemData;
19    private readonly ISymbolicExpressionTree tree;
20
21    private Model(Model original, Cloner cloner) {
22      this.problemData = cloner.Clone(original.problemData);
23      this.tree = cloner.Clone(original.tree);
24    }
25
26    public Model(IRegressionProblemData problemData, ISymbolicExpressionTree tree) {
27      this.problemData = problemData;
28      this.tree = tree;
29    }
30
31    public override IDeepCloneable Clone(Cloner cloner) {
32      return new Model(this, cloner);
33    }
34
35    public IEnumerable<double> GetEstimatedValues(IDataset dataset, IEnumerable<int> rows) {
36      return Interpreter.Apply(tree.Root.GetSubtree(0).GetSubtree(0), problemData.Dataset, rows);
37    }
38
39    public IRegressionSolution CreateRegressionSolution(IRegressionProblemData problemData) {
40      return new Solution(this, problemData);
41    }
42  }
43}
Note: See TracBrowser for help on using the repository browser.