Python module: cuvs.neighbors.filters
1 def no_filter()
Create a default pre-filter which filters nothing.
1 def from_bitmap(bitmap)
Create a pre-filter from an array with type of uint32.
Parameters
| Name | Type | Description |
|---|---|---|
bitmap | numpy.ndarray | An array with type of uint32 where each bit in the array corresponds to if a sample and query pair is greenlit (not filtered) or filtered. The array is row-major, meaning the bits are ordered by rows first. Each bit in a uint32 element represents a different sample-query pair.- Bit value of 1: The sample-query pair is greenlit (allowed). - Bit value of 0: The sample-query pair is filtered. |
Returns
| Name | Type | Description |
|---|---|---|
filter | cuvs.neighbors.filters.Prefilter | An instance of Prefilter that can be used to filter neighbors based on the given bitmap. |
resources | cuvs.common.Resources, optional |
Examples
1 >>> import cupy as cp 2 >>> import numpy as np 3 >>> from cuvs.neighbors import filters 4 >>> 5 >>> n_samples = 50000 6 >>> n_queries = 1000 7 >>> 8 >>> n_bitmap = np.ceil(n_samples * n_queries / 32).astype(int) 9 >>> bitmap = cp.random.randint(1, 100, size=(n_bitmap,), dtype=cp.uint32) 10 >>> prefilter = filters.from_bitmap(bitmap)
1 def from_bitset(bitset)
Create a pre-filter from an array with type of uint32.
Parameters
| Name | Type | Description |
|---|---|---|
bitset | numpy.ndarray | An array with type of uint32 where each bit in the array corresponds to if a sample is greenlit (not filtered) or filtered. Each bit in a uint32 element represents a different sample of the dataset.- Bit value of 1: The sample is greenlit (allowed). - Bit value of 0: The sample pair is filtered. |
Returns
| Name | Type | Description |
|---|---|---|
filter | cuvs.neighbors.filters.Prefilter | An instance of Prefilter that can be used to filter neighbors based on the given bitset. |
resources | cuvs.common.Resources, optional |
Examples
1 >>> import cupy as cp 2 >>> import numpy as np 3 >>> from cuvs.neighbors import filters 4 >>> 5 >>> n_samples = 50000 6 >>> n_queries = 1000 7 >>> 8 >>> n_bitset = np.ceil(n_samples / 32).astype(int) 9 >>> bitset = cp.random.randint(1, 100, size=(n_bitset,), dtype=cp.uint32) 10 >>> prefilter = filters.from_bitset(bitset)
1 cdef class Prefilter
Constructor
1 def __init__(self, cuvsFilter prefilter, parent=None)