osier.utils.farthest_first#
- osier.utils.farthest_first(X, D, n_points, start_idx=None, seed=1234)[source]#
This function identifies the farthest first traversal order for an MxN matrix and returns an array of indices (ordered by the distance). If n_points exceeds the number of points in the dataset, all points will be returned.
This implementation was modified from Hiroyuki Tanaka’s [GitHub gist](https://gist.github.com/nkt1546789/8e6c46aa4c3b55f13d32).
- Parameters:
X (
numpy.ndarray) – An MxN matrix.D (
numpy.ndarray) – An MxM distance matrix for the dataset, X.n_points (int) – The number of points to traverse.
start_idx (int) – The index of the starting point. If None, a starting point will be chosen randomly. Default is None.
seed (int) – Specifies the seed for a random number generator to ensure repeatable results. Default is 1234.
- Returns:
checked_points – An array of points checked by the algorithm.
- Return type:
Notes
The algorithm will stop if the average distance is unchanging.