mahout-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jeast...@apache.org
Subject svn commit: r1002744 - in /mahout/trunk/core/src: main/java/org/apache/mahout/clustering/OnlineGaussianAccumulator.java test/java/org/apache/mahout/clustering/TestGaussianAccumulators.java
Date Wed, 29 Sep 2010 17:11:59 GMT
Author: jeastman
Date: Wed Sep 29 17:11:59 2010
New Revision: 1002744

URL: http://svn.apache.org/viewvc?rev=1002744&view=rev
Log:
MAHOUT-513
- fixed bug in OnlineGaussianAccumulator.getStd()
- added test of variance
all tests now run, though std/variance results are different than with RunningSums

Modified:
    mahout/trunk/core/src/main/java/org/apache/mahout/clustering/OnlineGaussianAccumulator.java
    mahout/trunk/core/src/test/java/org/apache/mahout/clustering/TestGaussianAccumulators.java

Modified: mahout/trunk/core/src/main/java/org/apache/mahout/clustering/OnlineGaussianAccumulator.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/OnlineGaussianAccumulator.java?rev=1002744&r1=1002743&r2=1002744&view=diff
==============================================================================
--- mahout/trunk/core/src/main/java/org/apache/mahout/clustering/OnlineGaussianAccumulator.java
(original)
+++ mahout/trunk/core/src/main/java/org/apache/mahout/clustering/OnlineGaussianAccumulator.java
Wed Sep 29 17:11:59 2010
@@ -45,7 +45,7 @@ public class OnlineGaussianAccumulator i
 
   @Override
   public Vector getStd() {
-    return variance.assign(new SquareRootFunction());
+    return variance.clone().assign(new SquareRootFunction());
   }
 
   @Override
@@ -60,7 +60,6 @@ public class OnlineGaussianAccumulator i
       delta = weightedX.clone();
     }
     mean = mean.plus(delta.divide(n));
-
     if (M2 != null) {
       M2 = M2.plus(delta.times(weightedX.minus(mean)));
     } else {

Modified: mahout/trunk/core/src/test/java/org/apache/mahout/clustering/TestGaussianAccumulators.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/test/java/org/apache/mahout/clustering/TestGaussianAccumulators.java?rev=1002744&r1=1002743&r2=1002744&view=diff
==============================================================================
--- mahout/trunk/core/src/test/java/org/apache/mahout/clustering/TestGaussianAccumulators.java
(original)
+++ mahout/trunk/core/src/test/java/org/apache/mahout/clustering/TestGaussianAccumulators.java
Wed Sep 29 17:11:59 2010
@@ -37,6 +37,7 @@ public class TestGaussianAccumulators ex
   @Before
   public void setUp() throws Exception {
     super.setUp();
+    sampleData = new ArrayList<VectorWritable>();
     generateSamples();
   }
 
@@ -111,6 +112,6 @@ public class TestGaussianAccumulators ex
     assertEquals("N", accumulator0.getN(), accumulator1.getN(), EPSILON);
     assertEquals("Means", accumulator0.getMean().zSum(), accumulator1.getMean().zSum(), EPSILON);
     assertEquals("Stds", accumulator0.getStd().zSum(), accumulator1.getStd().zSum(), 0.01);
-    //assertEquals("Variance", accumulator0.getVariance().zSum(), accumulator1.getVariance().zSum(),
1.6);
+    assertEquals("Variance", accumulator0.getVariance().zSum(), accumulator1.getVariance().zSum(),
0.1);
   }
 }



Mime
View raw message