You do not need to calculate the distance inside the loop, the H2O distance function can efficiently calculate the distances for all rows. For two data frames with dimensions n x kand m x kyou can find the distance matrix n x mas follows:
distance_matrix <- h2o.distance(df1, df2, 'l2')
, h2o.distance() , : "l1" - ( L1), "l2" - ( L2), "cosine" - "cosine_sq" - .
, :
library(h2o)
h2o.init()
df1 <- as.h2o(matrix(rnorm(7500 * 40), ncol = 40))
df2 <- as.h2o(matrix(rnorm(1250 * 40), ncol = 40))
distance_matrix <- h2o.distance(df1, df2, 'l2')
7500 rows x 1250 columns.