Changeset 2386 for trunk/sources
- Timestamp:
- 09/24/09 13:09:50 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Modeling/3.2/ModelingResultCalculators.cs
r2383 r2386 27 27 namespace HeuristicLab.Modeling { 28 28 public abstract class ModelingResultCalculators { 29 30 public static readonly Dictionary<ModelingResult, Func<double[,], double>> Mapping; 29 private static readonly Dictionary<ModelingResult, Func<double[,], double>> ClassificationModelingResults; 30 private static readonly Dictionary<ModelingResult, Func<double[,], double>> RegressionModelingResults; 31 private static readonly Dictionary<ModelingResult, Func<double[,], double>> TimeSeriesPrognosisModelingResults; 31 32 32 33 static ModelingResultCalculators() { 33 Mapping= new Dictionary<ModelingResult, Func<double[,], double>>();34 RegressionModelingResults = new Dictionary<ModelingResult, Func<double[,], double>>(); 34 35 35 36 //Mean squared errors 36 Mapping[ModelingResult.TrainingMeanSquaredError] = SimpleMSEEvaluator.Calculate;37 Mapping[ModelingResult.ValidationMeanSquaredError] = SimpleMSEEvaluator.Calculate;38 Mapping[ModelingResult.TestMeanSquaredError] = SimpleMSEEvaluator.Calculate;37 RegressionModelingResults[ModelingResult.TrainingMeanSquaredError] = SimpleMSEEvaluator.Calculate; 38 RegressionModelingResults[ModelingResult.ValidationMeanSquaredError] = SimpleMSEEvaluator.Calculate; 39 RegressionModelingResults[ModelingResult.TestMeanSquaredError] = SimpleMSEEvaluator.Calculate; 39 40 40 41 //Normalized mean squared errors 41 Mapping[ModelingResult.TrainingNormalizedMeanSquaredError] = SimpleNMSEEvaluator.Calculate;42 Mapping[ModelingResult.ValidationNormalizedMeanSquaredError] = SimpleNMSEEvaluator.Calculate;43 Mapping[ModelingResult.TestNormalizedMeanSquaredError] = SimpleNMSEEvaluator.Calculate;42 RegressionModelingResults[ModelingResult.TrainingNormalizedMeanSquaredError] = SimpleNMSEEvaluator.Calculate; 43 RegressionModelingResults[ModelingResult.ValidationNormalizedMeanSquaredError] = SimpleNMSEEvaluator.Calculate; 44 RegressionModelingResults[ModelingResult.TestNormalizedMeanSquaredError] = SimpleNMSEEvaluator.Calculate; 44 45 45 46 //Mean absolute percentage error 46 Mapping[ModelingResult.TrainingMeanAbsolutePercentageError] = SimpleMeanAbsolutePercentageErrorEvaluator.Calculate;47 Mapping[ModelingResult.ValidationMeanAbsolutePercentageError] = SimpleMeanAbsolutePercentageErrorEvaluator.Calculate;48 Mapping[ModelingResult.TestMeanAbsolutePercentageError] = SimpleMeanAbsolutePercentageErrorEvaluator.Calculate;47 RegressionModelingResults[ModelingResult.TrainingMeanAbsolutePercentageError] = SimpleMeanAbsolutePercentageErrorEvaluator.Calculate; 48 RegressionModelingResults[ModelingResult.ValidationMeanAbsolutePercentageError] = SimpleMeanAbsolutePercentageErrorEvaluator.Calculate; 49 RegressionModelingResults[ModelingResult.TestMeanAbsolutePercentageError] = SimpleMeanAbsolutePercentageErrorEvaluator.Calculate; 49 50 50 51 //Mean absolute percentage of range error 51 Mapping[ModelingResult.TrainingMeanAbsolutePercentageOfRangeError] = SimpleMeanAbsolutePercentageOfRangeErrorEvaluator.Calculate;52 Mapping[ModelingResult.ValidationMeanAbsolutePercentageOfRangeError] = SimpleMeanAbsolutePercentageOfRangeErrorEvaluator.Calculate;53 Mapping[ModelingResult.TestMeanAbsolutePercentageOfRangeError] = SimpleMeanAbsolutePercentageOfRangeErrorEvaluator.Calculate;52 RegressionModelingResults[ModelingResult.TrainingMeanAbsolutePercentageOfRangeError] = SimpleMeanAbsolutePercentageOfRangeErrorEvaluator.Calculate; 53 RegressionModelingResults[ModelingResult.ValidationMeanAbsolutePercentageOfRangeError] = SimpleMeanAbsolutePercentageOfRangeErrorEvaluator.Calculate; 54 RegressionModelingResults[ModelingResult.TestMeanAbsolutePercentageOfRangeError] = SimpleMeanAbsolutePercentageOfRangeErrorEvaluator.Calculate; 54 55 55 56 //Coefficient of determination 56 Mapping[ModelingResult.TrainingCoefficientOfDetermination] = SimpleR2Evaluator.Calculate;57 Mapping[ModelingResult.ValidationCoefficientOfDetermination] = SimpleR2Evaluator.Calculate;58 Mapping[ModelingResult.TestCoefficientOfDetermination] = SimpleR2Evaluator.Calculate;57 RegressionModelingResults[ModelingResult.TrainingCoefficientOfDetermination] = SimpleR2Evaluator.Calculate; 58 RegressionModelingResults[ModelingResult.ValidationCoefficientOfDetermination] = SimpleR2Evaluator.Calculate; 59 RegressionModelingResults[ModelingResult.TestCoefficientOfDetermination] = SimpleR2Evaluator.Calculate; 59 60 60 61 //Variance accounted for 61 Mapping[ModelingResult.TrainingVarianceAccountedFor] = SimpleVarianceAccountedForEvaluator.Calculate;62 Mapping[ModelingResult.ValidationVarianceAccountedFor] = SimpleVarianceAccountedForEvaluator.Calculate;63 Mapping[ModelingResult.TestVarianceAccountedFor] = SimpleVarianceAccountedForEvaluator.Calculate;62 RegressionModelingResults[ModelingResult.TrainingVarianceAccountedFor] = SimpleVarianceAccountedForEvaluator.Calculate; 63 RegressionModelingResults[ModelingResult.ValidationVarianceAccountedFor] = SimpleVarianceAccountedForEvaluator.Calculate; 64 RegressionModelingResults[ModelingResult.TestVarianceAccountedFor] = SimpleVarianceAccountedForEvaluator.Calculate; 64 65 65 66 //Accuracy 66 Mapping[ModelingResult.TrainingAccuracy] = SimpleAccuracyEvaluator.Calculate;67 Mapping[ModelingResult.ValidationAccuracy] = SimpleAccuracyEvaluator.Calculate;68 Mapping[ModelingResult.TestAccuracy] = SimpleAccuracyEvaluator.Calculate;67 ClassificationModelingResults[ModelingResult.TrainingAccuracy] = SimpleAccuracyEvaluator.Calculate; 68 ClassificationModelingResults[ModelingResult.ValidationAccuracy] = SimpleAccuracyEvaluator.Calculate; 69 ClassificationModelingResults[ModelingResult.TestAccuracy] = SimpleAccuracyEvaluator.Calculate; 69 70 70 71 //Theil inequality 71 Mapping[ModelingResult.TrainingTheilInequality] = SimpleTheilInequalityCoefficientEvaluator.Calculate;72 Mapping[ModelingResult.ValidationTheilInequality] = SimpleTheilInequalityCoefficientEvaluator.Calculate;73 Mapping[ModelingResult.TestTheilInequality] = SimpleTheilInequalityCoefficientEvaluator.Calculate;72 TimeSeriesPrognosisModelingResults[ModelingResult.TrainingTheilInequality] = SimpleTheilInequalityCoefficientEvaluator.Calculate; 73 TimeSeriesPrognosisModelingResults[ModelingResult.ValidationTheilInequality] = SimpleTheilInequalityCoefficientEvaluator.Calculate; 74 TimeSeriesPrognosisModelingResults[ModelingResult.TestTheilInequality] = SimpleTheilInequalityCoefficientEvaluator.Calculate; 74 75 75 76 //Directional symmetry 76 Mapping[ModelingResult.TrainingDirectionalSymmetry] = SimpleDirectionalSymmetryEvaluator.Calculate;77 Mapping[ModelingResult.ValidationDirectionalSymmetry] = SimpleDirectionalSymmetryEvaluator.Calculate;78 Mapping[ModelingResult.TestDirectionalSymmetry] = SimpleDirectionalSymmetryEvaluator.Calculate;77 TimeSeriesPrognosisModelingResults[ModelingResult.TrainingDirectionalSymmetry] = SimpleDirectionalSymmetryEvaluator.Calculate; 78 TimeSeriesPrognosisModelingResults[ModelingResult.ValidationDirectionalSymmetry] = SimpleDirectionalSymmetryEvaluator.Calculate; 79 TimeSeriesPrognosisModelingResults[ModelingResult.TestDirectionalSymmetry] = SimpleDirectionalSymmetryEvaluator.Calculate; 79 80 80 81 //Weighted directional symmetry 81 Mapping[ModelingResult.TrainingWeightedDirectionalSymmetry] = SimpleWeightedDirectionalSymmetryEvaluator.Calculate; 82 Mapping[ModelingResult.ValidationWeightedDirectionalSymmetry] = SimpleWeightedDirectionalSymmetryEvaluator.Calculate; 83 Mapping[ModelingResult.TestWeightedDirectionalSymmetry] = SimpleWeightedDirectionalSymmetryEvaluator.Calculate; 82 TimeSeriesPrognosisModelingResults[ModelingResult.TrainingWeightedDirectionalSymmetry] = SimpleWeightedDirectionalSymmetryEvaluator.Calculate; 83 TimeSeriesPrognosisModelingResults[ModelingResult.ValidationWeightedDirectionalSymmetry] = SimpleWeightedDirectionalSymmetryEvaluator.Calculate; 84 TimeSeriesPrognosisModelingResults[ModelingResult.TestWeightedDirectionalSymmetry] = SimpleWeightedDirectionalSymmetryEvaluator.Calculate; 85 } 86 87 public static Dictionary<ModelingResult, Func<double[,], double>> GetModelingResult(ModelType modelType) { 88 IEnumerable<KeyValuePair<ModelingResult,Func<double[,],double>>> ret = new Dictionary<ModelingResult,Func<double[,],double>>(); 89 switch (modelType) { 90 case ModelType.Regression: 91 ret = ret.Union( RegressionModelingResults); 92 break; 93 case ModelType.Classification: 94 ret = ret.Union(RegressionModelingResults); 95 ret = ret.Union(ClassificationModelingResults); 96 break; 97 case ModelType.TimeSeriesPrognosis: 98 ret = ret.Union(RegressionModelingResults); 99 ret = ret.Union(TimeSeriesPrognosisModelingResults); 100 break; 101 default: 102 throw new ArgumentException("Modeling result mapping for ModelType " + modelType + " not defined."); 103 } 104 return ret.ToDictionary<KeyValuePair<ModelingResult, Func<double[,], double>>, ModelingResult, Func<double[,], double>>(x => x.Key, x => x.Value); 84 105 } 85 106 }
Note: See TracChangeset
for help on using the changeset viewer.