peekxc / landmark-py

Finds 'landmarks' via metric k-center approximations

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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 (also known k-center clustering problem):

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

Metric $k$-center is a classic NP-hard problem intrinsically related to many other problems, such as geometric set cover and facility location; its output is also related to other geometric constructions, like $\epsilon$-nets.

Landmarks example

Installation

Clone and use:

python -m pip install < landmark-py location >

Warning: this package is very early-stage, e.g. does not offer wheels on PyPI. Use with care.

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 landmarks:

from landmark import landmarks
ind = landmarks(X, k = 25) ## Finds the indices of 25 landmarks
print(ind)
# [0, 32, 45, 16, ...]

The first $k$-indices of ind are equivalent to the $k$-th prefix of the greedy permutation. You can get their covering radii by specifying radii = True

from landmark import landmarks
ind, radii = landmarks(X, k = 25, radii = True) ## Finds the indices of 25 landmarks
print(ind, radii)
# [0, 32, 45, 16, ...]
# [inf 31.6024 28.4495 20.3045 ...]

For more examples, see notebook example.

About

Finds 'landmarks' via metric k-center approximations

License:Apache License 2.0


Languages

Language:Python 44.8%Language:C++ 43.5%Language:Meson 11.7%