You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@systemds.apache.org by ss...@apache.org on 2020/10/05 12:24:56 UTC

[systemds] branch master updated: [MINOR] minor fixes in smote.dml

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 18628f0  [MINOR] minor fixes in smote.dml
18628f0 is described below

commit 18628f07cd027b8dd9938b5f23fee7183e8357e7
Author: Shafaq Siddiqi <sh...@tugraz.at>
AuthorDate: Mon Oct 5 14:21:28 2020 +0200

    [MINOR] minor fixes in smote.dml
    
    for loop converted to parfor
    syntax reformations suggested by Arnab
---
 scripts/builtin/smote.dml                       | 11 ++++-------
 src/test/scripts/functions/builtin/imputeFD.dml | 23 +++++++++++++----------
 2 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/scripts/builtin/smote.dml b/scripts/builtin/smote.dml
index 8e04e1d..a223227 100644
--- a/scripts/builtin/smote.dml
+++ b/scripts/builtin/smote.dml
@@ -55,7 +55,7 @@ return (Matrix[Double] Y) {
   # matrix to keep the index of KNN for each minority sample
   knn_index = matrix(0,k,nrow(X))
   # find nearest neighbour
-  for(i in 1:nrow(X))
+  parfor(i in 1:nrow(X))
   {
     knn = nn(X, X[i, ], k)
     knn_index[, i] = knn
@@ -68,11 +68,8 @@ return (Matrix[Double] Y) {
   synthetic_samples = matrix(0, iterLim*ncol(knn_index), ncol(X))
   
   # shuffle the nn indexes
-  if(k < iterLim)
-    rand_index = sample(k, iterLim, TRUE)
-  else 
-    rand_index = sample(k, iterLim)
-  
+  rand_index =  ifelse(k < iterLim, sample(k, iterLim, TRUE, 42), sample(k, iterLim, 42))
+
   while(iter < iterLim)
   {
     # pick the random NN
@@ -82,7 +79,7 @@ return (Matrix[Double] Y) {
     {
       index = as.scalar(knn_sample[1,i])
       X_diff = X[index,] - X[i, ]
-      gap = as.scalar(Rand(rows=1, cols=1, min=0, max=1, seed = 41))
+      gap = as.scalar(Rand(rows=1, cols=1, min=0, max=1, seed = 42))
       X_sys = X[i, ] + (gap*X_diff)
       synthetic_samples[iter*ncol(knn_index)+i,] = X_sys;
     }
diff --git a/src/test/scripts/functions/builtin/imputeFD.dml b/src/test/scripts/functions/builtin/imputeFD.dml
index bcb61f1..1110642 100644
--- a/src/test/scripts/functions/builtin/imputeFD.dml
+++ b/src/test/scripts/functions/builtin/imputeFD.dml
@@ -1,18 +1,21 @@
 #-------------------------------------------------------------
 #
-# Copyright 2020 Graz University of Technology
-#
-# Licensed 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
+# 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.
+# 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.
 #
 #-------------------------------------------------------------