Introduction

Degradation of metallic components by corrosion has been a long-standing problem in metallurgy and construction1, with annual worldwide economic losses being estimated to be USD 2.5 trillion2. The availability of corrosion-resistant alloys, therefore, plays a crucial role in sustaining not only the longevity but also the safety and integrity of key engineering applications including energy conversion systems, nuclear waste disposal, bio-medical implants, civil infrastructures, food industry, and transportation industries to name but a few sectors3. The design of alloys that are inherently resistant to dangerous forms of localized corrosion (such as pitting), that can lead to catastrophic part failure, is essential in many applications.

The essential characteristic of such alloys is their ability to form protective, passive oxide films on their surface which are adherent, robust for inhibiting corrosion, and resistant to localized failure by pitting4,5. Systematic investigations have been carried out over the last decades to understand the role of different compositional and microstructural characteristics on the passive film formation and stability in different alloys6,7,8. Microstructural homogeneity (preferably single-phase microstructures)9, second-phases with tailored galvanic potentials10, defect-free passive oxide film formation11, and higher reactivity of salt films relative to the passive oxide film7,12 are among the properties identified to be most important for improved corrosion resistance. However, alloys such as ferritic/austenitic stainless steels, Ni-Cr alloys, and Al alloys, which exhibit superior corrosion resistance properties, have been in use for many years before the underlying protection mechanisms were identified. Their applicability was realized often by accident, intuition, experience, and trial and error experimentation. It has been understood only in hindsight that their superior properties come from the above-mentioned phenomena.

While our advanced scientific understanding of the phenomenon of passivation has allowed the development of a rigorous evaluation scheme for determining the corrosion resistance of a newly developed alloy grade, it does not provide a method to predict suited alloy compositions with desired corrosion resistance properties3. Reliable rules do not exist for predicting the corrosion resistance properties as a function of alloying additions. Consequently, we still have to rely on trial-and-error experimentation and experience to design new alloys that can exhibit the required corrosion resistance in different applications, specifically, under different chemical environments. Empirical design parameters such as the pitting resistant equivalence number (PREN) have been developed for specific alloy classes such as austenitic stainless steels13. However, the scope and applicability of such empirical design parameters seem severely limited in view of the vast parameter space of possible alloy compositions and environmental conditions. With the advent of high entropy alloys, which seem to show promising corrosion resistance14,15, the compositional parameter space has expanded drastically. Thus, it is clear that both, trial and error experimentation and the available design parameters are not the best strategies to design optimal alloy compositions. Moreover, reaching increasing levels of circularity in alloy production is inevitable in the long run, which translates into having increasing amounts of tramp elements in commercial alloys16,17. There exists no framework at hand, that can inform us of the qualitative/quantitative influence of such elements.

Machine learning-based methods exploiting the large amounts of already measured/existing data have shown tremendous potential to expedite the tedious trial and error processes and accelerate materials discovery/evaluation in several applications18,19,20. This has been facilitated by the mechanisms offered by these methods, beyond conventional statistical approaches, that automate the process of hypothesis generation, case-based and instance-based reasoning21. However, the efficacy of traditional machine learning algorithms including support vector machines, random forest, k-nearest neighbors, conventional (shallow) neural networks and others depends on painstakingly created handcrafted features. This tedious process of manual feature engineering has been greatly alleviated with the advent of deep learning/deep neural networks with their capability to automate this process of feature extraction and training22,23.

In the area of corrosion research, machine learning models have been significantly used lately, primarily as a tool for modeling/predicting the behavior of individual materials systems in specific experimental conditions24. Some examples include works predicting the atmospheric corrosion rate of steels25,26, high temperature oxidation of alloys27,28, interpreting electrochemical impedance spectroscopy data29 and understanding corrosion in the presence of inhibitors30,31. However, machine learning has not been exploited, to our knowledge, as a tool for alloy design in general. The need for the same has nevertheless been recognized by the corrosion community, marked by the recent publication of the dataset on the corrosion-relevant electrochemical metrics of a wide range of passivating alloys32.

As a step in this direction, here we employed a deep learning method and developed a framework that helps understand the individual and mutual contributions of alloying elements to localized pitting resistance in a wide range of alloys. This knowledge could facilitate the efficient discovery of corrosion-resistant alloys. For this purpose, we first trained the deep neural network algorithm over the pitting potential dataset to solve a regression problem (predicting the pitting potential for a given set of environmental conditions and alloy composition across all of the included alloy classes). We then performed a multi-dimensional gradient descent optimization over the trained deep neural network to arrive at compositions across different alloy classes that could be increasingly resistant to pitting.

Results and discussion

Training

The mean absolute error of network predictions on the training and testing dataset (termed ‘loss’ and ‘validation loss’, respectively) as a function of training history were evaluated for all the 6 random dataset splits (i.e. the sixfolds). Both loss measures were observed to evolve in a similar manner in all cases. A representative result corresponding to 10,000 epochs of training is presented in Fig. 1. A validation loss close to 170 mV has been obtained at the end of training, i.e. at the final epoch (Fig. 1a). Further, the R-square coefficient (averaged over the sixfolds) turned out to be 0.61 ± 0.04. The negligible difference between the training and validation losses over the course of training history (Fig. 1a) implies that no overfitting occurs. This is attributed to the use of a dropout fraction of 0.5 at each layer in the network.

Fig. 1: Results of deep neural network training.
figure 1

a Mean absolute error in pitting potential of network predictions on the training and testing datasets (termed as loss and validation loss respectively) in course of training history. b Plot of the DNN predictions over the test dataset after training. c Absolute prediction errors of pitting potential (both the mean and distribution in the form of 95% confidence limits) from the trained DNN model within each alloy class are plotted in black along the axis on the left. The statistical representation of each alloy class within the training and test dataset is represented by the bar chart in blue along the axis on the right.

Mean of the absolute errors in predictions of the trained DNN model over the test data within each alloy class along with their respective distributions (in the form of their 95% confidence limits) are shown in (Fig. 1c) In addition, the statistical representation of each alloy class in the training and test datasets is plotted in the form of a bar chart. It can be seen that the model performance (both in terms of the mean of the absolute errors and error uncertainty) is better for NiCr-based, miscellaneous and Fe-based alloys as compared to Al-based and high entropy alloys. This can be understood on the basis of the amount of data and the compositional variation existing within the data for each alloy class. For example, the high entropy alloys class can be seen to have a relatively much smaller statistical representation within the dataset. Consequently, the training data is not sufficient to capture the variation offered by the large and diverse composition space within the high entropy alloys, making the test errors high and also uncertain. In case of Al-based alloys class, although it has a considerably larger statistical representation within the dataset, the corresponding compositional variation within the data is also higher than in other material classes. There exist different binary alloy systems within the Al-based alloy class, such as Al-Cu, Al-Mg, Al-Si etc. each of which have their own characteristic corrosion properties. In other words, because of different precipitates, second phases and their respective galvanic potentials, each of the Al-based binary alloy systems functions like a distinct material class of its own within the broad Al-alloys class. This could be the reason for the poor test accuracy within the Al-based alloys class. On the contrary, Fe-based and NiCr-based alloys data is primarily composed of compositions belonging to one broad ternary/quaternary system with their property being a function of minor alloy additions of N, Mo, W etc. Consequently, the amount of available training data is reasonably sufficient, resulting in higher test accuracies.

Maximizing pitting potential using the trained DNN

The pitting potential was first maximized with respect to the entire composition and test-specific parameter space. The increasing pitting potential (i.e. increasing resistance to pitting) as a function of the optimization iterations, for different representative initial input conditions, has been plotted in Fig. 2. The most significant variation in the input-feature space causing an increase in the pitting potential was observed to be due to a decrease in the chloride ion concentration. The corresponding variations in the chloride ion concentrations as a function of the optimization iterations for the same initial input conditions are plotted in Fig. 2b. Changes in the alloy composition in the initial iterations until the chloride ion concentration dropped to zero were rather negligible (less than 0.5 wt. %). The deep neural network can thus be seen to have ‘learned’ the significantly detrimental effect of chloride ions on the resistance of passive films towards pitting in all alloys. Due to the decreasing trend of chloride ion concentration during optimization, it does not require any extrapolation beyond the training data (consisting of chloride ion concentrations in the range of 0–4 molar).

Fig. 2: Effect of chloride ion concentration.
figure 2

Variation in pitting potential (target variable) during the optimization, starting from different initial conditions and the corresponding change in chloride ion concentrations during the respective optimization sequence (the legend is applicable for both plots).

Maximizing pitting potential under constant chloride concentration conditions

To identify composition variables (i.e. alloying elements) that are most effective in improving the pitting-resistance of alloys, maximization of the pitting potential was carried out with the exclusion of the chloride ion concentration variable from the optimization variables, i.e. keeping the chloride ion concentration constant as in the respective initial conditions during optimization. The results of such optimization sequences, with different initial conditions, are presented in Fig. 3. Representative initial compositions from each alloy class have been randomly chosen for this purpose. Due to the complexity involved with the 23-dimensional composition-variable space, only those parameters which exhibited significant variations during the optimization are discussed here. All other elements (not shown in the plots) exhibited a variation below 0.5 wt. % (with respect to their respective values in the initial alloy composition) during the entire optimization sequence. Major alloying elements in each of the alloy and the solution pH have been shown in all cases regardless of their magnitude of variation during optimization.

Fig. 3: Compositional change during different optimization sequences carried out while keeping the respective chloride ion concentrations fixed.
figure 3

The initial conditions for each optimization sequence have been indicated. a Fe-25Cr-4Ni-4Mo ferritic stainless steel. b FCC Ni-28Cr-5Mo alloy. c Al-4.5Cr alloy. d FCC Ni-20Fe-20Cr-20Co high entropy alloy and e FCC equiatomic Fe-Ni-Cr-Co high entropy alloy.

The striking feature that can be seen in all the optimization sequences in Fig. 3 is that the interstitial alloying elements (i.e. either one or both of C and N) exhibit an increasing trend in all alloy classes. N can be observed to be rapidly increasing in the stainless steel, Ni-Cr alloy and Al-Cr alloy (Fig. 3a–c) while C can be seen to be particularly important in the Ni/Co containing high entropy alloys (Fig. 3d, e). These interstitial elements, with their highest rate of change in comparison to all other alloying elements, thus turn out to be the most effective elements in increasing the pitting resistance of alloys belonging to all the classes tested. In other words, the DNN model trained over the current dataset primarily points us in the direction of working towards maximizing the interstitial content within the different broad alloy classes, rather than any other substitutional alloying element, to most effectively improve their corrosion resistance.

It must be taken into account that the artificial intelligence approach does at this stage not take the respective solubility limits of these interstitial atoms in the respective alloys into consideration. This has not been part of the present training information. Exceeding the solubility limits could lead to the formation of carbides or nitrides, respectively, which in turn could worsen the pitting potential, due to the formation of additional local galvanic elements. That is, the artificial intelligence approach used in this section can essentially detect this trend of improvement of the pitting potential by these elements, but not their thermodynamic solubility limits. However, this secondary alloy design aspect can be readily supplemented by further training based on corresponding thermodynamic data. Also, below we show that the prediction ranges regarding the alloys’ compositional variation can be confined to the composition ranges covered by the training data, so as to avoid thermodynamically unreasonable extrapolations. Further details of this aspect are discussed below.

In addition, the optimization results presented in Fig. 3 also reveal the existence of coordinated transitions in the rate of change of some of the feature-space variables during the optimization sequences. For instance, the change in the slope of the increasing Mo content in the stainless steel and the NiCr-based alloy (i.e. at around 220 and 400 optimization steps in Fig. 3a, b, respectively) can both be seen to be correlated with decreasing pH value. In addition, this transition in the Ni-Cr-Mo alloy (Fig. 3b) can also be seen to be accompanied by an increase in the slope of the N content. A similar correlation in slope-transitions of C and Co contents can be seen in (Fig. 3e).

Maximizing pitting potential only in composition space

In the next set of optimization sequences, maximizing the pitting potential has been carried out while varying composition parameters alone and maintaining the test/specific parameters including chloride ion concentration, pH, and test temperature constant at their respective initial conditions. An additional restriction of not extrapolating the compositions beyond the respective limits of each of the parameters within the training dataset has been imposed. With the maximum C and N contents in the training dataset being 0.2 wt. % and 0.8 wt. % respectively, this serves as a severe restriction for the interstitial elements, in comparison to the values predicted in the previous optimization sequences (Fig. 3). This was done to see if such a restriction triggers the substantial increase of any other substitutional element during optimization. The same sets of the initial compositions considered in (Fig. 3) have been utilized. The results of these optimization sequences are presented in (Fig. 4).

Fig. 4: Compositional change during different optimization sequences carried out while keeping the test-specific parameters fixed and not allowing N or C composition extrapolation beyond the training data.
figure 4

The initial conditions for each optimization sequence have been indicated. a Fe-25Cr-4Ni-4Mo ferritic stainless steel. b FCC Ni-28Cr-5Mo alloy. c Al-4.5Cr alloy. d FCC Ni-20Fe-20Cr-20Co high entropy alloy and e FCC equiatomic Fe-Ni-Cr-Co high entropy alloy.

The results can be seen to be qualitatively similar to those presented in Fig. 3, but also reveal some important differences. Firstly, despite the strong restriction on the maximum interstitial element content during optimization, the variation in substitutional element contents in all cases is largely similar to that in Fig. 3. No rapid increase in any of the substitutional elements has been triggered. The interstitial element content variations are also similar to that in Fig. 3, in the sense that they can be seen to rapidly increase at the beginning of the optimization, and reach their respective imposed limits. However, this is true only for the N increase in the stainless steel (Fig. 4a) and Al-Cr alloy (Fig. 4c), and the N or C increase in the high entropy alloys (Fig. 4d, e). On the contrary, the Ni-Cr alloy (Fig. 4b) can be seen to deviate from such a behavior, with the N composition during optimization increasing only marginally and remaining distinctly lower than the imposed N concentration limit. This indicates that the extent to which N alloying can improve the pitting resistance in this alloy is especially dependent on the pH value, which has not been allowed to vary during these optimization sequences.

Another distinct difference in comparison to the results in Fig. 3 is that the slope change corresponding to an increase in Mo content in Fig. 3a, b are absent in the corresponding Fig. 4a and b, respectively, where no pH variation is permitted. This indicates that the slope changes of Mo in the stainless steel and in the Ni-Cr alloy observed in the former set of optimizations are indeed correlated with decreasing pH values. In other words, it can be inferred that while Mo generally increases the pitting resistance in stainless steels and Ni-Cr alloys, it is increasingly effective in acidic environments.

Cr content optimization in Fe-Cr and Ni-Cr alloys

Cr is one of the most important alloying elements in Fe-based (stainless steels) and Ni-based alloys exhibiting passivation characteristics. Critical amounts of Cr close to 12 at. % and 15 at. % are required to achieve effective passivation in the two alloy systems, respectively33,34. Here, we evaluate if the network effectively learned this critical transition in corrosion resistance with Cr content in the two alloy systems. For this purpose, maximizing the pitting potential was carried out, with pure Fe and pure Ni respectively as the initial compositions, while allowing variation of the Cr content alone during optimization. The results are presented in Fig. 5. In the course of the optimization sequence, transitions in the pitting potential from largely negative to largely positive values can be observed in both the Fe-Cr and Ni-Cr alloy systems at 12 wt. % and 15 wt. % Cr, respectively. This implies that the trained network has indeed successfully learned the active-passive transition of these alloys at their respective critical Cr contents.

Fig. 5: Optimizations allowing variation of Cr content alone.
figure 5

Variation of Cr content and pitting potential during optimization history have been plotted. Initial compositions are a pure Fe c pure Ni. The pitting potential predicted by the trained network as a function of Cr content is plotted for b BCC Fe-Cr alloys and d FCC Ni-Cr alloys. The active-passive transitions at the respective critical Cr contents in both the alloy systems can be seen to have been successfully predicted by the trained network.

However, lack of any significant variation in the pitting potential of Ni-Cr alloys up to the critical Cr content of 15 wt. %, followed by the extremely sharp transition, as predicted by the model can be seen as artificial. This could have arisen due to the limited training data for Ni-based alloys in the pertinent composition range.

Compositional correlations predicted by the trained DNN and understanding from literature

The above-identified features of the compositional trajectories evolving during the different optimization schemes can be seen to be in agreement with known correlations between composition and the corrosion resistance of alloys. The ability of the network to learn the active-passive transition in Fe-Cr and Ni-Cr alloy systems at the respective critical Cr contents (Fig. 5) is significant. In relation to the increasing interstitial N or C content during optimization, the presence of N is known to significantly improve the corrosion resistance of stainless steels. In fact, N has the strongest weighting coefficient in the PREN of the stainless steels13. Mo, which is shown to increase the pitting potential in Figs. 3 and 4, is also known to enhance pitting resistance in stainless steels7,35 and NiCr-based alloys36,37. In particular, detailed investigations have revealed that Mo is particularly effective in improving the pitting resistance in acidic environments. In fact, a synergistic effect of Mo and N addition has been shown to improve pitting resistance in acidic environments38. Correlation in the slope-transition for Mo increase with a decreasing pH value during optimization (Fig. 3) and absence of such a slope change when pH variation is not allowed (Fig. 4a) is in agreement with this understanding. The optimizations carried out with and without allowing pH variation indicate a similar pH dependence (Figs. 3b and 4b respectively) for the beneficial influence of interstitial N in NiCr-based alloys. It is interesting to note that while acidic environments are usually detrimental for pitting resistance, the network predicts a decrease in pH for specific alloy compositions (Fig. 3a, b and e). This is because the multi-dimensional gradient descent algorithm attempts to optimize all the feature space variables simultaneously. The decreasing pH predicted in these cases is specific to those alloy compositions (with Mo and N) and should not be interpreted to be a general trend.

Experimentally unverified predictions—assessing their applicability

The ability of the network to learn the above-mentioned experimentally known correlations (i.e. the role of N or Mo in stainless steels and Mo in Ni-Cr alloys) is motivating and justifies the necessity to pursue experimental investigations to verify some of the unknown predictions (i.e. large N or C contents in Ni-Cr alloys and transition metal high entropy alloys). However, the results of optimization, especially in terms of the large N or C contents predicted (Fig. 3), must be interpreted with caution. For instance, the beneficial influence of increasing bulk N contents in stainless steels (as given by the PREN) is known to be restricted by the solubility limit of N in the matrix, as briefly discussed above. Precipitation of N-enriched second phases beyond the critical N content leads to a deterioration of corrosion resistance in those alloys39. The dataset employed herein primarily consists of N contents within the solubility limit. Therefore, due to lack of training data beyond the N-solubility limit, it is reasonable that the DNN model is unable to learn the deleterious effects of excess N-induced precipitates. Highly exaggerated amounts of N content, much beyond the solubility limit, are thus predicted upon optimization without restrictions (Fig. 3).

Nevertheless, the results of optimization with restriction on interstitial content extrapolation (Fig. 4) confirm the fact that the beneficial influence of interstitial N or C content far outweighs any other substitutional element in the respective alloys. This follows from the observation that despite this restriction, no substantial increase in any other substitutional element is predicted, beyond that predicted in the unrestricted optimization (Fig. 3). Thus, the very high rate of change in N or C content predicted by the optimization sequences could be considered as a direction for alloy design. It provides motivation to work on developing strategies, especially for the relatively unexplored transition-metal high entropy alloys, which can introduce large amounts of N or C, much beyond the solubility limit, into solid solution.

For instance, in stainless steels, such large N or C supersaturations can be achieved by low-temperature/plasma-based thermochemical treatments (such as nitriding/carburizing). Experimental investigations show that controlled nitriding/carburizing treatments of austenitic/PH stainless steels can lead to a so-called colossal supersaturation of N or C, without triggering secondary phase precipitation40,41. The austenite phase formed with the colossal N or C -supersaturation, also called the N-expanded or C-expanded austenite, is in fact known to exhibit superior corrosion resistance (pitting resistance in particular) in comparison to conventional austenitic stainless steels39,42. While the physical basis behind this is not fully understood39, a recent work43 has shown that large interstitial C contents in solid solution can drastically increase the covalent character of bonds between matrix elements. This is expected to reduce the metal dissolution rate in a pit environment. Based on the predictions of the optimization for similar effects of N or C in other alloy systems (such as NiCr-based alloys and transition metal high entropy alloys), strategies to develop N or C-supersaturated solid solution phases in these systems could turn out worthwhile44,45,46.

The improvement in pitting resistance of both the N-expanded and C-expanded austenite is governed by the extent of metastable N or C-supersaturation (upon suppression of carbide/nitride phases) that can be achieved. This extent of supersaturation is governed strongly by the substitutional alloy composition. CALPHAD based models have been developed to quantitatively estimate such a metastable N or C supersaturation that can be attained for a given alloy composition during low-temperature thermochemical treatments47,48. Figure 6 shows the limits of such N or C supersaturation as a function of composition, calculated for the representative austenitic stainless steels, austenitic (FCC) NiCr alloys, and FCC FeCrNiCo high entropy alloys. The methodology for the calculations (explained in detail in the ref. 47) essentially involves estimating the N or C content in the solid solution phase necessary to realize an equivalence of N/C chemical potential with the nitriding/carburizing atmosphere. Formation of equilibrium nitrides/carbides and any variation in substitutional element content is suppressed, making the estimated N solubilities metastable in nature.

Fig. 6: Maximum allowed metastable N or C supersaturation by suppressing nitrides/carbides in different alloys (with compositions in at. %).
figure 6

a Austenitic Fe-xCr-10Ni alloy. b FCC Ni-xCr alloy. c Austenitic Fe-20Cr-xNi alloy. d FCC Fe-20Cr-20Ni-xCo high entropy alloy. Calculated for typical nitriding/carburization conditions at 450 °C using N activity of 3 × 10−4 and C activity of 1 (with respect to standard element reference state (SER)). Commercially available thermodynamic databases (TCFE11 for steels and TCHEA4 for other alloys) along with the Thermo-Calc v. 2021(b) software package have been used for the calculations.

It can be seen that increasing amounts of Cr facilitate higher extents of N or C supersaturation in all the alloy systems. On the contrary, Ni and Co have the opposite influence. In particular, the N supersaturation limit can be seen to decrease very rapidly with increasing Ni and Co contents in comparison to C. In other words, the thermodynamic calculations imply that Ni and Co prefer C in solid solution in comparison to N. This is in line with predictions from the optimization sequences. Figure 3 shows increasing C content (either alone or together with N) in high Ni/Co containing high entropy alloys, as opposed to the predominantly increasing N content in the high Cr-containing stainless steels and NiCr-based alloy. In summary, compositional predictions arrived at using the trained DNN model consist of several features that corroborate existing knowledge from corrosion research. At the same time, the predictions also offer thermodynamically reasonable, definite design guidelines that can direct actual experimental efforts for developing effective corrosion-resistant alloy compositions. Development of alloy compositions and strategies capable for achieving large interstitial N or C supersaturation could be considered as a direction for corrosion-resistant alloy design from the current work.

Methods

Dataset description and adaptation

We have utilized an open-source data base on the corrosion-relevant electrochemical metrics for metals and alloys published recently32. It consists of a compilation of a total of 1274 records spanning over 8 corrosion metrics (pitting potential, repassivation potential, corrosion current density, passive current density, corrosion potential, crevice corrosion potential, pitting temperature and crevice corrosion temperature) and 5 alloy classes (Fe-based, Al-based, NiCr based, high entropy alloys and other miscellaneous alloys). In this work, we have only used data pertaining to the pitting potential (reported with respect to the standard calomel electrode potential (SCE)). This has been chosen considering the enormous importance of pitting as one of the most critical forms of localized corrosion. The dataset consists of 810 records (obtained from 85 literature ref. 32) spanning over all five alloy classes. The feature space in the dataset can be broadly divided into two categories, namely material-specific variables and electrochemical test-specific variables. The former includes the major alloy classes, alloy composition (24 elements, all in wt. %), microstructural information (in terms of the major matrix phase, precipitate distribution, etc.), and alloy processing conditions. On the other hand, test temperature, chloride ion concentration, pH value of the test solution and the test method applied are the documented electrochemical test-specific variables.

For training the deep neural network towards solving the regression problem, it is essential to have numerical input. All the 23 independent compositional variables, test temperature, pH, and chloride ion concentration of the test solution, being numerical in nature, were taken as such. However, the categorical input features such as microstructural characteristics and alloy class were transformed into numerical features by simply replacing each category within a feature with a unique positive integer. Such a transformation was particularly used in preference to other methods such as one-hot encoding due to the relatively small size of the dataset and a tremendous increase in input-dimensionality that would be introduced by one-hot encoding [There are 5 categories (alloy classes) within the material class feature and the microstructural information feature was divided into 8 categories. One-hot encoding would replace two of these features with 13 new features]. The test method, scan rate and details of alloy processing, as documented in the dataset being used, consist of textual information with significant variation. In order to transform this into numerical data, an elaborate natural language processing (NLP) based approach involving text vectorization, followed by word embedding and encoding would be essential. In this first attempt to develop a machine-learning based model, such a complication has been avoided and thus these features were not included for training. The missing values in the dataset have been treated as follows. In the case of major alloying elements such as Ni, Mo, W, C, and N, missing values were replaced with values compatible with the commercial alloy grade mentioned in the comments. Missing values of S, P, Mn, and Si (elements that are not added intentionally for alloying in most cases) were replaced by their respective most frequently occurring values. Missing values in others were replaced by zero. Samples reported as ‘transpassive’ instead of having an exact value for the pitting potential were omitted from the database. The adapted dataset which includes 769 records, was divided into the training and testing datasets in a 4:1 ratio, while ensuring random sampling in both. The random sampling is reflected by the fact that data instances from all material classes are represented in the training and test datasets with the same probability as in the original dataset.

Network description and training

The deep neural network (DNN) has been implemented, trained, and tested using Keras49, an application programming interface (API) written in Python, running on top of the machine learning platform TensorFlow50. A simple fully connected deep neural network with the following structure was arrived at, after performing hyperparameter tuning by manual trial and error [The different hyperparameters varied and their ranges in all the trials include number of hidden layers (varying from 2 to 4), number of nodes in the hidden layers (varying from 16-256), activation functions (ReLU, sigmoid, tanh and leaky ReLU) and dropout fraction (0.1–0.6). The network finally used had shown the optimal combination of minimum error and computational time required for training.]. The network has one input layer of size 28, followed by 3 hidden layers of sizes 64, 64, and 32 respectively followed by an output layer of size 1 (Fig. 7). For the hidden layers we have used the ReLU activation function, and also initialized all the weights in conjunction with the glorot uniform initializer51 and the biases set to zero. The Adam optimization algorithm52 was used during training with a step size (learning rate) of 0.001. Given the small size of the available dataset, we also included a dropout fraction of 0.5 for each of the hidden layers to combat overfitting. The DNN model was trained 6 times, each time using a different random dataset split (i.e. 6-fold cross validation).

Fig. 7
figure 7

Schematic representation of the fully connected deep neural network structure (with a dropout fraction of 0.5 for each hidden layer) used for training.

Optimization

After training, multi-dimensional optimization within the input parameter space was performed to maximize the pitting potential using the gradient descent method53. It is worth noting that the maximization of the pitting potential refers here to property improvement, i.e. to an alloy’s increasing resistance to pitting. To obtain the gradient of the output with respect to the inputs, we have relied on the automatic differentiation method (AD)54 which is already implemented in the Tensorflow package (https://www.tensorflow.org/guide/autodiff). Indeed, AD is the central principle behind some machine learning algorithms such as backpropagation, where the derivative of the loss function is calculated with respect to the weights and biases of the network55. In this work, we have gone beyond the derivatives with respect to weights and biases, and calculated the derivatives with respect to the inputs as well; this is equivalent to one more step of backpropagation where the derivatives are made with respect to the activation of the input layer. For convenience and reproducibility purposes, we have created an augmented version of the Keras model class, which is exactly like the default Keras model class but augmented with an additional method that returns the Jacobian of the network. We refer to this class as AugNet, and it can be used: (i) to create, compile, and train a network from scratch, or (ii) to load a trained network (which does not necessarily need to be an AugNet itself). The implementation of this class, together with its installation, two minimal examples, and performance analysis, is available in the Github repository56. In all the gradient descent optimizations, a step size (learning rate) of 0.0001 was used.