  Machine learning (ML) algorithms have undergone an explosive development
impacting every aspect of computational chemistry. To obtain reliable
predictions, one needs to maintain the proper balance between the black-box
nature of ML frameworks and the physics of the target properties. One of the
most appealing quantum-chemical properties for regression models is the
electron density, and some of us recently proposed a transferable and scalable
model based on the decomposition of the density onto an atom-centered basis
set. The decomposition, as well as the training of the model, is at its core a
minimization of some loss function, which can be arbitrarily chosen and may
lead to results of different quality. Well-studied in the context of density
fitting (DF), the impact of the metric on the performance of ML models has not
been analyzed yet. In this work, we compare predictions obtained using the
overlap and the Coulomb-repulsion metrics for both decomposition and training.
As expected, the Coulomb metric used as both the DF and ML loss functions leads
to the best results for the electrostatic potential and dipole moments. The
origin of this difference lies in the fact that the model is not constrained to
predict densities that integrate to the exact number of electrons $N$. Since an
\textit{a posteriori} correction for the number of electrons decreases the
errors, we proposed a modification of the model where $N$ is included directly
into the kernel function, which allowed to lower the errors on the test and
out-of-sample sets.
