[MINOR] minor fixes in smote.dml
for loop converted to parfor
syntax reformations suggested by Arnab
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 @@
# 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 @@
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 @@
{
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.
#
#-------------------------------------------------------------