You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@systemds.apache.org by ba...@apache.org on 2022/09/15 20:55:51 UTC

[systemds] branch main updated: [MINOR] Python NoReturn source test add sleep

This is an automated email from the ASF dual-hosted git repository.

baunsgaard pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/systemds.git


The following commit(s) were added to refs/heads/main by this push:
     new 75df84d77c [MINOR] Python NoReturn source test add sleep
75df84d77c is described below

commit 75df84d77c81dc4f088324a1b0b919c2cf99550b
Author: baunsgaard <ba...@tugraz.at>
AuthorDate: Thu Sep 15 22:55:26 2022 +0200

    [MINOR] Python NoReturn source test add sleep
---
 .../systemds/operator/algorithm/builtin/l2svm.py   | 26 ++++++++++++----------
 .../systemds/operator/algorithm/builtin/msvm.py    | 23 ++++++++++---------
 .../python/tests/source/test_source_no_return.py   |  5 ++++-
 3 files changed, 30 insertions(+), 24 deletions(-)

diff --git a/src/main/python/systemds/operator/algorithm/builtin/l2svm.py b/src/main/python/systemds/operator/algorithm/builtin/l2svm.py
index 5ae30f44b0..dadc1f1be8 100644
--- a/src/main/python/systemds/operator/algorithm/builtin/l2svm.py
+++ b/src/main/python/systemds/operator/algorithm/builtin/l2svm.py
@@ -33,22 +33,24 @@ def l2svm(X: Matrix,
           Y: Matrix,
           **kwargs: Dict[str, VALID_INPUT_TYPES]):
     """
-     Builtin function Implements binary-class SVM with squared slack variables
+     This builting function implements binary-class Support Vector Machine (SVM)
+     with squared slack variables (l2 regularization).
     
     
     
-    :param X: matrix X of feature vectors
-    :param Y: matrix Y of class labels have to be a single column
-    :param intercept: No Intercept ( If set to TRUE then a constant bias column is added to X)
-    :param epsilon: Procedure terminates early if the reduction in objective function value is less
-        than epsilon (tolerance) times the initial objective function value.
-    :param reg: Regularization parameter (reg) for L2 regularization
-    :param maxIterations: Maximum number of conjugate gradient iterations
-    :param maxii: max inner for loop iterations
-    :param verbose: Set to true if one wants print statements updating on loss.
-    :param columnId: The column Id used if one wants to add a ID to the print statement,
+    :param X: Feature matrix X (shape: m x n)
+    :param Y: Label vector y of class labels (shape: m x 1), assumed binary
+        in -1/+1 or 1/2 encoding.
+    :param intercept: Indicator if a bias column should be added to X and the model
+    :param epsilon: Tolerance for early termination if the reduction of objective
+        function is less than epsilon times the initial objective
+    :param reg: Regularization parameter (lambda) for L2 regularization
+    :param maxIterations: Maximum number of conjugate gradient (outer) iterations
+    :param maxii: Maximum number of line search (inner) iterations
+    :param verbose: Indicator if training details should be printed
+    :param columnId: An optional class ID used in verbose print output,
         eg. used when L2SVM is used in MSVM.
-    :return: the trained model
+    :return: Trained model/weights (shape: n x 1, w/ intercept: n+1)
     """
 
     params_dict = {'X': X, 'Y': Y}
diff --git a/src/main/python/systemds/operator/algorithm/builtin/msvm.py b/src/main/python/systemds/operator/algorithm/builtin/msvm.py
index 988d873518..fdf1ce3db0 100644
--- a/src/main/python/systemds/operator/algorithm/builtin/msvm.py
+++ b/src/main/python/systemds/operator/algorithm/builtin/msvm.py
@@ -33,21 +33,22 @@ def msvm(X: Matrix,
          Y: Matrix,
          **kwargs: Dict[str, VALID_INPUT_TYPES]):
     """
-     Implements builtin multi-class SVM with squared slack variables, 
-     learns one-against-the-rest binary-class classifiers by making a function call to l2SVM
+     This builtin function implements a multi-class Support Vector Machine (SVM)
+     with squared slack variables. The trained model comprises #classes
+     one-against-the-rest binary-class l2svm classification models.
     
     
     
-    :param X: matrix X of feature vectors
-    :param Y: matrix Y of class labels
-    :param intercept: No Intercept ( If set to TRUE then a constant bias column is added to X)
-    :param num_classes: Number of classes
-    :param epsilon: Procedure terminates early if the reduction in objective function
-        value is less than epsilon (tolerance) times the initial objective function value.
+    :param X: Feature matrix X (shape: m x n)
+    :param Y: Label vector y of class labels (shape: m x 1),
+        where max(Y) is assumed to be the number of classes
+    :param intercept: Indicator if a bias column should be added to X and the model
+    :param epsilon: Tolerance for early termination if the reduction of objective
+        function is less than epsilon times the initial objective
     :param reg: Regularization parameter (lambda) for L2 regularization
-    :param maxIterations: Maximum number of conjugate gradient iterations
-    :param verbose: Set to true to print while training.
-    :return: model matrix
+    :param maxIterations: Maximum number of conjugate gradient (outer l2svm) iterations
+    :param verbose: Indicator if training details should be printed
+    :return: Trained model/weights (shape: n x max(Y), w/ intercept: n+1)
     """
 
     params_dict = {'X': X, 'Y': Y}
diff --git a/src/main/python/tests/source/test_source_no_return.py b/src/main/python/tests/source/test_source_no_return.py
index f38273dd61..237a8d2fbd 100644
--- a/src/main/python/tests/source/test_source_no_return.py
+++ b/src/main/python/tests/source/test_source_no_return.py
@@ -21,7 +21,7 @@
 
 import unittest
 
-import numpy as np
+from time import sleep
 from systemds.context import SystemDSContext
 
 class TestSource_NoReturn(unittest.TestCase):
@@ -41,6 +41,7 @@ class TestSource_NoReturn(unittest.TestCase):
         s = self.sds.source(self.src_path,"test")
         c = s.no_return()
         c.compute()
+        sleep(1) # to allow the std buffer to fill
         stdout = self.sds.get_stdout()
         self.assertEqual(4.2 + 14 * 2,float(stdout[0]))
 
@@ -48,6 +49,7 @@ class TestSource_NoReturn(unittest.TestCase):
         s = self.sds.source(self.src_path,"test")
         c = s.no_return(4)
         c.compute()
+        sleep(1) # to allow the std buffer to fill
         stdout = self.sds.get_stdout()
         self.assertEqual(4 + 14 * 2,float(stdout[0]))
 
@@ -55,6 +57,7 @@ class TestSource_NoReturn(unittest.TestCase):
         s = self.sds.source(self.src_path,"test")
         c = s.no_return(a=14)
         c.compute()
+        sleep(1) # to allow the std buffer to fill
         stdout = self.sds.get_stdout()
         self.assertEqual(14 + 14 * 2,float(stdout[0]))