using System; using System.Collections.Generic; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using HeuristicLab.Common; using HeuristicLab.Core; using HeuristicLab.Data; using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; using HeuristicLab.Problems.DataAnalysis; namespace HeuristicLab.Problems.GeneticProgramming.GlucosePrediction { [StorableClass] [Item("Model", "")] public sealed class Model : NamedItem, IRegressionModel { private readonly IRegressionProblemData problemData; private readonly ISymbolicExpressionTree tree; private Model(Model original, Cloner cloner) { this.problemData = cloner.Clone(original.problemData); this.tree = cloner.Clone(original.tree); } public Model(IRegressionProblemData problemData, ISymbolicExpressionTree tree) { this.problemData = problemData; this.tree = tree; } public override IDeepCloneable Clone(Cloner cloner) { return new Model(this, cloner); } public IEnumerable GetEstimatedValues(IDataset dataset, IEnumerable rows) { return Interpreter.Apply(tree.Root.GetSubtree(0).GetSubtree(0), problemData.Dataset, rows); } public IRegressionSolution CreateRegressionSolution(IRegressionProblemData problemData) { return new Solution(this, problemData); } } }