Find the top-n matches

Share:

Description

Find the top-n matches in y for each record in x.

Usage

1
2
gower_topn(x, y, pair_x = NULL, pair_y = NULL, n = 5, eps = 1e-08,
  nthread = getOption("gd_num_thread"))

Arguments

x

[data.frame]

y

[data.frame]

pair_x

[numeric|character] (optional) Columns in x used for comparison. See Details below.

pair_y

[numeric|character] (optional) Columns in y used for comparison. See Details below.

n

The top-n indices and distances to return.

eps

[numeric] (optional) Computed numbers (variable ranges) smaller than eps are treated as zero.

nthread

Number of threads to use for parallelization. By default, for a dual-core machine, 2 threads are used. For any other machine n-1 cores are used so your machine doesn't freeze during a big computation. The maximum nr of threads are determined from omp::get_max_threads.

Value

A list with two array elements: index and distance. Both have size n X nrow(x). Each ith column corresponds to the top-n best matches of x with rows in y.

See Also

gower_dist

Examples

1
2
3
4
# find the top 4 best matches in the iris data set with itself.
x <- iris[1:3,]
lookup <- iris[1:10,]
gower_topn(x=x,y=lookup,n=4)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.