Changeset 17687 for branches/1837_Sliding Window GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SymbolicRegressionModel.cs
- Timestamp:
- 07/19/20 19:07:40 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1837_Sliding Window GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SymbolicRegressionModel.cs
r9587 r17687 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-2013Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 20 20 #endregion 21 21 22 using System; 22 23 using System.Collections.Generic; 23 24 using HeuristicLab.Common; 24 25 using HeuristicLab.Core; 25 26 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 26 using H euristicLab.Persistence.Default.CompositeSerializers.Storable;27 using HEAL.Attic; 27 28 28 29 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression { … … 30 31 /// Represents a symbolic regression model 31 32 /// </summary> 32 [Storable Class]33 [StorableType("2739C33E-4DDB-4285-9DFB-C056D900B2F2")] 33 34 [Item(Name = "Symbolic Regression Model", Description = "Represents a symbolic regression model.")] 34 35 public class SymbolicRegressionModel : SymbolicDataAnalysisModel, ISymbolicRegressionModel { 35 36 [Storable] 37 private string targetVariable; 38 public string TargetVariable { 39 get { return targetVariable; } 40 set { 41 if (string.IsNullOrEmpty(value) || targetVariable == value) return; 42 targetVariable = value; 43 OnTargetVariableChanged(this, EventArgs.Empty); 44 } 45 } 36 46 37 47 [StorableConstructor] 38 protected SymbolicRegressionModel(bool deserializing) : base(deserializing) { } 39 protected SymbolicRegressionModel(SymbolicRegressionModel original, Cloner cloner) : base(original, cloner) { } 48 protected SymbolicRegressionModel(StorableConstructorFlag _) : base(_) { 49 targetVariable = string.Empty; 50 } 40 51 41 public SymbolicRegressionModel(ISymbolicExpressionTree tree, ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, 52 protected SymbolicRegressionModel(SymbolicRegressionModel original, Cloner cloner) 53 : base(original, cloner) { 54 this.targetVariable = original.targetVariable; 55 } 56 57 public SymbolicRegressionModel(string targetVariable, ISymbolicExpressionTree tree, 58 ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, 42 59 double lowerEstimationLimit = double.MinValue, double upperEstimationLimit = double.MaxValue) 43 : base(tree, interpreter, lowerEstimationLimit, upperEstimationLimit) { } 60 : base(tree, interpreter, lowerEstimationLimit, upperEstimationLimit) { 61 this.targetVariable = targetVariable; 62 } 44 63 45 64 public override IDeepCloneable Clone(Cloner cloner) { … … 47 66 } 48 67 49 public IEnumerable<double> GetEstimatedValues( Dataset dataset, IEnumerable<int> rows) {68 public IEnumerable<double> GetEstimatedValues(IDataset dataset, IEnumerable<int> rows) { 50 69 return Interpreter.GetSymbolicExpressionTreeValues(SymbolicExpressionTree, dataset, rows) 51 70 .LimitToRange(LowerEstimationLimit, UpperEstimationLimit); … … 62 81 Scale(problemData, problemData.TargetVariable); 63 82 } 83 84 public virtual bool IsProblemDataCompatible(IRegressionProblemData problemData, out string errorMessage) { 85 return RegressionModel.IsProblemDataCompatible(this, problemData, out errorMessage); 86 } 87 88 public override bool IsProblemDataCompatible(IDataAnalysisProblemData problemData, out string errorMessage) { 89 if (problemData == null) throw new ArgumentNullException("problemData", "The provided problemData is null."); 90 var regressionProblemData = problemData as IRegressionProblemData; 91 if (regressionProblemData == null) 92 throw new ArgumentException("The problem data is not compatible with this symbolic regression model. Instead a " + problemData.GetType().GetPrettyName() + " was provided.", "problemData"); 93 return IsProblemDataCompatible(regressionProblemData, out errorMessage); 94 } 95 96 #region events 97 public event EventHandler TargetVariableChanged; 98 private void OnTargetVariableChanged(object sender, EventArgs args) { 99 var changed = TargetVariableChanged; 100 if (changed != null) 101 changed(sender, args); 102 } 103 #endregion 64 104 } 65 105 }
Note: See TracChangeset
for help on using the changeset viewer.