Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/11/11 15:56:17 (14 years ago)
Author:
gkronber
Message:

#1450: merged r5816 from the branch and implemented first version of ensemble solutions for regression. The ensembles are only produced by cross validation.

Location:
trunk/sources
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources

  • trunk/sources/HeuristicLab.Problems.DataAnalysis

  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Tests/StatisticCalculatorsTest.cs

    r5944 r6184  
    7878          double variance = calculator.Variance;
    7979
    80           Assert.AreEqual(mean_alglib, mean, 1E-6 * scale);
    81           Assert.AreEqual(variance_alglib, variance, 1E-6 * scale);
     80          Assert.AreEqual(mean_alglib.ToString(), mean.ToString());
     81          Assert.AreEqual(variance_alglib.ToString(), variance.ToString());
    8282        }
    8383      }
     
    109109            double r2 = r2Calculator.RSquared;
    110110
    111             Assert.AreEqual(r2_alglib, r2, 1E-6 * Math.Max(c1Scale, c2Scale));
     111            Assert.AreEqual(r2_alglib.ToString(), r2.ToString());
    112112          }
    113113        }
    114114      }
    115115    }
     116    [TestMethod]
     117    public void CalculatePearsonsRSquaredOfConstantTest() {
     118      System.Random random = new System.Random(31415);
     119      int n = 12;
     120      int cols = testData.GetLength(1);
     121      for (int c1 = 0; c1 < cols; c1++) {
     122        double c1Scale = random.NextDouble() * 1E7;
     123        double c2Scale = 1.0;
     124        IEnumerable<double> x = from rows in Enumerable.Range(0, n)
     125                                select testData[rows, c1] * c1Scale;
     126        IEnumerable<double> y = (new List<double>() { 150494407424305.44 })
     127          .Concat(Enumerable.Repeat(150494407424305.47, n - 1));
     128        double[] xs = x.ToArray();
     129        double[] ys = y.ToArray();
     130        double r2_alglib = alglib.pearsoncorrelation(xs, ys, n);
     131        r2_alglib *= r2_alglib;
     132
     133        var r2Calculator = new OnlinePearsonsRSquaredCalculator();
     134        for (int i = 0; i < n; i++) {
     135          r2Calculator.Add(xs[i], ys[i]);
     136        }
     137        double r2 = r2Calculator.RSquared;
     138
     139        Assert.AreEqual(r2_alglib.ToString(), r2.ToString());
     140      }
     141    }
    116142  }
    117143}
Note: See TracChangeset for help on using the changeset viewer.