Line | |
---|
1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 | using System.Text;
|
---|
5 | using HeuristicLab.Core;
|
---|
6 | using HeuristicLab.Data;
|
---|
7 | using HeuristicLab.DataAnalysis;
|
---|
8 |
|
---|
9 | namespace HeuristicLab.Modeling {
|
---|
10 | public class SimpleWeightedDirectionalSymmetryEvaluator : SimpleEvaluatorBase {
|
---|
11 |
|
---|
12 | public override string OutputVariableName {
|
---|
13 | get {
|
---|
14 | return "WeightedDirectionalSymmetry";
|
---|
15 | }
|
---|
16 | }
|
---|
17 |
|
---|
18 | public override double Evaluate(double[,] values) {
|
---|
19 | return Calculate(values);
|
---|
20 | }
|
---|
21 |
|
---|
22 | public static double Calculate(double[,] values) {
|
---|
23 | double correctSum = 0.0;
|
---|
24 | double incorrectSum = 0.0;
|
---|
25 | for (int i = 1; i < values.GetLength(0); i++) {
|
---|
26 | double prevOriginal = values[i - 1, ORIGINAL_INDEX];
|
---|
27 | double original = values[i, ORIGINAL_INDEX];
|
---|
28 | double prevEstimated = values[i - 1, ESTIMATION_INDEX];
|
---|
29 | double estimated = values[i, ESTIMATION_INDEX];
|
---|
30 | if (!(double.IsNaN(original) || double.IsInfinity(original) || double.IsNaN(prevOriginal) || double.IsInfinity(prevOriginal))) {
|
---|
31 | if (!(double.IsNaN(estimated) || double.IsInfinity(estimated) || double.IsNaN(prevEstimated) || double.IsInfinity(prevEstimated))) {
|
---|
32 | double error = Math.Abs(estimated - original);
|
---|
33 | if ((original - prevOriginal) * (estimated - prevEstimated) >= 0) correctSum += error;
|
---|
34 | else incorrectSum += error;
|
---|
35 | }
|
---|
36 | }
|
---|
37 | }
|
---|
38 | return incorrectSum / correctSum;
|
---|
39 | }
|
---|
40 | }
|
---|
41 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.