inst/doc/metrics.R

## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

## ----setup--------------------------------------------------------------------
library(rnndescent)

## ----binary data--------------------------------------------------------------
set.seed(42)
binary_data <- matrix(sample(c(0, 1), 100, replace = TRUE), ncol = 10)
head(binary_data)

## ----hamming------------------------------------------------------------------
nn <- brute_force_knn(binary_data, k = 4, metric = "hamming")

## ----logical data-------------------------------------------------------------
logical_data <- binary_data == 1
head(logical_data)

## ----logical hamming----------------------------------------------------------
logical_nn <- brute_force_knn(logical_data, k = 4, metric = "hamming")

## ----compare------------------------------------------------------------------
all.equal(nn, logical_nn)

Try the rnndescent package in your browser

Any scripts or data that you put into this service are public.

rnndescent documentation built on May 29, 2024, 8:38 a.m.