Landmark

landmark is a Python package that constructs landmarks \(L^\ast \subset X\) from a point set \(X \subset \mathbb{R}^d\) or a metric space \((X, d_X)\) that approximate the metric k-center problem:

\[ L^\ast \triangleq \mathop{\mathrm{argmin}}\limits_{\substack{L \subseteq X : \lvert L \rvert = k}} \ \max_{x \in X} d_X(x, L)\]

Below is an example a data set \(X\) (blue points), some sample landmarks \(L\) (red), along with the coverage (yellow) and packing (orange) properties they obey.

Usage

Given a point cloud \(X \in \mathbb{R}^{n \times d}\) represented as a numpy matrix with \(n\) points in \(d\) dimensions, the indices of the landmarks can be found with the landmarks function:

from landmark import landmarks
ind = landmarks(X, k = 10) ## Finds the indices of 25 landmarks
print(ind)
[ 0 45 15 40  2  6 21 16 10 29]

The first \(k\)-indices of ind are equivalent to the \(k\)-th prefix of the greedy permutation. You can get their covering radii and their predecessors by specifying full_output=True:

ind, info = landmarks(X, k = 10, full_output = True)
print(ind)                  ## prefix indices
print(info['radii'])        ## insertion radii 
print(info['predecessors']) ## predecessor map 
[ 0 45 15 40  2  6 21 16 10 29]
[ inf 0.88 0.67 0.54 0.46 0.44 0.37 0.29 0.27 0.25]
[ 0  0 45 45  0 45 40  6 45 15]