You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@systemml.apache.org by de...@apache.org on 2017/09/06 21:19:07 UTC
systemml git commit: [SYSTEMML-1863] MLContext test for linear
regression
Repository: systemml
Updated Branches:
refs/heads/master d5f20b43b -> a0cf8e3be
[SYSTEMML-1863] MLContext test for linear regression
Closes #647.
Project: http://git-wip-us.apache.org/repos/asf/systemml/repo
Commit: http://git-wip-us.apache.org/repos/asf/systemml/commit/a0cf8e3b
Tree: http://git-wip-us.apache.org/repos/asf/systemml/tree/a0cf8e3b
Diff: http://git-wip-us.apache.org/repos/asf/systemml/diff/a0cf8e3b
Branch: refs/heads/master
Commit: a0cf8e3bee9470f622d57c4d83f64f2a5bf5f72f
Parents: d5f20b4
Author: Janardhan <pu...@nitkkr.ac.in>
Authored: Wed Sep 6 14:17:20 2017 -0700
Committer: Deron Eriksson <de...@apache.org>
Committed: Wed Sep 6 14:17:20 2017 -0700
----------------------------------------------------------------------
.../algorithms/MLContextLinregTest.java | 83 ++++++++++++++++++++
.../mlcontext/algorithms/ZPackageSuite.java | 5 +-
2 files changed, 87 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/systemml/blob/a0cf8e3b/src/test/java/org/apache/sysml/test/integration/mlcontext/algorithms/MLContextLinregTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/sysml/test/integration/mlcontext/algorithms/MLContextLinregTest.java b/src/test/java/org/apache/sysml/test/integration/mlcontext/algorithms/MLContextLinregTest.java
new file mode 100644
index 0000000..d04ab77
--- /dev/null
+++ b/src/test/java/org/apache/sysml/test/integration/mlcontext/algorithms/MLContextLinregTest.java
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.sysml.test.integration.mlcontext.algorithms;
+
+import static org.apache.sysml.api.mlcontext.ScriptFactory.dmlFromFile;
+
+import org.apache.log4j.Logger;
+import org.apache.sysml.api.mlcontext.Script;
+import org.apache.sysml.test.integration.mlcontext.MLContextTestBase;
+import org.junit.Test;
+
+public class MLContextLinregTest extends MLContextTestBase {
+ protected static Logger log = Logger.getLogger(MLContextLinregTest.class);
+
+ protected final static String TEST_SCRIPT_CG = "scripts/algorithms/LinearRegCG.dml";
+ protected final static String TEST_SCRIPT_DS = "scripts/algorithms/LinearRegDS.dml";
+ private final static double sparsity1 = 0.7; // dense
+ private final static double sparsity2 = 0.1; // sparse
+
+ public enum LinregType {
+ CG, DS,
+ }
+
+ @Test
+ public void testLinregCGSparse() {
+ runLinregTestMLC(LinregType.CG, true);
+ }
+
+ @Test
+ public void testLinregCGDense() {
+ runLinregTestMLC(LinregType.CG, false);
+ }
+
+ @Test
+ public void testLinregDSSparse() {
+ runLinregTestMLC(LinregType.DS, true);
+ }
+
+ @Test
+ public void testLinregDSDense() {
+ runLinregTestMLC(LinregType.DS, false);
+ }
+
+ private void runLinregTestMLC(LinregType type, boolean sparse) {
+
+ double[][] X = getRandomMatrix(10, 3, 0, 1, sparse ? sparsity2 : sparsity1, 7);
+ double[][] Y = getRandomMatrix(10, 1, 0, 10, 1.0, 3);
+
+ switch (type) {
+ case CG:
+ Script lrcg = dmlFromFile(TEST_SCRIPT_CG);
+ lrcg.in("X", X).in("y", Y).in("$icpt", "0").in("$tol", "0.000001").in("$maxi", "0").in("$reg", "0.000001")
+ .out("beta_out");
+ ml.execute(lrcg);
+
+ break;
+
+ case DS:
+ Script lrds = dmlFromFile(TEST_SCRIPT_DS);
+ lrds.in("X", X).in("y", Y).in("$icpt", "0").in("$reg", "0.000001").out("beta_out");
+ ml.execute(lrds);
+
+ break;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/systemml/blob/a0cf8e3b/src/test_suites/java/org/apache/sysml/test/integration/mlcontext/algorithms/ZPackageSuite.java
----------------------------------------------------------------------
diff --git a/src/test_suites/java/org/apache/sysml/test/integration/mlcontext/algorithms/ZPackageSuite.java b/src/test_suites/java/org/apache/sysml/test/integration/mlcontext/algorithms/ZPackageSuite.java
index 2230625..e4db1dc 100644
--- a/src/test_suites/java/org/apache/sysml/test/integration/mlcontext/algorithms/ZPackageSuite.java
+++ b/src/test_suites/java/org/apache/sysml/test/integration/mlcontext/algorithms/ZPackageSuite.java
@@ -26,7 +26,10 @@ import org.junit.runners.Suite;
* Group together the tests in this package.
*/
@RunWith(Suite.class)
-@Suite.SuiteClasses({ MLContextUnivariateStatisticsTest.class })
+@Suite.SuiteClasses({
+ MLContextUnivariateStatisticsTest.class,
+ MLContextLinregTest.class
+ })
/** This class is just a holder for the above JUnit annotations. */
public class ZPackageSuite {