Changeset 5273
- Timestamp:
- 01/11/11 13:59:55 (14 years ago)
- Location:
- trunk/sources/HeuristicLab.Problems.DataAnalysis.Classification/3.3/Symbolic
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis.Classification/3.3/Symbolic/Analyzer/TrainingBestSymbolicClassificationSolutionAnalyzer.cs
r5271 r5273 34 34 using HeuristicLab.Problems.DataAnalysis.Evaluators; 35 35 using HeuristicLab.Problems.DataAnalysis.Classification; 36 37 namespace HeuristicLab.Problems.DataAnalysis.Regression.Symbolic.Analyzers { 36 using HeuristicLab.Problems.DataAnalysis.Regression.Symbolic; 37 using HeuristicLab.Problems.DataAnalysis.Regression.Symbolic.Analyzers; 38 39 namespace HeuristicLab.Problems.DataAnalysis.Classification.Symbolic.Analyzers { 38 40 /// <summary> 39 /// An operator that analyzes the training best scaled symbolic regression solution.41 /// An operator that analyzes the training best scaled symbolic classification solution. 40 42 /// </summary> 41 [Item("TrainingBestS caledSymbolicRegressionSolutionAnalyzer", "An operator that analyzes the training best scaled symbolic regression solution.")]43 [Item("TrainingBestSymbolicClassificationSolutionAnalyzer", "An operator that analyzes the training best scaled symbolic classification solution.")] 42 44 [StorableClass] 43 public sealed class TrainingBestSymbolicClassificationSolutionAnalyzer : SingleSuccessorOperator, ISymbolic RegressionAnalyzer {45 public sealed class TrainingBestSymbolicClassificationSolutionAnalyzer : SingleSuccessorOperator, ISymbolicClassificationAnalyzer { 44 46 private const string SymbolicExpressionTreeParameterName = "SymbolicExpressionTree"; 45 47 private const string QualityParameterName = "Quality"; … … 56 58 private const string BestSolutionHeightParameterName = "Best training solution height"; 57 59 private const string BestSolutionVariablesParameterName = "Best training solution variables"; 60 private const string BestSolutionTrainingRSquaredParameterName = "Best training solution R² (training)"; 61 private const string BestSolutionTestRSquaredParameterName = "Best training solution R² (test)"; 62 private const string BestSolutionTrainingMseParameterName = "Best training solution mean squared error (training)"; 63 private const string BestSolutionTestMseParameterName = "Best training solution mean squared error (test)"; 64 private const string BestSolutionTrainingRelativeErrorParameterName = "Best training solution relative error (training)"; 65 private const string BestSolutionTestRelativeErrorParameterName = "Best training solution relative error (test)"; 58 66 private const string BestSolutionAccuracyTrainingParameterName = "Best training solution accuracy (training)"; 59 67 private const string BestSolutionAccuracyTestParameterName = "Best training solution accuracy (test)"; … … 103 111 public ILookupParameter<IntValue> BestSolutionVariablesParameter { 104 112 get { return (ILookupParameter<IntValue>)Parameters[BestSolutionVariablesParameterName]; } 113 } 114 public ILookupParameter<DoubleValue> BestSolutionTrainingRSquaredParameter { 115 get { return (ILookupParameter<DoubleValue>)Parameters[BestSolutionTrainingRSquaredParameterName]; } 116 } 117 public ILookupParameter<DoubleValue> BestSolutionTestRSquaredParameter { 118 get { return (ILookupParameter<DoubleValue>)Parameters[BestSolutionTestRSquaredParameterName]; } 119 } 120 public ILookupParameter<DoubleValue> BestSolutionTrainingMseParameter { 121 get { return (ILookupParameter<DoubleValue>)Parameters[BestSolutionTrainingMseParameterName]; } 122 } 123 public ILookupParameter<DoubleValue> BestSolutionTestMseParameter { 124 get { return (ILookupParameter<DoubleValue>)Parameters[BestSolutionTestMseParameterName]; } 125 } 126 public ILookupParameter<DoubleValue> BestSolutionTrainingRelativeErrorParameter { 127 get { return (ILookupParameter<DoubleValue>)Parameters[BestSolutionTrainingRelativeErrorParameterName]; } 128 } 129 public ILookupParameter<DoubleValue> BestSolutionTestRelativeErrorParameter { 130 get { return (ILookupParameter<DoubleValue>)Parameters[BestSolutionTestRelativeErrorParameterName]; } 105 131 } 106 132 public ILookupParameter<DoubleValue> BestSolutionTrainingAccuracyParameter { … … 166 192 get { return BestSolutionVariablesParameter.ActualValue; } 167 193 set { BestSolutionVariablesParameter.ActualValue = value; } 194 } 195 public DoubleValue BestSolutionTrainingRSquared { 196 get { return BestSolutionTrainingRSquaredParameter.ActualValue; } 197 set { BestSolutionTrainingRSquaredParameter.ActualValue = value; } 198 } 199 public DoubleValue BestSolutionTestRSquared { 200 get { return BestSolutionTestRSquaredParameter.ActualValue; } 201 set { BestSolutionTestRSquaredParameter.ActualValue = value; } 202 } 203 public DoubleValue BestSolutionTrainingMse { 204 get { return BestSolutionTrainingMseParameter.ActualValue; } 205 set { BestSolutionTrainingMseParameter.ActualValue = value; } 206 } 207 public DoubleValue BestSolutionTestMse { 208 get { return BestSolutionTestMseParameter.ActualValue; } 209 set { BestSolutionTestMseParameter.ActualValue = value; } 210 } 211 public DoubleValue BestSolutionTrainingRelativeError { 212 get { return BestSolutionTrainingRelativeErrorParameter.ActualValue; } 213 set { BestSolutionTrainingRelativeErrorParameter.ActualValue = value; } 214 } 215 public DoubleValue BestSolutionTestRelativeError { 216 get { return BestSolutionTestRelativeErrorParameter.ActualValue; } 217 set { BestSolutionTestRelativeErrorParameter.ActualValue = value; } 168 218 } 169 219 public DoubleValue BestSolutionTrainingAccuracy { … … 196 246 Parameters.Add(new LookupParameter<IntValue>(BestSolutionHeightParameterName, "The height of the best symbolic classfication solution.")); 197 247 Parameters.Add(new LookupParameter<IntValue>(BestSolutionVariablesParameterName, "The number of variables used by the best symbolic classification solution.")); 248 Parameters.Add(new LookupParameter<DoubleValue>(BestSolutionTrainingRSquaredParameterName, "The R² value on the training set of the best symbolic classification solution.")); 249 Parameters.Add(new LookupParameter<DoubleValue>(BestSolutionTestRSquaredParameterName, "The R² value on the test set of the best symbolic classification solution.")); 250 Parameters.Add(new LookupParameter<DoubleValue>(BestSolutionTrainingMseParameterName, "The mean squared error on the training set of the best symbolic classification solution.")); 251 Parameters.Add(new LookupParameter<DoubleValue>(BestSolutionTestMseParameterName, "The mean squared error value on the test set of the best symbolic classification solution.")); 252 Parameters.Add(new LookupParameter<DoubleValue>(BestSolutionTrainingRelativeErrorParameterName, "The relative error on the training set of the best symbolic classification solution.")); 253 Parameters.Add(new LookupParameter<DoubleValue>(BestSolutionTestRelativeErrorParameterName, "The relative error value on the test set of the best symbolic classification solution.")); 198 254 Parameters.Add(new LookupParameter<DoubleValue>(BestSolutionAccuracyTrainingParameterName, "The accuracy on the training set of the best symbolic classification solution.")); 199 255 Parameters.Add(new LookupParameter<DoubleValue>(BestSolutionAccuracyTestParameterName, "The accuracy on the test set of the best symbolic classification solution.")); 200 Parameters.Add(new LookupParameter<ResultCollection>(ResultsParameterName, "The result collection where the best symbolic regression solution should be stored."));256 Parameters.Add(new LookupParameter<ResultCollection>(ResultsParameterName, "The result collection where the best symbolic classification solution should be stored.")); 201 257 } 202 258 … … 272 328 IEnumerable<double> testValues = ProblemData.Dataset.GetEnumeratedVariableValues(ProblemData.TargetVariable.Value, ProblemData.TestIndizes); 273 329 OnlineAccuracyEvaluator accuracyEvaluator = new OnlineAccuracyEvaluator(); 330 OnlineMeanSquaredErrorEvaluator mseEvaluator = new OnlineMeanSquaredErrorEvaluator(); 331 OnlineMeanAbsolutePercentageErrorEvaluator relErrorEvaluator = new OnlineMeanAbsolutePercentageErrorEvaluator(); 332 OnlinePearsonsRSquaredEvaluator r2Evaluator = new OnlinePearsonsRSquaredEvaluator(); 274 333 275 334 #region training 276 335 var originalEnumerator = trainingValues.GetEnumerator(); 277 var estimatedEnumerator = solution.EstimatedTraining Values.GetEnumerator();336 var estimatedEnumerator = solution.EstimatedTrainingClassValues.GetEnumerator(); 278 337 while (originalEnumerator.MoveNext() & estimatedEnumerator.MoveNext()) { 279 338 accuracyEvaluator.Add(originalEnumerator.Current, estimatedEnumerator.Current); 339 mseEvaluator.Add(originalEnumerator.Current, estimatedEnumerator.Current); 340 r2Evaluator.Add(originalEnumerator.Current, estimatedEnumerator.Current); 341 relErrorEvaluator.Add(originalEnumerator.Current, estimatedEnumerator.Current); 280 342 } 281 343 double trainingAccuracy = accuracyEvaluator.Accuracy; 344 double trainingR2 = r2Evaluator.RSquared; 345 double trainingMse = mseEvaluator.MeanSquaredError; 346 double trainingRelError = relErrorEvaluator.MeanAbsolutePercentageError; 282 347 #endregion 283 348 284 349 accuracyEvaluator.Reset(); 350 mseEvaluator.Reset(); 351 relErrorEvaluator.Reset(); 352 r2Evaluator.Reset(); 285 353 286 354 #region test 287 355 originalEnumerator = testValues.GetEnumerator(); 288 estimatedEnumerator = solution.EstimatedTest Values.GetEnumerator();356 estimatedEnumerator = solution.EstimatedTestClassValues.GetEnumerator(); 289 357 while (originalEnumerator.MoveNext() & estimatedEnumerator.MoveNext()) { 290 358 accuracyEvaluator.Add(originalEnumerator.Current, estimatedEnumerator.Current); 359 mseEvaluator.Add(originalEnumerator.Current, estimatedEnumerator.Current); 360 r2Evaluator.Add(originalEnumerator.Current, estimatedEnumerator.Current); 361 relErrorEvaluator.Add(originalEnumerator.Current, estimatedEnumerator.Current); 291 362 } 292 363 double testAccuracy = accuracyEvaluator.Accuracy; 364 double testR2 = r2Evaluator.RSquared; 365 double testMse = mseEvaluator.MeanSquaredError; 366 double testRelError = relErrorEvaluator.MeanAbsolutePercentageError; 293 367 #endregion 294 368 BestSolutionTrainingAccuracy = new DoubleValue(trainingAccuracy); 295 369 BestSolutionTestAccuracy = new DoubleValue(testAccuracy); 370 BestSolutionTrainingRSquared = new DoubleValue(trainingR2); 371 BestSolutionTestRSquared = new DoubleValue(testR2); 372 BestSolutionTrainingMse = new DoubleValue(trainingMse); 373 BestSolutionTestMse = new DoubleValue(testMse); 374 BestSolutionTrainingRelativeError = new DoubleValue(trainingRelError); 375 BestSolutionTestRelativeError = new DoubleValue(testRelError); 296 376 297 377 if (!Results.ContainsKey(BestSolutionAccuracyTrainingParameterName)) { 378 Results.Add(new Result(BestSolutionTrainingRSquaredParameterName, BestSolutionTrainingRSquared)); 379 Results.Add(new Result(BestSolutionTestRSquaredParameterName, BestSolutionTestRSquared)); 380 Results.Add(new Result(BestSolutionTrainingMseParameterName, BestSolutionTrainingMse)); 381 Results.Add(new Result(BestSolutionTestMseParameterName, BestSolutionTestMse)); 382 Results.Add(new Result(BestSolutionTrainingRelativeErrorParameterName, BestSolutionTrainingRelativeError)); 383 Results.Add(new Result(BestSolutionTestRelativeErrorParameterName, BestSolutionTestRelativeError)); 298 384 Results.Add(new Result(BestSolutionAccuracyTrainingParameterName, BestSolutionTrainingAccuracy)); 299 385 Results.Add(new Result(BestSolutionAccuracyTestParameterName, BestSolutionTestAccuracy)); 300 386 } else { 387 Results[BestSolutionTrainingRSquaredParameterName].Value = BestSolutionTrainingRSquared; 388 Results[BestSolutionTestRSquaredParameterName].Value = BestSolutionTestRSquared; 389 Results[BestSolutionTrainingMseParameterName].Value = BestSolutionTrainingMse; 390 Results[BestSolutionTestMseParameterName].Value = BestSolutionTestMse; 391 Results[BestSolutionTrainingRelativeErrorParameterName].Value = BestSolutionTrainingRelativeError; 392 Results[BestSolutionTestRelativeErrorParameterName].Value = BestSolutionTestRelativeError; 301 393 Results[BestSolutionAccuracyTrainingParameterName].Value = BestSolutionTrainingAccuracy; 302 394 Results[BestSolutionAccuracyTestParameterName].Value = BestSolutionTestAccuracy; -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Classification/3.3/Symbolic/SymbolicClassificationProblem.cs
r5271 r5273 37 37 using HeuristicLab.Problems.DataAnalysis.Symbolic; 38 38 using HeuristicLab.Problems.DataAnalysis.Symbolic.Symbols; 39 using HeuristicLab.Problems.DataAnalysis.Classification.Symbolic.Analyzers; 39 40 40 41 namespace HeuristicLab.Problems.DataAnalysis.Classification {
Note: See TracChangeset
for help on using the changeset viewer.