The basicities of 125 pyridine derivatives in the gas phase and in water have been correlated with the electron density properties within the framework of quantum topological molecular similarity (QTMS). We used the theory of quantum chemical topology (QCT) to provide ab initio descriptors that are able to predict pkb values. Partial least squares (PLS) and the machine-learning technique Kriging generated validated models. Properties were considered for systems in their neutral and protonated forms. The compounds were divided into a training set, used to develop the models, and a test set, for which the predicted values of the different models were compared with the experimental ones. The results were found to be good for those compounds with substituents in the meta and para positions, whereas the use of Kriging was required to obtain reasonable results when ortho derivatives were included. The basicity was found to be better described in the gas phase than in water. Special attention was paid to external validation. © 2010 American Chemical Society.