Wrong Euclidean distance H2O calculations R -
i using h2o r calculate euclidean distance between 2 data.frames:
set.seed(121) #create data df1<-data.frame(matrix(rnorm(1000),ncol=10)) df2<-data.frame(matrix(rnorm(300),ncol=10)) #init h2o h2o.init() #transform h2o df1.h<-as.h2o(df1) df2.h<-as.h2o(df2)
if use normal calculations, i.e. first row:
distance1<-sqrt(sum((df1[1,]-df2[1,])^2))
and if use h2o library:
distance.h2o<-h2o.distance(df1.h[1,],df2.h[1,],"l2") print(distance1) print(distance.h2o)
the distance1 , distance.h2o not same. knows why? thanks!!
it seems if h2o.distance
calculates sum of squares, without taking square root: take square root standard result.
distance.h2o <- h2o.distance(df1.h[1,],df2.h[1,],"l2") sqrt(distance.h2o)
Comments
Post a Comment