Changeset 11025 for trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/SymbolicClassificationPruningOperator.cs
- Timestamp:
- 06/18/14 15:27:38 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/SymbolicClassificationPruningOperator.cs
r10469 r11025 1 using System.Linq; 1 #region License Information 2 3 /* HeuristicLab 4 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 5 * 6 * This file is part of HeuristicLab. 7 * 8 * HeuristicLab is free software: you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License as published by 10 * the Free Software Foundation, either version 3 of the License, or 11 * (at your option) any later version. 12 * 13 * HeuristicLab is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>. 20 */ 21 22 #endregion 23 24 using System.Linq; 2 25 using HeuristicLab.Common; 3 26 using HeuristicLab.Core; 4 using HeuristicLab.Data;5 27 using HeuristicLab.Parameters; 6 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; … … 12 34 private const string ImpactValuesCalculatorParameterName = "ImpactValuesCalculator"; 13 35 private const string ModelCreatorParameterName = "ModelCreator"; 14 private const string ApplyLinearScalingParmameterName = "ApplyLinearScaling";15 36 16 37 #region parameter properties … … 18 39 get { return (ILookupParameter<ISymbolicClassificationModelCreator>)Parameters[ModelCreatorParameterName]; } 19 40 } 20 21 public ILookupParameter<BoolValue> ApplyLinearScalingParameter {22 get { return (ILookupParameter<BoolValue>)Parameters[ApplyLinearScalingParmameterName]; }23 }24 #endregion25 #region properties26 private ISymbolicClassificationModelCreator ModelCreator { get { return ModelCreatorParameter.ActualValue; } }27 private BoolValue ApplyLinearScaling { get { return ApplyLinearScalingParameter.ActualValue; } }28 41 #endregion 29 42 … … 31 44 : base(original, cloner) { 32 45 } 46 33 47 public override IDeepCloneable Clone(Cloner cloner) { 34 48 return new SymbolicClassificationPruningOperator(this, cloner); … … 44 58 45 59 protected override ISymbolicDataAnalysisModel CreateModel() { 46 var model = ModelCreator.CreateSymbolicClassificationModel(SymbolicExpressionTree, Interpreter, EstimationLimits.Lower, EstimationLimits.Upper); 47 var rows = Enumerable.Range(FitnessCalculationPartition.Start, FitnessCalculationPartition.Size); 60 var model = ModelCreatorParameter.ActualValue.CreateSymbolicClassificationModel(SymbolicExpressionTree, Interpreter, EstimationLimits.Lower, EstimationLimits.Upper); 48 61 var problemData = (IClassificationProblemData)ProblemData; 62 var rows = problemData.TrainingIndices; 49 63 model.RecalculateModelParameters(problemData, rows); 50 64 return model; … … 54 68 var classificationModel = (IClassificationModel)model; 55 69 var classificationProblemData = (IClassificationProblemData)ProblemData; 56 var trainingIndices = ProblemData.TrainingIndices.ToList();70 var trainingIndices = Enumerable.Range(FitnessCalculationPartition.Start, FitnessCalculationPartition.Size).ToArray(); 57 71 var estimatedValues = classificationModel.GetEstimatedClassValues(ProblemData.Dataset, trainingIndices); 58 72 var targetValues = ProblemData.Dataset.GetDoubleValues(classificationProblemData.TargetVariable, trainingIndices); 59 73 OnlineCalculatorError errorState; 60 var quality = Online PearsonsRSquaredCalculator.Calculate(targetValues, estimatedValues, out errorState);74 var quality = OnlineAccuracyCalculator.Calculate(targetValues, estimatedValues, out errorState); 61 75 if (errorState != OnlineCalculatorError.None) return double.NaN; 62 76 return quality;
Note: See TracChangeset
for help on using the changeset viewer.