public class kNearestNeighbors
Imputation of the missing data by k-nearest neighbors.
public static kotlin.Array[] impute(kotlin.Array[] data,
int k,
boolean isManhattan,
boolean isCosine)
Impute all the missing values.
data - matrixk - - number of nearest neighbors to be computed.isManhattan - - if true Manhattan distance will be used.isCosine - - if true Cosine similarity will be used.public static double columnMean(kotlin.Array[] data,
int col)
data - a matrixcol - the column of the matrix for which the mean should be computedpublic static double cosine(kotlin.Array[] data1,
kotlin.Array[] data2)
Computes the cosine similarity of two vectors.
data1 - arraydata2 - arraypublic static kotlin.Array[] cosineSimRank(kotlin.Array[] data,
int row,
int col,
int k)
Rank all the rows according to their cosine similarity with the given row.
data - matrixrow - col - k - public static double distance(kotlin.Array[] data1,
kotlin.Array[] data2,
boolean isManhattan)
Compute Manhattan or Eulcidean distance between two vectors.
data1 - arraydata2 - arrayisManhattan - - true for Manhattan distance choice.public static kotlin.Array[] KNearestNeighbor(kotlin.Array[] data,
int row,
int k,
boolean isManhattan)
Rank the rows based on their distance from the given row.
data - matrixrow - k - isManhattan -