Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Modeling/3.2/SimpleDirectionalSymmetryEvaluator.cs @ 3177

Last change on this file since 3177 was 2379, checked in by gkronber, 15 years ago

Implemented additional model quality metrics. #761

File size: 1.4 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using HeuristicLab.Core;
6using HeuristicLab.Data;
7using HeuristicLab.DataAnalysis;
8
9namespace HeuristicLab.Modeling {
10  public class SimpleDirectionalSymmetryEvaluator : SimpleEvaluatorBase {
11
12    public override string OutputVariableName {
13      get {
14        return "DirectionalSymmetry";
15      }
16    }
17
18    public override double Evaluate(double[,] values) {
19      return Calculate(values);
20    }
21
22    public static double Calculate(double[,] values) {
23      int n = 0;
24      int nCorrect = 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
31        if (!(double.IsNaN(original) || double.IsInfinity(original) || double.IsNaN(prevOriginal) || double.IsInfinity(prevOriginal))) {
32          n++;
33          if (!(double.IsNaN(estimated) || double.IsInfinity(estimated) || double.IsNaN(prevEstimated) || double.IsInfinity(prevEstimated))) {
34            if ((original - prevOriginal) * (estimated - prevEstimated) >= 0) nCorrect++;
35          }
36        }
37      }
38      return (double)nCorrect / (double)n * 100.0;
39    }
40  }
41}
Note: See TracBrowser for help on using the repository browser.