regaleo605 commented on code in PR #1888:
URL: https://github.com/apache/systemds/pull/1888#discussion_r1306430830


##########
scripts/builtin/imputeByKNN.dml:
##########
@@ -76,30 +79,32 @@ m_imputeByKNN = function(Matrix[Double] X, String 
method="dist", Int seed=-1)
     #Get the minimum distance row-wise computation
     minimum_index = rowIndexMin(distance_matrix)
 
-    #Position of missing values in per row in which column
-    position = rowSums(is.nan(X))
-    position = position * minimum_index
+    #Loop through each column
+    parfor(i in 1:nrow(missing_col_index), check = 0){
+      #Position of missing values in per row in which column
+      position = masked[,as.scalar(missing_col_index[i,1])]
+      position = position * minimum_index

Review Comment:
   By replacing the 0 value with (nrow(X) + 1) and then use table with 
restricted odim1 and odim2. I can get directly the A with the same dimensions 
as the mask and ignore the non-problematic rows and thus the imputed value. I 
am not sure if using the replace() function will be bad in terms of efficiency.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to