Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/29/10 19:26:56 (14 years ago)
Author:
gkronber
Message:

Refactored cloning in DataAnalysis plugins. #922

Location:
branches/CloningRefactoring/HeuristicLab.Problems.DataAnalysis.Classification/3.3
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/CloningRefactoring/HeuristicLab.Problems.DataAnalysis.Classification/3.3/ClassificationProblemData.cs

    r4618 r4678  
    196196    }
    197197
     198    [StorableConstructor]
     199    protected ClassificationProblemData(bool deserializing) : base(deserializing) { }
     200    protected ClassificationProblemData(ClassificationProblemData original, Cloner cloner)
     201      : base(original, cloner) {
     202      RegisterParameterEvents();
     203      UpdateClassValues();
     204    }
    198205    public ClassificationProblemData()
    199206      : base(new Dataset(defaultInputs, defaultData), defaultInputs, defaultInputs[defaultInputs.Length - 1], 0, 60, 60, 120) {
     
    207214    }
    208215
    209     [StorableConstructor]
    210     protected ClassificationProblemData(bool deserializing) : base(deserializing) { }
     216    public override IDeepCloneable Clone(Cloner cloner) {
     217      return new ClassificationProblemData(this, cloner);
     218    }
     219
    211220    [StorableHook(HookType.AfterDeserialization)]
    212     private void AfterDeserializationHook() {
     221    private void AfterDeserialization() {
    213222      RegisterParameterEvents();
    214223      RegisterParameterValueEvents();
    215     }
    216 
    217     public override IDeepCloneable Clone(Cloner cloner) {
    218       ClassificationProblemData clone = (ClassificationProblemData)base.Clone(cloner);
    219       clone.RegisterParameterEvents();
    220       clone.UpdateClassValues();
    221       return clone;
    222224    }
    223225
  • branches/CloningRefactoring/HeuristicLab.Problems.DataAnalysis.Classification/3.3/SingleObjectiveClassificationProblem.cs

    r4565 r4678  
    4949    [StorableConstructor]
    5050    protected SingleObjectiveClassificationProblem(bool deserializing) : base(deserializing) { }
     51    protected SingleObjectiveClassificationProblem(SingleObjectiveClassificationProblem<T, U> original, Cloner cloner)
     52      : base(original, cloner) {
     53      Initialize();
     54    }
    5155    public SingleObjectiveClassificationProblem()
    5256      : base() {
    5357      Parameters.Add(new ValueParameter<ClassificationProblemData>(ClassificationProblemDataParameterName, "The data set, target variable and input variables of the data analysis problem."));
    5458      ClassificationProblemData = new ClassificationProblemData();
    55       RegisterParameterEvents();
    56       RegisterParameterValueEvents();
     59      Initialize();
    5760    }
    5861
    5962    [StorableHook(HookType.AfterDeserialization)]
    60     private void AfterDeserializationHook() {
     63    private void AfterDeserialization() {
     64      Initialize();
     65    }
     66    private void Initialize() {
    6167      RegisterParameterEvents();
    6268      RegisterParameterValueEvents();
    63     }
    64 
    65     public override IDeepCloneable Clone(Cloner cloner) {
    66       SingleObjectiveClassificationProblem<T, U> clone = (SingleObjectiveClassificationProblem<T, U>)base.Clone(cloner);
    67       clone.RegisterParameterEvents();
    68       clone.RegisterParameterValueEvents();
    69       return clone;
    7069    }
    7170
  • branches/CloningRefactoring/HeuristicLab.Problems.DataAnalysis.Classification/3.3/Symbolic/Analyzer/ValidationBestSymbolicClassificationSolutionAnalyzer.cs

    r4469 r4678  
    2323using System.Linq;
    2424using HeuristicLab.Analysis;
     25using HeuristicLab.Common;
    2526using HeuristicLab.Core;
    2627using HeuristicLab.Data;
     
    180181    #endregion
    181182
     183    [StorableConstructor]
     184    private ValidationBestSymbolicClassificationSolutionAnalyzer(bool deserializing) : base(deserializing) { }
     185    protected ValidationBestSymbolicClassificationSolutionAnalyzer(ValidationBestSymbolicClassificationSolutionAnalyzer original, Cloner cloner)
     186      : base(original, cloner) {
     187    }
    182188    public ValidationBestSymbolicClassificationSolutionAnalyzer()
    183189      : base() {
     
    204210    }
    205211
    206     [StorableConstructor]
    207     private ValidationBestSymbolicClassificationSolutionAnalyzer(bool deserializing) : base(deserializing) { }
     212    public override IDeepCloneable Clone(Cloner cloner) {
     213      return new ValidationBestSymbolicClassificationSolutionAnalyzer(this, cloner);
     214    }
    208215
    209216    public override IOperation Apply() {
     
    304311      }
    305312    }
    306 
    307313  }
    308314}
  • branches/CloningRefactoring/HeuristicLab.Problems.DataAnalysis.Classification/3.3/Symbolic/Evaluators/SymbolicClassificationMeanSquaredErrorEvaluator.cs

    r4391 r4678  
    2020#endregion
    2121
     22using HeuristicLab.Common;
    2223using HeuristicLab.Core;
    2324using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    2728  [Item("SymbolicClassificationMeanSquaredErrorEvaluator", "Calculates the mean squared error of a symbolic classification solution.")]
    2829  [StorableClass]
    29   public class SymbolicClassifacitionMeanSquaredErrorEvaluator : SymbolicRegressionMeanSquaredErrorEvaluator, ISymbolicClassificationEvaluator {
     30  public sealed class SymbolicClassifacitionMeanSquaredErrorEvaluator : SymbolicRegressionMeanSquaredErrorEvaluator, ISymbolicClassificationEvaluator {
    3031    public ClassificationProblemData ClassificationProblemData {
    3132      get { return (ClassificationProblemData)RegressionProblemData; }
    3233    }
    3334
    34     public SymbolicClassifacitionMeanSquaredErrorEvaluator()
    35       : base() {
     35    [StorableConstructor]
     36    private SymbolicClassifacitionMeanSquaredErrorEvaluator(bool deserializing) : base(deserializing) { }
     37    private SymbolicClassifacitionMeanSquaredErrorEvaluator(SymbolicClassifacitionMeanSquaredErrorEvaluator original, Cloner cloner) : base(original, cloner) { }
     38    public SymbolicClassifacitionMeanSquaredErrorEvaluator() : base() { }
     39    public override IDeepCloneable Clone(Cloner cloner) {
     40      return new SymbolicClassifacitionMeanSquaredErrorEvaluator(this, cloner);
    3641    }
    3742  }
  • branches/CloningRefactoring/HeuristicLab.Problems.DataAnalysis.Classification/3.3/Symbolic/Evaluators/SymbolicClassificationPearsonRSquaredEvaluator.cs

    r4392 r4678  
    2020#endregion
    2121
     22using HeuristicLab.Common;
    2223using HeuristicLab.Core;
    2324using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    2728  [Item("SymbolicClassificationPearsonRSquaredEvaluator", "Calculates the pearson R² correlation coefficient of a symbolic classification solution.")]
    2829  [StorableClass]
    29   public class SymbolicClassificationPearsonRSquaredEvaluator : SymbolicRegressionPearsonsRSquaredEvaluator, ISymbolicClassificationEvaluator {
     30  public sealed class SymbolicClassificationPearsonRSquaredEvaluator : SymbolicRegressionPearsonsRSquaredEvaluator, ISymbolicClassificationEvaluator {
    3031    public ClassificationProblemData ClassificationProblemData {
    3132      get { return (ClassificationProblemData)RegressionProblemData; }
    3233    }
    3334
    34     public SymbolicClassificationPearsonRSquaredEvaluator()
    35       : base() {
     35    [StorableConstructor]
     36    private SymbolicClassificationPearsonRSquaredEvaluator(bool deserializing) : base(deserializing) { }
     37    private SymbolicClassificationPearsonRSquaredEvaluator(SymbolicClassificationPearsonRSquaredEvaluator original, Cloner cloner) : base(original, cloner) { }
     38    public SymbolicClassificationPearsonRSquaredEvaluator() : base() { }
     39
     40    public override IDeepCloneable Clone(Cloner cloner) {
     41      return new SymbolicClassificationPearsonRSquaredEvaluator(this, cloner);
    3642    }
    3743  }
  • branches/CloningRefactoring/HeuristicLab.Problems.DataAnalysis.Classification/3.3/Symbolic/SymbolicClassificationProblem.cs

    r4452 r4678  
    4242  [StorableClass]
    4343  [Creatable("Problems")]
    44   public class SymbolicClassificationProblem : SingleObjectiveClassificationProblem<ISymbolicClassificationEvaluator, ISymbolicExpressionTreeCreator>, IStorableContent {
     44  public sealed class SymbolicClassificationProblem : SingleObjectiveClassificationProblem<ISymbolicClassificationEvaluator, ISymbolicExpressionTreeCreator>, IStorableContent {
    4545    private const string SymbolicExpressionTreeInterpreterParameterName = "SymbolicExpressionTreeInterpreter";
    4646    private const string FunctionTreeGrammarParameterName = "FunctionTreeGrammar";
     
    133133
    134134    [StorableConstructor]
    135     protected SymbolicClassificationProblem(bool deserializing) : base(deserializing) { }
     135    private SymbolicClassificationProblem(bool deserializing) : base(deserializing) { }
     136    private SymbolicClassificationProblem(SymbolicClassificationProblem original, Cloner cloner)
     137      : base(original, cloner) {
     138      RegisterParameterEvents();
     139
     140      UpdateEstimationLimits();
     141      ParameterizeEvaluator();
     142      ParameterizeSolutionCreator();
     143      ParameterizeGrammar();
     144      ParameterizeOperators();
     145      ParameterizeAnalyzers();
     146    }
    136147    public SymbolicClassificationProblem()
    137148      : base() {
     
    167178    }
    168179
    169 
    170     [StorableHook(HookType.AfterDeserialization)]
    171     private void AfterDeserialization() {
    172 
     180    public override IDeepCloneable Clone(Cloner cloner) {
     181      return new SymbolicClassificationProblem(this, cloner);
    173182    }
    174183
  • branches/CloningRefactoring/HeuristicLab.Problems.DataAnalysis.Classification/3.3/Symbolic/SymbolicClassificationSolution.cs

    r4469 r4678  
    3535  [StorableClass]
    3636  public class SymbolicClassificationSolution : SymbolicRegressionSolution, IClassificationSolution {
     37    public new ClassificationProblemData ProblemData {
     38      get { return (ClassificationProblemData)base.ProblemData; }
     39      set { base.ProblemData = value; }
     40    }
     41
     42    #region properties
     43    private List<double> optimalThresholds;
     44    private List<double> actualThresholds;
     45    public IEnumerable<double> Thresholds {
     46      get {
     47        if (actualThresholds == null) RecalculateEstimatedValues();
     48        return actualThresholds;
     49      }
     50      set {
     51        if (actualThresholds != null && actualThresholds.SequenceEqual(value))
     52          return;
     53        actualThresholds = new List<double>(value);
     54        OnThresholdsChanged();
     55      }
     56    }
     57
     58    public IEnumerable<double> EstimatedClassValues {
     59      get { return GetEstimatedClassValues(Enumerable.Range(0, ProblemData.Dataset.Rows)); }
     60    }
     61
     62    public IEnumerable<double> EstimatedTrainingClassValues {
     63      get { return GetEstimatedClassValues(ProblemData.TrainingIndizes); }
     64    }
     65
     66    public IEnumerable<double> EstimatedTestClassValues {
     67      get { return GetEstimatedClassValues(ProblemData.TestIndizes); }
     68    }
     69
     70    [StorableConstructor]
     71    protected SymbolicClassificationSolution(bool deserializing) : base(deserializing) { }
     72    protected SymbolicClassificationSolution(SymbolicClassificationSolution original, Cloner cloner) : base(original, cloner) { }
    3773    private SymbolicClassificationSolution() : base() { }
    3874    public SymbolicClassificationSolution(ClassificationProblemData problemData, SymbolicRegressionModel model, double lowerEstimationLimit, double upperEstimationLimit)
     
    4076    }
    4177
    42     public new ClassificationProblemData ProblemData {
    43       get { return (ClassificationProblemData)base.ProblemData; }
    44       set { base.ProblemData = value; }
     78    public override IDeepCloneable Clone(Cloner cloner) {
     79      return new SymbolicClassificationSolution(this, cloner);
    4580    }
    4681
     
    114149    }
    115150
    116     #region properties
    117     private List<double> optimalThresholds;
    118     private List<double> actualThresholds;
    119     public IEnumerable<double> Thresholds {
    120       get {
    121         if (actualThresholds == null) RecalculateEstimatedValues();
    122         return actualThresholds;
    123       }
    124       set {
    125         if (actualThresholds != null && actualThresholds.SequenceEqual(value))
    126           return;
    127         actualThresholds = new List<double>(value);
    128         OnThresholdsChanged();
    129       }
    130     }
    131 
    132     public IEnumerable<double> EstimatedClassValues {
    133       get { return GetEstimatedClassValues(Enumerable.Range(0, ProblemData.Dataset.Rows)); }
    134     }
    135 
    136     public IEnumerable<double> EstimatedTrainingClassValues {
    137       get { return GetEstimatedClassValues(ProblemData.TrainingIndizes); }
    138     }
    139 
    140     public IEnumerable<double> EstimatedTestClassValues {
    141       get { return GetEstimatedClassValues(ProblemData.TestIndizes); }
    142     }
    143 
    144151    public IEnumerable<double> GetEstimatedClassValues(IEnumerable<int> rows) {
    145152      double[] classValues = ProblemData.SortedClassValues.ToArray();
Note: See TracChangeset for help on using the changeset viewer.