DAFPS

class PAsampling.wrappers.DAFPS(X, d=None, knn=100, weights=None, precomputed_distances=False)[source]

Implements the Density-Aware Farthest Point Sampling (DA-FPS) algorithm.

This class provides a wrapper around the da_fps_np function, allowing for the selection of a subset of samples from a dataset based on the DA-FPS strategy. The selection can be performed using different distance functions and can handle precomputed distance matrices.

Attributes:

Xnumpy.ndarray (n_samples, n_features)

Input points, representing a set of data points.

dnumpy.ndarray (n_samples, knn), optional (default=None)

knn distance matrix between points. The i-th row contains the sorted distances between the i-th point and its k nearest neighbors.

knnint, optional (default=100)

The number of nearest neighbors to consider when computing the knn distance matrix.

weightsnumpy.ndarray (n_samples, ), optional (default=None)

Array of weights for each point. If provided, these weights are used to adjust the selection process.

precomputed_distancesbool, optional (default=False)

If True, the input X is assumed to be a precomputed distance matrix.

fit(initial_subset, b_samples, mu=0, distance_func=None, verbose=False)[source]

Fits the model to the data X and returns the indices of the selected samples.

Parameters:

initial_subsetlist

List of indices (rows of the input points matrix) representing the initial set of selected elements.

b_samplesint

The desired number of points to select.

muint, optional (default=0)

The number of initial points to select using FPS before applying the DA-FPS algorithm. mu is expressed as a percentage of the total number of samples in the dataset. Default is 0%.

distance_funccallable, optional (default=None)

A function to compute pairwise distances. If None, Euclidean distance is used.

verbosebool, optional (default=False)

If True, progress messages are printed.

Returns:

sampleslist

List of indices representing the selected points using the DAFPS algorithm.