Year: 2018

Abstract:
Automatic Chemical Design provides a framework for generating novel molecules with optimized molecular properties. The current model suffers from the pathology that it tends to produce invalid molecular structures. By reformulating the search procedure as a constrained Bayesian optimization problem, we showcase improvements in both the validity and quality of the generated molecules. We demonstrate that the model consistently produces novel molecules ranking above the 90th percentile of the distribution over training set scores across a range of objective functions. Importantly, our method suffers no degradation in the complexity or the diversity of the generated molecules.

heading: 1 INTRODUCTION
text: There are two fundamental ways in which Machine Learning can be leveraged in chemical design:
1. To evaluate a molecule for a given application. 2. To find a promising molecule for a given application.
There has been much progress in the first use-case through the development of quantitative structure activity relationship (QSAR) models using deep learning (Ma et al., 2015). These models have achieved state-of-the-art results in predicting properties of known molecules.
The second use-case, finding new molecules that are useful for a given application, is arguably more important however. One existing approach for finding molecules that maximise an applicationspecific metric involves searching a large library of compounds, either physically or virtually PyzerKnapp et al. (2015). This has the disadvantage that the search is not open-ended; if the molecule is not in the library you specify, the search won’t find it.
A second method involves the use of genetic algorithms. In this approach, a known molecule acts as a seed and a local search is performed over a discrete space of molecules. Although these methods have enjoyed success in producing biologically active compounds, an approach featuring a search over an open-ended, continuous space would be beneficial. The use of geometrical cues such as gradients to guide the search in continuous space could accelerate both drug (Pyzer-Knapp et al., 2015; Gómez-Bombarelli et al., 2016a) and material (Hachmann et al., 2011; 2014) discovery by functioning as a high-throughput virtual screen of unpromising candidates.
Recently, Gómez-Bombarelli et al. (Gómez-Bombarelli et al., 2016b) presented Automatic Chemical Design, a VAE architecture capable of encoding continuous representations of molecules. In continuous latent space, gradient-based optimization is leveraged to find molecules that maximize a design metric.
Although a strong proof of concept, Automatic Chemical Design possesses a deficiency in so far as it fails to generate a high proportion of valid molecular structures. Gómez-Bombarelli et al. (2016b) hypothesise that molecules selected by Bayesian Optimization lie in “dead regions” of the latent space far away from any data that the VAE has seen in training, yielding invalid structures when decoded. Although there have been many attempts to address the issue of generating valid molecules, they all rely on model assumptions that can negatively impact either the complexity (Jaques et al., 2017; Janz et al., 2017; Kusner et al., 2017) or the diversity (Jin et al., 2018) of the generated molecules.
The principle contribution of this paper will be to present an approach based on constrained Bayesian optimization that generates a high proportion of valid sequences without relying on model assumptions that affect the complexity or the diversity of the generated molecules.

heading: 2 METHODS

heading: 2.1 SMILES REPRESENTATION
text: SMILES strings Weininger (1988) are a means of representing molecules as a character sequence. This text-based format facilitates the use of tools from natural language processing for applications such as organic chemistry reaction prediction Schwaller et al. (2017); Jin et al. (2017). For use with the variational autoencoder, the SMILES strings in turn are converted into one-hot vectors indicating the presence or absence of a particular character within a sequence as illustrated in Figure 1.

heading: 2.2 VARIATIONAL AUTOENCODER
text: Variational autoencoders Kingma & Welling (2013); Kingma et al. (2014) allow us to map molecules x to and from continuous values z in a latent space. The encoding z is interpreted as a latent variable in a probabilistic generative model over which there is a prior distribution p(z). The probabilistic decoder is defined by the likelihood function pθ(x|z). The posterior distribution pθ(z|x) is interpreted as the probabilistic encoder. The parameters of the likelihood pθ(x|z) as well as the parameters of the approximate posterior distribution qφ(z|x) are learned by maximizing the evidence lower bound (ELBO)
L(φ, θ;x) = Eqφ(z|x)[log pθ(x, z)− log qφ(z|x)].
Variational autoencoders have been coupled with recurrent neural networks by Bowman et al. (2015) to encode sentences into a continuous latent space. This approach is followed for the SMILES format both by Gómez-Bombarelli et al. (2016b) and here. The SMILES variational autoencoder, together with our constraint function, is shown in Figure 2.

heading: 2.3 OBJECTIVE FUNCTIONS FOR BAYESIAN OPTIMIZATION OF MOLECULES
text: Bayesian Optimization is performed in the latent space of the variational autoencoder in order to find molecules that score highly under a specified objective function. We assess molecular quality on the following objectives:
J logPcomp(m) = logP(m)− SA(m)− ring-penalty(m),
JQEDcomp(m) = QED(m)− SA(m)− ring-penalty(m),
JQED(m) = QED(m).
m denotes a molecule, logP(m) is the water-octanol partition coefficient, QED(m) is the quantitative estimate of drug-likeness (Bickerton et al., 2012) and SA(m) is the synthetic accessibility (Ertl & Schuffenhauer, 2009). The ring penalty term is as featured in (Gómez-Bombarelli et al., 2016b). The “comp” subscript is designed to indicate that the objective function is a composite of standalone metrics.
It is important to note, that the first objective, a common metric of comparison in this area GómezBombarelli et al. (2016b); Kusner et al. (2017); Jin et al. (2018), is mis-specified. From a chemical standpoint it is undesirable to maximize the logP score as is being done here. Rather it is preferable to optimize logP to be in a range that is in accordance with the Lipinski Rule of Five Lipinski et al. (1997). We use the penalized logP objective here because regardless of its relevance for chemistry, it serves as a point of comparison against other methods.

heading: 2.4 CONSTRAINED BAYESIAN OPTIMIZATION OF MOLECULES
text: We now describe our extension to the Bayesian Optimization procedure followed by GómezBombarelli et al. (2016b). Expressed formally, the constrained optimization problem is
max m
f(m) s.t. Pr(C(m)) ≥ 1− δ
where f(m) is a black-box objective function, Pr(C(m)) denotes the probability that a boolean constraint C(m) is satisfied and 1− δ is some user-specified minimum confidence that the constraint is satisfied (Gelbart et al., 2014). The constraint is that a latent point must decode successfully a large fraction of the times decoding is attempted. The black-box objective function is noisy because a single latent point may decode to multiple molecules when the model makes a mistake, obtaining different values under the objective. In practice, f(m) is one of the objectives described in section 2.3

heading: 2.5 EXPECTED IMPROVEMENT WITH CONSTRAINTS (EIC)
text: EIC may be thought of as expected improvement (EI),
EI(m) = Ef(m) [ max(0, η − f(m)) ] ,
that offers improvement only when a set of constraints are satisfied (Schonlau et al., 1998):
EIC(m) = EI(m) Pr(C(m)).
The incumbent solution η in EI(m), may be set in an analogous way to vanilla expected improvement (Gelbart, 2015) as either:
1. The best observation in which all constraints are observed to be satisfied. 2. The minimum of the posterior mean such that all constraints are satisfied.
The latter approach is adopted for the experiments performed in this paper. If at the stage in the Bayesian optimization procedure where a feasible point has yet to be located, the form of acquisition function used is that defined by (Gelbart, 2015)
EIC(m) = {
Pr(C(m)EI(m), if ∃m, Pr(C(m)) ≥ 1− δ Pr(C(m)), otherwise
with the intuition being that if the probabilistic constraint is violated everywhere, the acquisition function selects the point having the highest probability of lying within the feasible region. The algorithm ignores the objective until it has located the feasible region. It would also have been possible to adopt the methodologies of Rainforth et al. (2016); Mueller et al. (2017) under the assumption that the constraint is cheap to evaluate.

heading: 3 RELATED WORK
text: Gómez-Bombarelli et al. (2016b); Segler et al. (2017) constructed character-level generative models of SMILES strings using recurrent decoders. These models both suffered from the problem that they produced a high proportion of invalid SMILES strings. Blaschke et al. (2017) compared a range of autoencoder architectures in terms of their ability to produce valid molecules. Kusner et al. (2017); Dai et al. (2018) addressed the issue of generating valid molecules explicitly by imposing syntactic and semantic constraints using context free and attribute grammars while Janz et al. (2017); Guimaraes et al. (2017) leveraged additional training signal to enforce molecular validity.
A potential drawback of these methods is that the constraints may favour the generation of simple molecules. Simonovsky & Komodakis (2018); Li et al. (2018) build generative models of molecular graphs but do not impose any constraints for molecular validity. Jin et al. (2018) build a generative model of molecular graphs with constraints in order to achieve 100% validity. One possible disadvantage of this approach is that each molecule is assumed to be constructed from a fixed vocabulary of subgraphs and so it will be impossible to generate a molecule comprised of subgraphs outside this vocabulary. De Cao & Kipf (2018) use a graph-based generative model which enforces a quality constraint in the latent space. Direct comparison with the aforementioned methods is complicated due to the orthogonality of the assumptions made for each model. As such, we compare out method against Gómez-Bombarelli et al. (2016b) only.
Our principle contribution is in showing that valid molecules can be generated without encoding assumptions into the design model that limit the complexity and diversity of the generated molecules.

heading: 4 EXPERIMENT I: DRUG DESIGN
text: In this section we conduct an empirical test of the hypothesis from (Gómez-Bombarelli et al., 2016b) that the decoder’s lack of efficiency is due to data point collection in “dead regions” of the latent space far from the data on which the VAE was trained. We use this information to construct a binary classification Bayesian Neural Network (BNN) to serve as a constraint function that outputs the probability of a latent point being valid. Secondly, we compare the performance of our constrained Bayesian optimization implementation against the original model (baseline) in terms of the numbers of valid and drug-like molecules generated. Thirdly, we compare the quality of the molecules produced by constrained Bayesian optimization with those of the baseline model.

heading: 4.1 IMPLEMENTATION
text: The implementation details of the encoder-decoder network as well as the sparse GP for modelling the objective remain unchanged from (Gómez-Bombarelli et al., 2016b). For the constrained Bayesian optimization algorithm, the BNN is constructed with 2 hidden layers each 100 units wide with ReLU activation functions and a logistic output. Minibatch size is set to 1000 and the network is trained for 5 epochs with a learning rate of 0.0005. 20 iterations of parallel Bayesian optimization are performed using the Kriging-Believer algorithm in all cases. Data is collected in batch sizes of 50. The same training set as (Gómez-Bombarelli et al., 2016b) is used, namely 249, 456 drug-like molecules drawn at random from the ZINC database (Irwin et al., 2012).

heading: 4.2 DIAGNOSTIC EXPERIMENTS AND LABELLING CRITERIA
text: These experiments were designed to test the hypothesis that points collected by Bayesian optimization lie far away from the training data in latent space. In doing so, they also serve as labelling criteria for the data collected to train the BNN acting as the constraint function. The resulting observations are summarized in Figure 3.
There is a noticeable decrease in the percentage of valid molecules decoded as one moves further away from the training data in latent space. Points collected by Bayesian optimization do the worst in terms of the percentage of valid decodings. This would suggest that these points lie farthest from the training data. The decoder over-generates methane molecules when far away from the data. One hypothesis for why this is the case is that methane is represented as ’C’ in the SMILES syntax and is by far the most common character. Hence far away from the training data, combinations such as ’C’ followed by a stop character may have high probability under the distribution over sequences learned by the decoder.
Given that methane has far too low a molecular weight to be a suitable drug candidate, a third plot in Figure 3(c), shows the percentage of decoded molecules such that the molecules are both valid and have a tangible molecular weight. The definition of a tangible molecular weight was interpreted somewhat arbitrarily as a SMILES length of 5 or greater. Henceforth, molecules that are both valid and have a SMILES length greater than 5 will be loosely referred to as drug-like. This is not to imply that a molecule comprising five SMILES characters is likely to be drug-like, but rather this SMILES length serves the purpose of determining whether the decoder has been successful or not.
As a result of these diagnostic experiments, it was decided that the criteria for labelling latent points to initialize the binary classification neural network for the constraint would be the following: if the latent point decodes into drug-like molecules in more than 20% of decode attempts, it should be classified as drug-like and non drug-like otherwise.

heading: 4.3 MOLECULAR VALIDITY
text: The BNN for the constraint was initialized with 117, 440 positive class points and 117, 440 negative class points. The positive points were obtained by running the training data through the decoder assigning them positive labels if they satisfied the criteria outlined in the previous section. The negative class points were collected by decoding points sampled uniformly at random across the 56 latent dimensions of the design space. Each latent point undergoes 100 decode attempts and the most probable SMILES string is retained. J logPcomp(m) is the choice of objective function. The relative performance of constrained Bayesian optimization and unconstrained Bayesian optimization (baseline) (Gómez-Bombarelli et al., 2016b) is compared in 4(a).
The results show that greater than 80% of the latent points decoded by constrained Bayesian optimization produce drug-like molecules compared to less than 5% for unconstrained Bayesian optimization. One must account however, for the fact that the constrained approach may be decoding
multiple instances of the same novel molecules. Constrained and unconstrained Bayesian optimization are compared on the metric of the percentage of unique novel molecules produced in 4(b).
One may observe that constrained Bayesian optimization outperforms unconstrained Bayesian optimization in terms of the generation of unique molecules, but not by a large margin. A manual inspection of the SMILES strings collected by the unconstrained optimization approach showed that there were many strings with lengths marginally larger than the cutoff point, which is suggestive of partially decoded molecules. As such, a fairer metric for comparison should be the quality of the new molecules produced as judged by the scores from the black-box objective function. This is examined next.

heading: 4.4 MOLECULAR QUALITY
text: The results of Figure 5 indicate that constrained Bayesian optimization is able to generate higher quality molecules relative to unconstrained Bayesian optimization across the three drug-likeness metrics introduced in section 2.3. Over the 5 independent runs, the constrained optimization procedure in every run produced new drug-like molecules ranked in the 100th percentile of the distribution over training set scores for the J logPcomp(m) objective and over the 90th percentile for the remaining objectives. Table 1 gives the percentile that the averaged score of the new molecules found by each process occupies in the distribution over training set scores.

heading: 5 EXPERIMENT II: MATERIAL DESIGN
text: In order to show that the constrained Bayesian optimization approach is extensible beyond the realm of drug design, we trained the model on data from the Harvard Clean Energy Project (Hachmann et al., 2011; 2014) to generate molecules optimized for power conversion efficiency (PCE).

heading: 5.1 IMPLEMENTATION
text: A neural network was trained to predict the PCE of 200, 000 molecules drawn at random from the Harvard Clean Energy Project dataset using 512-bit Morgan circular fingerprints Rogers & Hahn (2010) as input features with bond radius of 2 using RDKit. If unmentioned the details of the implementation remain the same as section 4.

heading: 5.2 RESULTS
text: The results are given in Figure 6. The averaged score of the new molecules generated lies above the 90th percentile in the distribution over training set scores. Given that the objective function in this instance was learned using a neural network, advances in predicting chemical properties from data Duvenaud et al. (2015); Ramsundar et al. (2015) are liable to yield concomitant improvements in the optimized molecules generated through this approach.

heading: 6 CONCLUSION AND FUTURE WORK

heading: 6.1 CONTRIBUTIONS
text: The reformulation of the search procedure in the Automatic Chemical Design model as a constrained Bayesian optimization problem has led to concrete improvements on two fronts:
1. Validity - The number of valid molecules produced by the constrained optimization procedure offers a marked improvement over the original model. Notably, by applying constraints solely to the latent space of the variational autoencoder, the method does not require model assumptions that compromise either the complexity or the diversity of the generated molecules.
2. Quality - For five independent train/test splits, the scores of the best molecules generated by the constrained optimization procedure consistently ranked above the 90th percentile of the distribution over training set scores for all objectives considered. The ability to find new molecules that are competitive with the very best of a training set of already drug-like molecules is a powerful demonstration of the model’s capabilities. As a further point, the generality of the approach should be emphasised. This approach is liable to work for a large range of objectives encoding countless desirable molecular properties.

heading: 6.2 FUTURE WORK
text: Future work could investigate whether performance gains can be achieved through the implementation of a more accurate constraint model. Recent work by Blaschke et al. (2017); Polykovskiy et al. (2018); Tabor et al. (2018); Aumentado-Armstrong (2018); Sanchez-Lengeling & Aspuru-Guzik (2018) has featured a more targeted search for novel compounds. This represents a move towards more industrially-relevant objective functions for Bayesian Optimization which should ultimately replace the chemically mis-specified objectives, such as the penalized logP score, identified here.

heading: A TOY EXPERIMENT: THE BRANIN-HOO FUNCTION
text: The Branin-Hoo function will act as a toy problem on which to test the functionality of the algorithmic implementation for constrained Bayesian optimization. The particular variant of the Branin-Hoo optimization of interest here is the constrained formulation of the problem as featured in Gelbart et al. (2014). This Branin-Hoo function has three global minima at the coordinates (−π, 12.275), (π, 2.275) and (9.42478, 2.475). In order to formulate the problem as a constrained optimization problem, a disk constraint on the region of feasible solutions is introduced. In contrast to the formulation of the problem in Gelbart et al. (2014), the disk constraint is coupled in this scenario in the sense that the objective and the constraint will be evaluated jointly at each iteration of Bayesian optimization. In addition, the observations of the black-box objective function will be assumed to be noise-free. The minima of the Branin-Hoo function as well as the disk constraint are illustrated in Figure 7.
The disk constraint eliminates the upper-left and lower-right solutions, leaving a unique global minimum at (π, 2.275). Given that our implementation of constrained Bayesian optimization relies on the use of a sparse GP as the underlying statistical model of the black-box objective and as such is designed for scale as opposed to performance, the results will not be compared directly against those of Gelbart et al. (2014) who use a full GP to model the objective. It will be sufficient to compare the performance of the algorithm against random sampling. Both the sequential Bayesian optimization algorithm and the parallel implementation using the Kriging-Believer algorithm Ginsbourger et al. (2010) are tested.
A.1 IMPLEMENTATION
A Sparse GP featuring the FITC approximation, based on the implementation of Bui et al. (2016) is used to model the black-box objective function. The kernel choice is exponentiated quadratic with ARD lengthscales. The number of inducing points M was chosen to be 20 in the case of sequential Bayesian optimization, and 5 in the case of parallel Bayesian optimization using the Kriging-Believer algorithm. The sparse GP is trained for 400 epochs using Adam Kingma & Ba (2014) with the default parameters and a learning rate of 0.005. The minibatch size is chosen to be 5. The extent of jitter is chosen to be 0.00001. A Bayesian Neural Network (BNN), adapted from the MNIST digit classification network of Hernández-Lobato et al. (2016) is trained using black-box alpha divergence minimization to model the constraint.
The network has a single hidden layer with 50 hidden units, Gaussian activation functions and logistic output units. The mean parameters of q, the approximation to the true posterior, are initialized by sampling from a zero-mean Gaussian with variance 2din+dout according to the method of Glorot & Bengio (2010), where din is the dimension of the previous layer in the network and dout is the dimension of the next layer in the network. The value of α is taken to be 0.5, minibatch sizes are taken to be 10 and 50 Monte Carlo samples are used to approximate the expectations with respect to q in each minibatch. The BNN adapted from Hernández-Lobato et al. (2016) was implemented in the Theano library Theano Development Team (2016). The LBFGs method Liu & Nocedal (1989) was used to optimize the EIC acquisition function in all experiments.
A.2 RESULTS
The results of the sequential constrained Bayesian optimization algorithm with EIC are shown in Figure 8. The algorithm was initialized with 50 labeled data points drawn uniformly at random from the grid depicted. 40 iterations of Bayesian optimization were carried out.
The figures show that the algorithm is correctly managing to collect data in the vicinity of the single feasible minimum. Figure 9 compares the performance of parallel Bayesian optimization using the Kriging-Believer algorithm against the results of random sampling. Both algorithms were initialized using 10 data points drawn uniformly at random from the grid on which the Branin-Hoo function is defined and were run for 10 iterations of Bayesian optimization. At each iteration a batch of 5 data points was collected for evaluation.
After 10 iterations, the minimum feasible value of the objective function was 0.42 for parallel Bayesian optimization with EIC using the Kriging-Believer algorithm and 2.63 for random sampling. The true minimum feasible value is 0.40.
It is very likely that the parallel constrained Bayesian optimization algorithm experienced a serendipitous initialisation on the single run shown.
A.3 DISCUSSION
The Branin-Hoo experiment is designed to yield some visual intuition for the constrained Bayesian Optimization implementation in two dimensions before moving to higher dimensional molecular space. The results demonstrate that the implementation of constrained Bayesian optimization is behaving as expected in so far as the constraint in the problem is recognized and the search procedure outperforms random sampling.
It could be worth performing some investigation into how much worse the sparse GP performs relative to the full GP in the constrained setting. Another aspect that could be explored is the impact of the initialization.

Review summaries:
This paper proposes a novel method for generating novel molecules with some targeted properties. Many studies on how to generate chemically valid molecular graphs have been done, but it is still an open problem due to the essential difficulty of generating discrete structures from any continuous latent space. From this motivation, the 'constrained' Bayesian optimization (BO) is applied and analyzed. Posing 'constraints' on the validity is realized by probability-weighting onto the expected improvement scores in BO. The 'validity' probability is learned beforehand by Bayesian neural nets in a supervised way. As empirical evaluations, two case studies are presented, and quality improvements of generated molecules are observed.