Skip to content

Commit 18628f0

Browse files
[MINOR] minor fixes in smote.dml
for loop converted to parfor syntax reformations suggested by Arnab
1 parent 8501fb3 commit 18628f0

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

scripts/builtin/smote.dml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ return (Matrix[Double] Y) {
5555
# matrix to keep the index of KNN for each minority sample
5656
knn_index = matrix(0,k,nrow(X))
5757
# find nearest neighbour
58-
for(i in 1:nrow(X))
58+
parfor(i in 1:nrow(X))
5959
{
6060
knn = nn(X, X[i, ], k)
6161
knn_index[, i] = knn
@@ -68,11 +68,8 @@ return (Matrix[Double] Y) {
6868
synthetic_samples = matrix(0, iterLim*ncol(knn_index), ncol(X))
6969

7070
# shuffle the nn indexes
71-
if(k < iterLim)
72-
rand_index = sample(k, iterLim, TRUE)
73-
else
74-
rand_index = sample(k, iterLim)
75-
71+
rand_index = ifelse(k < iterLim, sample(k, iterLim, TRUE, 42), sample(k, iterLim, 42))
72+
7673
while(iter < iterLim)
7774
{
7875
# pick the random NN
@@ -82,7 +79,7 @@ return (Matrix[Double] Y) {
8279
{
8380
index = as.scalar(knn_sample[1,i])
8481
X_diff = X[index,] - X[i, ]
85-
gap = as.scalar(Rand(rows=1, cols=1, min=0, max=1, seed = 41))
82+
gap = as.scalar(Rand(rows=1, cols=1, min=0, max=1, seed = 42))
8683
X_sys = X[i, ] + (gap*X_diff)
8784
synthetic_samples[iter*ncol(knn_index)+i,] = X_sys;
8885
}

src/test/scripts/functions/builtin/imputeFD.dml

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
#-------------------------------------------------------------
22
#
3-
# Copyright 2020 Graz University of Technology
4-
#
5-
# Licensed under the Apache License, Version 2.0 (the "License");
6-
# you may not use this file except in compliance with the License.
7-
# You may obtain a copy of the License at
3+
# Licensed to the Apache Software Foundation (ASF) under one
4+
# or more contributor license agreements. See the NOTICE file
5+
# distributed with this work for additional information
6+
# regarding copyright ownership. The ASF licenses this file
7+
# to you under the Apache License, Version 2.0 (the
8+
# "License"); you may not use this file except in compliance
9+
# with the License. You may obtain a copy of the License at
810
#
911
# http://www.apache.org/licenses/LICENSE-2.0
1012
#
11-
# Unless required by applicable law or agreed to in writing, software
12-
# distributed under the License is distributed on an "AS IS" BASIS,
13-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14-
# See the License for the specific language governing permissions and
15-
# limitations under the License.
13+
# Unless required by applicable law or agreed to in writing,
14+
# software distributed under the License is distributed on an
15+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
# KIND, either express or implied. See the License for the
17+
# specific language governing permissions and limitations
18+
# under the License.
1619
#
1720
#-------------------------------------------------------------
1821

0 commit comments

Comments
 (0)