# Using Enriched Category Theory to Construct the Nearest Neighbour Classification Algorithm

arXiv: https://arxiv.org/abs/2312.16529 · HTML: https://mlsanity.com/paper/2312.16529/

## Key facts

- Cited by 1 papers in the map (data through 14 Oct 2026).
- Builds on 2 of its 5 references that are in the map.
- First posted on arXiv 27 Dec 2023.

## Builds on (most cited first, 2 of 2)

- [Graph Neural Networks are Dynamic Programmers](https://mlsanity.com/paper/2203.15544/) (2022)
- [Kan Extensions in Data Science and Machine Learning](https://mlsanity.com/paper/2203.09018/) (2022)

## Built on by (most cited first, 1 of 1)

- [Transparent Semantic Spaces: A Categorical Approach to Explainable Word Embeddings](https://mlsanity.com/paper/2508.20701/) (2025)

## Abstract (arXiv)

This paper is the first to construct and motivate a Machine Learning algorithm solely with Enriched Category Theory, supplementing evidence that Category Theory can provide valuable insights into the construction and explainability of Machine Learning algorithms. It is shown that a series of reasonable assumptions about a dataset lead to the construction of the Nearest Neighbours Algorithm. This construction is produced as an extension of the original dataset using profunctors in the category of Lawvere metric spaces, leading to a definition of an Enriched Nearest Neighbours Algorithm, which, consequently, also produces an enriched form of the Voronoi diagram. Further investigation of the generalisations this construction induces demonstrates how the k Nearest Neighbours Algorithm may also be produced. Moreover, how the new construction allows metrics on the classification labels to inform the outputs of the Enriched Nearest Neighbour Algorithm: Enabling soft classification boundaries and dependent classifications. This paper is intended to be accessible without any knowledge of Category Theory.
