. Here we present an organic synthesis robot that can perform chemical reactions and analysis faster than they can be performed manually, as well as predict the reactivity of possible reagent combinations after conducting a small number of experiments, thus effectively navigating chemical reaction space. By using machine learning for decision making, enabled by binary encoding of the chemical inputs, the reactions can be assessed in real time using nuclear magnetic resonance and infrared spectroscopy. The machine learning system was able to predict the reactivity of about 1,000 reaction combinations with accuracy greater than 80 per cent after considering the outcomes of slightly over 10 per cent of the dataset. This approach was also used to calculate the reactivity of published datasets. Further, by using real-time data from our robot, these predictions were followed up manually by a chemist, leading to the discovery of four reactions. Recent progress in automated chemistry 9, 10 , online analytics 11 and real-time optimization 12 suggests that it is possible to construct a robot that can autonomously explore chemical reactivity. With this in mind, we have designed, built and programmed a bespoke chemicalhandling robot comprising in-line spectroscopy, real-time data analysis and feedback mechanisms (Fig. 1a, b) . The robot is configured to execute six experiments in parallel, allowing up to 36 experiments to be performed per day. To evaluate the outcome of a reaction, the robot is equipped with real-time sensors-a flow benchtop nuclear magnetic resonance (NMR) system 13 , a mass spectrometer and an attenuated total-reflection infrared spectroscopy system 14 -to record the spectra of the reaction mixtures. Then, it uses an algorithm to automatically classify the reaction mixtures as reactive or non-reactive, which is reported in binary form as zero or one, using a supported vector machine 15 (SVM) with a linear kernel (Fig. 1c) model. This algorithm compares the spectrum of the starting materials with that recorded by the robotic platform using NMR and infrared spectroscopy, registering differences as reactivity hits (see Fig. 1e for an example of a non-reactive mixture and Fig. 1f for a reactive mixture) . By training the model on 72 reactive and non-reactive mixtures manually classified by an expert chemist, the model could classify the reactivity of reaction mixtures with an accuracy of 86%, as determined by leave-one-out cross-validation. The machine learning algorithm used to explore the chemical space needs an automatically generated representation of the reactions 16 . Because the representation of the data is crucial for machine learning 17 , we created a reaction descriptor with a width corresponding to the number of starting materials in the pool of reagents and with bits representing reagents that were present in a given reaction mixture to one, similarly to one-hot encoding. Figure 1d shows example vector representations for the model substrate pool consisting aniline, benzaldehyde, acetyl chloride, phenylhydrazine and furan. This approach to representing chemical space renders it structureindependent and allows the robotic platform to operate without prior knowledge about reactivity and chemical structure (Fig. 2) . Initially, the chemical space was sampled by performing reactions with random combinations of starting materials, evaluating their reactivity as reactive or non-reactive using the SVM model (to determine expected values of reactivity, Y) and encoding them in vector form (to obtain a training set, X). The process of random selection is important because the system avoids making prior assumptions about the possible reactivity of the reagents, ensuring that the initial run results are unknown. Even if the reaction mixture decomposes or is non-reactive, this information is still useful for the navigation of the chemical space, allowing real-time assessment of the reactivity of the starting materials. After the reaction database has been built, a linear discriminant analysis (LDA) 18 model is trained on the data obtained to construct a model of the chemical space. The remaining reactions are then rated by predicting the probability of reactivity using the LDA model. This allows for autonomous decision making, and the reaction with the highest score is performed and analysed by the robotic system, thus avoiding many non-reactive combinations and speeding up the search. The loop is closed by updating the reaction database with the result of the last experiment from the platform and then by retraining the LDA model of the chemical space. The cycle is repeated until the required number of reactions is performed or until the whole space-defined by a pool of 18 reactive, structurally diverse molecules containing functional groups 1-18 (Extended Data Fig. 1 )-is spanned. The chemical space constituted of two-and three-component reactions formed from the pool of starting materials, giving 969 possible experiments. When LDA was performed, the algorithm was able to clearly differentiate between reactive and non-reactive combinations of the starting materials (Fig. 3a) . This means that the LDA can be useful for predicting new reactivity. By taking this approach, we showed that the robot can learn how reactive the starting materials are and efficiently navigate chemical space. For example, the reaction mixture composed from 2-aminothiazole (9), phenylacetyl chloride (15) and DBU (13) would be classified as highly reactive, a mixture of malononitrile (3), methylacetoacetate (18) and DBU (13) as moderately reactive and a mixture of nitromethane (4), benzofuroxan (7) and toluenesulfonylmethyl isocyanide (17) as non-reactive. These assignments agree with basic chemical intuition, demonstrating the predictive power of the model (see Supplementary Information for the reactivity of all reactions according to the LDA projection). To further test the learning ability of our robotic system, we performed simulations to calculate the number of reactive versus nonreactive combinations of the starting materials chosen by the algorithm during the exploration of the chemical space (Fig. 3b) . In the initial stage, the space was randomly sampled, resulting in an equal number
On the other hand, Granda et al. REF used random combinations of starting materials to perform reactions and then used AI to search for new reactivity within the chemical space.
Controlling an organic synthesis robot with machine learning to search for new reactivity
Nature
Nature
Medicine