Last change
on this file since 2705 was
2428,
checked in by gkronber, 15 years ago
|
Implemented #782 (Additional model quality metrics: Pearson product-moment correlation coefficient and Spearman's rank correlation coefficient)
|
File size:
932 bytes
|
Rev | Line | |
---|
[2428] | 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 SimpleSpearmansRankCorrelationCoefficientEvaluator : SimpleEvaluatorBase {
|
---|
| 11 |
|
---|
| 12 | public override string OutputVariableName {
|
---|
| 13 | get {
|
---|
| 14 | return "SpearmansRankCorrelationCoefficient";
|
---|
| 15 | }
|
---|
| 16 | }
|
---|
| 17 |
|
---|
| 18 | public override double Evaluate(double[,] values) {
|
---|
| 19 | try {
|
---|
| 20 | return Calculate(values);
|
---|
| 21 | }
|
---|
| 22 | catch (ArgumentException) {
|
---|
| 23 | return double.NegativeInfinity;
|
---|
| 24 | }
|
---|
| 25 | }
|
---|
| 26 |
|
---|
| 27 | public static double Calculate(double[,] values) {
|
---|
| 28 | return alglib.correlation.spearmanrankcorrelation(
|
---|
| 29 | Matrix<double>.GetColumn(values, ESTIMATION_INDEX),
|
---|
| 30 | Matrix<double>.GetColumn(values, ORIGINAL_INDEX),
|
---|
| 31 | values.GetLength(0));
|
---|
| 32 | }
|
---|
| 33 | }
|
---|
| 34 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.