  Many astronomical surveys are limited by the brightness of the sources, and
gravitational-wave searches are no exception. The detectability of
gravitational waves from merging binaries is affected by the mass and spin of
the constituent compact objects. To perform unbiased inference on the
distribution of compact binaries, it is necessary to account for this selection
effect, which is known as Malmquist bias. Since systematic error from selection
effects grows with the number of events, it will be increasingly important over
the coming years to accurately estimate the observational selection function
for gravitational-wave astronomy. We employ density estimation methods to
accurately and efficiently compute the compact binary coalescence selection
function. We introduce a simple pre-processing method, which significantly
reduces the complexity of the required machine learning models. We demonstrate
that our method has smaller statistical errors at comparable computational cost
than the method currently most widely used allowing us to probe narrower
distributions of spin magnitudes. The currently used method leaves $10-50\%$ of
the interesting black hole spin models inaccessible; our new method can probe
$>99\%$ of the models and has a lower uncertainty for $>80\%$ of the models.
