Changeset 5322
- Timestamp:
- 01/18/11 14:52:38 (14 years ago)
- Location:
- trunk/sources/HeuristicLab.Problems.DataAnalysis.Classification/3.3/Symbolic/Analyzer
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis.Classification/3.3/Symbolic/Analyzer/TrainingBestSymbolicClassificationSolutionAnalyzer.cs
r5285 r5322 53 53 private const string UpperEstimationLimitParameterName = "UpperEstimationLimit"; 54 54 private const string LowerEstimationLimitParameterName = "LowerEstimationLimit"; 55 private const string ApplyLinearScalingParameterName = "ApplyLinearScaling"; 55 56 private const string BestSolutionParameterName = "Best training solution"; 56 57 private const string BestSolutionQualityParameterName = "Best training solution quality"; … … 96 97 get { return (IValueLookupParameter<DoubleValue>)Parameters[LowerEstimationLimitParameterName]; } 97 98 } 99 public IValueLookupParameter<BoolValue> ApplyLinearScalingParameter { 100 get { return (IValueLookupParameter<BoolValue>)Parameters[ApplyLinearScalingParameterName]; } 101 } 98 102 99 103 public ILookupParameter<SymbolicClassificationSolution> BestSolutionParameter { … … 170 174 get { return LowerEstimationLimitParameter.ActualValue; } 171 175 } 176 public BoolValue ApplyLinearScaling { 177 get { return ApplyLinearScalingParameter.ActualValue; } 178 set { ApplyLinearScalingParameter.ActualValue = value; } 179 } 180 172 181 public ResultCollection Results { 173 182 get { return ResultsParameter.ActualValue; } … … 241 250 Parameters.Add(new ValueLookupParameter<DoubleValue>(UpperEstimationLimitParameterName, "The upper estimation limit that was set for the evaluation of the symbolic expression trees.")); 242 251 Parameters.Add(new ValueLookupParameter<DoubleValue>(LowerEstimationLimitParameterName, "The lower estimation limit that was set for the evaluation of the symbolic expression trees.")); 252 Parameters.Add(new ValueLookupParameter<BoolValue>(ApplyLinearScalingParameterName, "The switch determines if the best solution should be linearly scaled on the whole training set.", new BoolValue(false))); 243 253 Parameters.Add(new LookupParameter<SymbolicClassificationSolution>(BestSolutionParameterName, "The best symbolic classification solution.")); 244 254 Parameters.Add(new LookupParameter<DoubleValue>(BestSolutionQualityParameterName, "The quality of the best symbolic classification solution.")); … … 257 267 } 258 268 269 [StorableHook(HookType.AfterDeserialization)] 270 private void AfterDeserialization() { 271 if (!Parameters.ContainsKey(ApplyLinearScalingParameterName)) { 272 Parameters.Add(new ValueLookupParameter<BoolValue>(ApplyLinearScalingParameterName, "The switch determines if the best solution should be linearly scaled on the whole training set.", new BoolValue(false))); 273 } 274 } 275 259 276 public override IDeepCloneable Clone(Cloner cloner) { 260 277 return new TrainingBestSymbolicClassificationSolutionAnalyzer(this, cloner); … … 287 304 string targetVariable = ProblemData.TargetVariable.Value; 288 305 289 // calculate scaling parameters and only for the best tree using the full training set 290 double alpha, beta; 291 SymbolicRegressionScaledMeanSquaredErrorEvaluator.Calculate(SymbolicExpressionTreeInterpreter, bestTree, 292 lowerEstimationLimit, upperEstimationLimit, 293 ProblemData.Dataset, targetVariable, 294 ProblemData.TrainingIndizes, out beta, out alpha); 295 296 // scale tree for solution 297 var scaledTree = SymbolicRegressionSolutionLinearScaler.Scale(bestTree, alpha, beta); 306 if (ApplyLinearScaling.Value) { 307 // calculate scaling parameters and only for the best tree using the full training set 308 double alpha, beta; 309 SymbolicRegressionScaledMeanSquaredErrorEvaluator.Calculate(SymbolicExpressionTreeInterpreter, bestTree, 310 lowerEstimationLimit, upperEstimationLimit, 311 ProblemData.Dataset, targetVariable, 312 ProblemData.TrainingIndizes, out beta, out alpha); 313 314 // scale tree for solution 315 bestTree = SymbolicRegressionSolutionLinearScaler.Scale(bestTree, alpha, beta); 316 } 298 317 var model = new SymbolicRegressionModel((ISymbolicExpressionTreeInterpreter)SymbolicExpressionTreeInterpreter.Clone(), 299 scaledTree);318 bestTree); 300 319 var solution = new SymbolicClassificationSolution((ClassificationProblemData)ProblemData.Clone(), model, lowerEstimationLimit, upperEstimationLimit); 301 320 solution.Name = BestSolutionParameterName; -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Classification/3.3/Symbolic/Analyzer/ValidationBestSymbolicClassificationSolutionAnalyzer.cs
r5271 r5322 53 53 private const string LowerEstimationLimitParameterName = "LowerEstimationLimit"; 54 54 private const string CalculateSolutionComplexityParameterName = "CalculateSolutionComplexity"; 55 private const string ApplyLinearScalingParameterName = "ApplyLinearScaling"; 55 56 56 57 private const string ResultsParameterName = "Results"; … … 79 80 get { return (IValueLookupParameter<ISymbolicExpressionTreeInterpreter>)Parameters[SymbolicExpressionTreeInterpreterParameterName]; } 80 81 } 81 82 82 public ILookupParameter<ClassificationProblemData> ClassificationProblemDataParameter { 83 83 get { return (ILookupParameter<ClassificationProblemData>)Parameters[ClassificationProblemDataParameterName]; } … … 101 101 get { return (IValueLookupParameter<DoubleValue>)Parameters[LowerEstimationLimitParameterName]; } 102 102 } 103 public IValueLookupParameter<BoolValue> ApplyLinearScalingParameter { 104 get { return (IValueLookupParameter<BoolValue>)Parameters[ApplyLinearScalingParameterName]; } 105 } 103 106 public ILookupParameter<DataTable> VariableFrequenciesParameter { 104 107 get { return (ILookupParameter<DataTable>)Parameters[VariableFrequenciesParameterName]; } … … 107 110 get { return (IValueParameter<BoolValue>)Parameters[CalculateSolutionComplexityParameterName]; } 108 111 } 112 109 113 public ILookupParameter<ResultCollection> ResultsParameter { 110 114 get { return (ILookupParameter<ResultCollection>)Parameters[ResultsParameterName]; } … … 166 170 public DoubleValue LowerEstimationLimit { 167 171 get { return LowerEstimationLimitParameter.ActualValue; } 172 } 173 public BoolValue ApplyLinearScaling { 174 get { return ApplyLinearScalingParameter.ActualValue; } 175 set { ApplyLinearScalingParameter.ActualValue = value; } 168 176 } 169 177 public DataTable VariableFrequencies { … … 216 224 Parameters.Add(new ScopeTreeLookupParameter<SymbolicExpressionTree>(SymbolicExpressionTreeParameterName, "The symbolic expression trees to analyze.")); 217 225 Parameters.Add(new ValueLookupParameter<ISymbolicExpressionTreeInterpreter>(SymbolicExpressionTreeInterpreterParameterName, "The interpreter that should be used for the analysis of symbolic expression trees.")); 218 219 226 Parameters.Add(new LookupParameter<ClassificationProblemData>(ClassificationProblemDataParameterName, "The problem data for which the symbolic expression tree is a solution.")); 220 227 Parameters.Add(new LookupParameter<ISymbolicClassificationEvaluator>(EvaluatorParameterName, "The evaluator which should be used to evaluate the solution on the validation set.")); … … 226 233 Parameters.Add(new LookupParameter<DataTable>(VariableFrequenciesParameterName, "The variable frequencies table to use for the calculation of variable impacts")); 227 234 Parameters.Add(new ValueParameter<BoolValue>(CalculateSolutionComplexityParameterName, "Determines if the length and height of the validation best solution should be calculated.", new BoolValue(true))); 235 Parameters.Add(new ValueLookupParameter<BoolValue>(ApplyLinearScalingParameterName, "The switch determines if the best solution should be linearly scaled on the whole training set.", new BoolValue(false))); 236 228 237 Parameters.Add(new ValueLookupParameter<ResultCollection>(ResultsParameterName, "The results collection where the analysis values should be stored.")); 229 238 Parameters.Add(new LookupParameter<DoubleValue>(BestValidationQualityParameterName, "The validation quality of the best solution in the current run.")); … … 245 254 if (!Parameters.ContainsKey(BestSolutionHeightParameterName)) { 246 255 Parameters.Add(new LookupParameter<IntValue>(BestSolutionHeightParameterName, "The height of the best symbolic classification solution.")); 256 } 257 if (!Parameters.ContainsKey(ApplyLinearScalingParameterName)) { 258 Parameters.Add(new ValueLookupParameter<BoolValue>(ApplyLinearScalingParameterName, "The switch determines if the best solution should be linearly scaled on the whole training set.", new BoolValue(false))); 247 259 } 248 260 } … … 289 301 (!Maximization.Value && bestQuality < BestValidationQuality.Value); 290 302 if (newBest) { 291 double alpha, beta; 292 SymbolicRegressionScaledMeanSquaredErrorEvaluator.Calculate(SymbolicExpressionTreeInterpreter, bestTree, 293 lowerEstimationLimit, upperEstimationLimit, 294 ClassificationProblemData.Dataset, targetVariable, 295 ClassificationProblemData.TrainingIndizes, out beta, out alpha); 296 297 // scale tree for solution 298 var scaledTree = SymbolicRegressionSolutionLinearScaler.Scale(bestTree, alpha, beta); 303 if (ApplyLinearScaling.Value) { 304 double alpha, beta; 305 SymbolicRegressionScaledMeanSquaredErrorEvaluator.Calculate(SymbolicExpressionTreeInterpreter, bestTree, 306 lowerEstimationLimit, upperEstimationLimit, 307 ClassificationProblemData.Dataset, targetVariable, 308 ClassificationProblemData.TrainingIndizes, out beta, out alpha); 309 310 // scale tree for solution 311 bestTree = SymbolicRegressionSolutionLinearScaler.Scale(bestTree, alpha, beta); 312 } 299 313 var model = new SymbolicRegressionModel((ISymbolicExpressionTreeInterpreter)SymbolicExpressionTreeInterpreter.Clone(), 300 scaledTree);314 bestTree); 301 315 302 316 if (BestValidationSolution == null) {
Note: See TracChangeset
for help on using the changeset viewer.