You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mahout.apache.org by ra...@apache.org on 2017/02/24 13:33:57 UTC

mahout git commit: MAHOUT-1931 Add Test for MeanCenter closes apache/mahout#281

Repository: mahout
Updated Branches:
  refs/heads/master a70a8733c -> 52aceaf68


MAHOUT-1931 Add Test for MeanCenter closes apache/mahout#281


Project: http://git-wip-us.apache.org/repos/asf/mahout/repo
Commit: http://git-wip-us.apache.org/repos/asf/mahout/commit/52aceaf6
Tree: http://git-wip-us.apache.org/repos/asf/mahout/tree/52aceaf6
Diff: http://git-wip-us.apache.org/repos/asf/mahout/diff/52aceaf6

Branch: refs/heads/master
Commit: 52aceaf68cc198f6d5c3fb77ac16e21abce6e6dc
Parents: a70a873
Author: rawkintrevo <tr...@gmail.com>
Authored: Fri Feb 24 07:33:36 2017 -0600
Committer: rawkintrevo <tr...@gmail.com>
Committed: Fri Feb 24 07:33:36 2017 -0600

----------------------------------------------------------------------
 .../math/algorithms/PreprocessorSuiteBase.scala | 28 ++++++++++++++++++++
 1 file changed, 28 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mahout/blob/52aceaf6/math-scala/src/test/scala/org/apache/mahout/math/algorithms/PreprocessorSuiteBase.scala
----------------------------------------------------------------------
diff --git a/math-scala/src/test/scala/org/apache/mahout/math/algorithms/PreprocessorSuiteBase.scala b/math-scala/src/test/scala/org/apache/mahout/math/algorithms/PreprocessorSuiteBase.scala
index ec76c11..ffe1d1b 100644
--- a/math-scala/src/test/scala/org/apache/mahout/math/algorithms/PreprocessorSuiteBase.scala
+++ b/math-scala/src/test/scala/org/apache/mahout/math/algorithms/PreprocessorSuiteBase.scala
@@ -87,4 +87,32 @@ trait PreprocessorSuiteBase extends DistributedMahoutSuite with Matchers {
     (myAnswer.norm - correctAnswer.norm) should be <= epsilon
 
   }
+
+  test("mean center test") {
+    /**
+      * R Prototype
+      *
+      * x <- matrix( c(1.0,2.0,3.0,1.0,5.0,9.0,-2.0,2.0,0), nrow=3)
+      * centered.x <- scale(x, scale= FALSE)
+      * print(centered.x)
+      */
+
+
+    val A = drmParallelize(dense(
+      (1, 1, -2),
+      (2, 5, 2),
+      (3, 9, 0)), numPartitions = 2)
+
+    val scaler: MeanCenterModel = new MeanCenter().fit(A)
+
+    val myAnswer = scaler.transform(A).collect
+
+    val correctAnswer = dense(
+      (-1, -4, -2),
+      (0,  0,  2),
+      (1,  4,  0))
+
+    val epsilon = 1E-6
+    (myAnswer.norm - correctAnswer.norm) should be <= epsilon
+  }
 }