The choice of distance functions
WIT uses a distance function for its visual representation of data points.
If you click on the information symbol (i) next to Nearest counterfactual, WIT shows the three distance function options available:
Figure 9.19: Choosing a distance function
In this section, we will go through these options, starting with the L1 norm:
- The L1 norm
- The L2 norm
- Custom distance
The L1 norm
The L1 norm is the Manhattan or taxicab norm because it calculates distances in a way that resembles the blocks in Manhattan. The following diagram shows a grid like the blocks of buildings in Manhattan, New York City:
Figure 9.20: Manhattan distance
Suppose you take a cab at point [0, 0] and want to go to point [5, 6]. The driver will go 5 blocks in a straight line (see the blocks in gray) and will then turn to the left and drive 6 blocks (see the path in gray). You will pay a distance of 5 + 6 blocks = 11 ...