{'fraction_non_alphanumeric': 0.03546636375110438, 'fraction_numerical': 0.017102107787454246, 'mean_word_length': 5.142248062015504, 'pattern_counts': {'":': 0, '<': 1, '<?xml version=': 0, '>': 1, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Gaussian Process Molecule Property Prediction with FlowMO

We present FlowMO: an open-source Python library for molecular property prediction with Gaussian Processes. Built upon GPflow and RDKit, FlowMO enables the user to make predictions with well-calibrated uncertainty estimates, an output central to active learning and molecular design applications. Gaussian Processes are particularly attractive for modelling small molecular datasets, a characteristic of many real-world virtual screening campaigns where high-quality experimental data is scarce. Computational experiments across three small datasets demonstrate comparable predictive performance to deep learning methods but with superior uncertainty calibration.


Introduction
In the early stages of exploring a new class of drug molecules or molecular material, there is often only a small quantity of high-quality experimental data available [Thawani et al., 2020, Griffiths et al., 2018. In contrast to the big data regime of established molecule classes, where much of the information regarding performance has already been acquired, it is the small data regime which holds most promise for techniques such as Bayesian optimization [Gómez-Bombarelli et al., 2018, Korovina et al., 2020, Griffiths and Hernández-Lobato, 2020, Tripp et al., 2020, Moss et al., 2020a and active learning [Zhang and Lee, 2019] to expedite the rate at which novel and performant molecules are discovered.
The current trend in molecular machine learning research has been to leverage Bayesian deep learning to provide the uncertainty estimates which underpin active learning and Bayesian optimization methods [Ryu et al., 2019, Zhang and Lee, 2019, Hwang et al., 2020, Scalia et al., 2020. Deep learning methods, however, are often not the model of choice for small datasets. In fact, leading experts on deep learning have expressed a preference for Gaussian Processes (GPs) [Rasmussen, 2004] for small datasets [Bengio, 2011]. Furthermore, Bayesian deep learning methods rely on approximate inference in order to produce uncertainty estimates. In contrast, GPs admit exact inference at the expense of computationally prohibitive cost for very large datasets. In this paper, we compare calibration of the uncertainty estimates of GPs against a popular Bayesian deep learning method as well as against the recently-introduced attentive neural process .
Applying GPs to molecules in non-trivial, as the vast majority of existing applications of GPs assume inputs of low and fixed dimension. This assumption is not satisfied for the popular molecular representations of fingerprints [Rogers and Hahn, 2010] and SMILES strings [Weininger, 1988], sparse high-dimensional bit vectors and strings of variable length, respectively. To build GPs over molecules, FlowMO provides GPU-supported implementations of the Tanimoto and string kernels, providing a user-friendly way to make probabilistic predictions, whilst avoiding the expensive architecture tuning and model optimization often required to find effective deep learning models.
Our primary contributions can be summarized as follows. (1) We propose a GP framework for molecular property prediction using Tanimoto and string kernels. (2) We provide an open-source Figure 1: SMILES strings for structurally similar molecules have local differences (red) but common non-contiguous subsequences (black).
Figure 2: Fingerprints provide high-dimensional binary representations of molecules by encoding fragments whose size is dictated by a prespecified bond radius.
Python implementation built upon GPflow [De G. Matthews et al., 2017] and RDKit [Landrum, 2013], addressing the absence of GP support in popular libraries such as DeepChem [Ramsundar et al., 2019], DGL-LifeSci [Wang et al., 2020] and ASAP Cheng et al. [2020]. (3) We compare FlowMO with established baselines across three benchmark datasets with plans for a more extensive comparison of uncertainty calibration.

Molecular Representations
To apply GPs to molecules, we need a meaningful way to represent molecules. FlowMO currently supports two popular representations: SMILES and ECFP fingerprints.
SMILES strings. The Simplified Molecular-Input Line-Entry System (SMILES) [Weininger, 1988] is a procedure for expressing molecules as character strings. Each SMILES string is assembled by traversing the molecule's chemical graph. Two SMILES strings for structurally similar pyridine derivatives are presented in Figure 1. The alphabet of SMILES strings contains letters representing aliphatic and aromatic atoms (B, C, N, O, S, P, F, Cl, Br, I, b, c, n, o, s, p), parentheses and integers, as well as additional ASCII symbols representing bonds and the presence of rings (−, =, #, &, /, \, ., %).
ECFP fingerprints. ECFP fingerprints are high-dimensional bit vector representations of molecules [Christie et al., 1993] designed to search chemical databases and in the context of kernel-based classification have been used in conjunction with support vector machines [Ralaivola et al., 2005]. In this work, we consider extended-connectivity (ECFP) fingerprints [Rogers and Hahn, 2010] as generated by the RDKit library [Landrum, 2013]. ECFP fingerprints are calculated with an iterative procedure. First, each atom is represented in terms of its local properties, for example its atomic mass and valency. These local representations are then updated based on the representations of its neighbors, iteratively building representations of all fragments containing as many atoms as the chosen bond radius of the fingerprint. Finally, duplicates structures are removed and the remaining representations are hashed into a unique bit vector (see Figure 2). For our experiments, we use 2048-bit ECFP fingerprints with a bond radius of 3.

Molecular Property Prediction with Gaussian Processes
Given a training set of (possibly noisy) experimentally-determined molecular properties and a kernel function k measuring intermolecular similarity, Gaussian processes (See Rasmussen [2004] for a comprehensive introduction) provide tractable Gaussian predictive distributions for the properties of any out-of-sample target molecule. In FlowMO, we provide a kernel for each of our supported molecular representations (as introduced above): a Sub-sequence String Kernel (SSK) and a Tanimto Kernel (TK) suitable for measuring the similarity between SMILES strings of varying length and high-dimensional binary fingerprint vectors, respectively.
The computational complexity of training and inference for the GP are O(n 3 + n 2 C) and O(nC), where n is the number of training molecules and C is the cost of a single kernel evaluation. Although there exist many methods that reduce the computational complexity of GPs (for example Hensman et al. [2013]), they are designed with smooth input spaces in mind and do not yet support molecular data. In practice, we found standard GPs to be adequate for the datasets considered in this paper, and furthermore they can be comfortably applied to larger data sets using FlowMO's GPU support.
String Kernels. Sub-sequence String Kernels [Lodhi et al., 2002, Cancedda et al., 2003] measure the similarity of strings through the number of shared sub-strings, naturally supporting variable length inputs. The considered sub-strings can be non-contiguous, yielding a rich contextual model of string data that encapsulates the non-contiguity known to be important when characterising inter-SMILES similarity (Figure 1). To avoid enumeration of an exponentially-scaled feature space, SSKs exploit the kernel trick through an efficient dynamic programming algorithm, allowing individual kernel calculations between two strings s and s to be calculated in C = O(max(|s|, |s |) 2 ) operations. FlowMO's SSK implements the vectorized formulations of Beck and Cohn [2017] and Moss et al. [2020a], enabling efficient computation on GPUs. FlowMO's SSKs have two kernel parameters λ m and λ g controlling the relative weighting of long and/or highly non-contiguous sub-strings. In all our experiments, we set n = 5 and learn appropriate values for λ g and λ m through the standard practice of maximising the marginal likelihood of the GP.
Tanimoto Kernels. To build a GP model over fingerprint representations of molecules, we employ a kernel based on the Tanimoto similarity measure from the chemoinformatics literature [Gower, 1971, Fligner et al., 2002, Ralaivola et al., 2005. Note that ECFP fingerprints contain 1000 binary entries, each flagging the occurrence of particular features, and so have length and sparsity unsuitable for standard GP kernels designed for low-dimensional continuous spaces. The Tanimoto Kernel (TK) measures the similarity between two molecules via their fingerprints by the number of features present in both molecules normalized by the number of features occurring separately, i.e where f denotes a fingerprint representation and σ 2 is a single kernel hyper-parameter. The complexity of each kernel evaluation is simply C = O(|f|).

Experimental Validation
We now evaluate FlowMO (available at anonymized link) across three small molecular property prediction datasets.
Both ESOL and FreeSolv are part of the MoleculeNet dataset collection widely used for the benchmarking of molecular property prediction models [Wu et al., 2018], whereas the Photoswitch Dataset is a recent benchmark designed to specifically investigate the properties of light-activated molecules.
We compare the performance of our SSK and TK GPs with a range of existing molecular property prediction models. We report the scores of the best found model during the extensive testing of molecular graph-based models detailed in Wu et al.
[2018] namely a graph convolutional network (GCN) [Kipf and Welling, 2016] for the Photoswitch Dataset and a message passing neural network (MPNN) [Gilmer et al., 2017] for ESOL and FreeSolv. These scores are regarded as very strong benchmarks, only recently improved upon for ESOL and FreeSolv by SMILES-X [Lambard and Gracheva, 2020]. SMILES-X is a sophisticated model that relies on extensive hyperparameter optimization and requires data augmentation via augmented random SMILES. We include the performance of SMILES-X pre and post augmentation. Across all three data sets, we also consider a black-box alpha divergence minimization Bayesian Neural Network (BNN)  and an Attentive Neural Process (ANP)  applied to fingerprint representations. Our ANP and BNN follow the exact implementation described by [Thawani et al., 2020], with hyperparameters tuned by grid search. Further details are available in the supplementary information.
Reported scores for all methods are based on 20 random train/validation/test splits in an 80:10:10 ratio, except for the GPs which need no validation set and so can be applied to 90:10 train/test splits. Table 1 demonstrates the predictive performance of the models, showing the mean and a single standard deviation of the root-mean-squared error (RMSE). The best GP models outperform the ANP and BNN, and achieve comparable performance to both the MoleculeNet collection and the pre-augmentation SMILES-X models. Only the substantially more computationally demanding augmented SMILES-X model is able to significantly outperform the GPs and only on the FreeSolv data. The SSK GP outperforms the TK GP on all but the Photoswitch Dataset, suggesting that  SMILES strings are useful representations for predicting aqueous solubility and hydration free energies, but ECFP fingerprints are especially informative for modeling transition wavelengths highlighting the importance of feature engineering for molecular property prediction tasks.

Calibration
To analyze the calibration achieved by the predictive distributions provided by the probabilistic models (only the GPs, BNN and ANP), we define a calibration score function based on cross-validatory predictive p-values [Marshall andSpiegelhalter, 2003, Leslie et al., 2007]. y(m),ŷ(m) andσ(m) represent true values, predictive means and predictive standard deviations for each test molecule m ∈ T , and Φ −1 is the inverse of the standard Gaussian cumulative distribution function. The indicator 1 is activated only when the true value is contained in the model's q * 100% confidence interval. Therefore, perfect calibration at the q th quantile corresponds to C(q) = q. C(q) > q indicates under-confidence through overly large uncertainty estimates (limiting the strength of conclusions that can be drawn from the model) whereas C(q) < q denotes over-confidence (leading to reckless decisions downstream). We plot C(q) for our probabilistic models as Figure 3.

Future Work
We have presented an analysis of GPs for molecular property prediction and uncertainty quantification. Future work will extend this analysis in three ways. Firstly, as string kernels operate directly on SMILES strings, we will explore if the data augmentation strategy exploited by SMILES-X can yield a similar performance boost for our SSK GPs. Secondly, we wish to consider GPs built upon additional kernels belonging to the broad class of convolutions kernels that includes our SSK. For example, graph kernels [Vishwanathan et al., 2010] could be used to define GPs directly over molecular graphs, enabling a comparison with recent work on graph-based deep learning methods [Yang et al., 2019, Hwang et al., 2020. Finally, FlowMO will allow us to apply the extended Bayesian optimization methods designed for GP models to further improve efficiency in automatic wet-lab workflows [MacLeod et al., 2020]. Potential extensions include batch [González et al., 2016], multitask [Swersky et al., 2013], multi-fidelity [Moss et al., 2020c]

A Broader Impact
As mentioned in the main body of the paper, calibrated uncertainty estimates are highly important for the successful implementation of techniques which depend on them such as Bayesian Optimization and active learning. To this end, Gaussian Processes are an important, yet somewhat neglected method (in the molecular machine learning domain) for producing well-calibrated uncertainty estimates for small datasets. It is our hope that through the provision of a bespoke library for Gaussian Processes for molecular property prediction, we can enhance the efficacy of downstream Bayesian Optimization and active learning campaigns in discovering promising drug molecules and molecular materials in the laboratory.

B Hyper-parameter Settings
For the ESOL and FreeSolv data, hyper-parameters were selected by validation on an 80/10/10 train/validation/test split. For the Photoswitch data a split of 80/20 train/test was required in order to maintain consistency with the results reported in Thawani et al. [2020]. In this latter case, validation was performed by taking the original train set (80) and splitting this in the ratio of 90/10. Following hyper-parameter selection, the models were then re-trained using these hyper-parameters on the original train set.
For the BNN, a grid search was performed over the number of nodes per layer, the learning rate, the batch size as well as the number of iterations for the ADAM optimizer. The α hyper-parameter was fixed at 0.5 and the number of samples was fixed at 100. ReLU activations were the only activation functions considered and the number of layers was fixed to 2.
For the ANP, a grid search was performed over the number of nodes in the deterministic encoder, the number of nodes in the latent encoder and the number of nodes in the decoder in addition to the learning rate, the batch size and the number of training iterations. The dimensionality of the context encoding was fixed to 8. The number of layers for the deterministic encoder, the latent encoder and the decoder was fixed to 2 in each case. The number of samples to take of the context set was fixed to 10.