K-Nearest Neighbors: every point reaches for its closest eight
2026Giclée prints on archival paper
Sizes vary by work
Scatter points at random over a square. Then let each one draw a line to the eight points nearest to it. That is the whole rule. What comes out is not a uniform mesh but a kind of lace: tight knots of triangles, thin threads between them, and open rounded holes where nothing is close enough to reach across.
The algorithm
k-nearest neighbors is one of the oldest ideas in machine learning. To guess what something is, look at the few known examples closest to it and go with what they are. The "k" is how many neighbours you look at. Here there is nothing to guess. I only keep the part that finds the neighbours, and draw it.
- Scatter the points. Place them at random, evenly spread over the square, with no pattern intended.
- Find each point's neighbours. For every point, find the eight other points closest to it.
- Draw a line to each of them. Every point sends out eight lines.
The texture comes from one simple fact: being close is not mutual. If a point sits in a crowd, its eight nearest neighbours are all close by, so its lines are short and they pile up into a dense knot. If it sits alone, its nearest eight may be far away, so it throws long lines across the gap. And the crowd on the other end usually doesn't reach back, because each of those points has closer neighbours of its own.
So a random scatter, which looks like an even grey from a distance, turns into a map of its own small accidents. Where the points happened to bunch up you get knots. Where they happened to thin out you get holes. The long single lines are the bridges between them.
Where it started
The first version, 2022. Ten thousand points, eight neighbours each, black on white.
I first made this as a short Python notebook, adapted from Marcus Volz's R code in his mathart collection. It used ten thousand points and drew every connection as a thin black line. Up close it is lovely. From across a room it reads as one even texture, because there are so many points that every hole is about the same size.
What changed for the new pieces
I rebuilt it in Processing, and three changes turned the texture into a picture.
Fewer points, so the shapes get bigger. The number of points doesn't make the picture lighter or darker. It changes the scale. With ten thousand points the holes are small and everywhere. With 2,500 each point's fan of eight lines becomes a little rosette you can see on its own, and the long lines read as single strokes bridging the holes. With 1,000 the holes become large rounded rooms.
Lines made of dots. Each line is drawn as a row of small overlapping dots, each nudged slightly off the true line. From a distance it reads as an ink line. Up close the edge is soft and slightly uneven, like a pen on paper rather than a vector on a screen. The dots are partly transparent, so where lines cross, or where two points each count the other as a neighbour and the same line is drawn twice, the ink builds up darker.
Colour that follows the structure. The colour of a line can be taken from how long it is. Short lines, the ones inside the knots, take one end of the palette. Long lines, the bridges and the rims of the holes, take the other. So the colour traces the same thing the density already shows: where the crowds are, and where they thin out.
Every image comes from a random seed and a list of settings, and the file name records all of them. The same file name always produces the same picture, line for line, at any size. That lets me look through hundreds of seeds at preview size and then print the ones I keep at a metre wide, knowing the composition will not change.
Ember
100 × 100 cm.
The densest of the three. The colour runs from deep violet through magenta to orange, by length. The short lines inside the knots are violet. The orange is the longer lines, so it gathers around the edges of the holes and makes each one look lit from inside.
Tide
100 × 100 cm.
Fewer points, so everything is larger and more open. The short lines in the knots are navy and the long bridges are pale turquoise. The holes join up into winding channels, like water running through a net.
K-Nearest Neighbors 12
K-Nearest Neighbors 12. 100 × 100 cm, signed.
The most open of the three. With only a thousand points, the holes become large rooms and the knots become clusters of shards. One more step makes the difference: wherever three points are all neighbours of each other, the triangle between them is filled with a thin, see-through wash of vermilion. Triangles only form where points crowd together, so the washes stack up in the knots and leave the holes bare. The deepest reds are where many layers overlap.
K-Nearest Neighbors is made in Processing. The 2022 notebook it grew from was adapted from marcusvolz/mathart.