## 2 Forecasting Model for Nutrient Deficiency Identification and Data Pre-Processing
### Training and Validation Dataset  
Like other crops, tomato plants need to be supplied with adequate minerals and micronutrients to avoid diseases. As mentioned above, in order to generate the expression of symptoms of nutritional deficiencies, such as Calcium, Potassium, and Nitrogen deficiencies, in the leaves and fruits of tomato, we carried out this study under greenhouse conditions. A digital camera and smartphone camera were used to collect images of each nutrient deficiency symptom, as shown in Figure 2. As can be seen from Figure 1, the lack of nutrients can be observed during the early stage symptoms of deficiency in leaves and fruit. To create a database for training the AI model, we relied on the distinctive signatures between the investigated substances, which included Calcium, Potassium, and Nitrogen. Calcium deficiency is mostly expressed on the tomato fruit; Potassium deficiency appears earlier on leaves, and on the fruit in the middle stage; and finally, Nitrogen shortage is shown on the leaf. Based on the characteristics of the nutrient deficiency. We labeled each observed mineral nutrient as follows: number zero for Calcium, number one for Potassium, and number two for Nitrogen.  
In Table 1, the total number of captured images collected by the proposed system for the three different macronutrients can be seen. The database consisted of 571 images, which were grouped into two parts, with 80% of the dataset (461 images) being used for training and 20% (110 images) being used for validating the performance of the two models. Three macronutrients, i.e., Calcium, Potassium, and Nitrogen, were considered as the subjects of monitoring and identification during the growth of the tomato plants.  
\begin{table}
\begin{tabular}{c c c c} \hline \hline
**Mineral Nutrient** & **Training** & **Validation** & **Total** \\ \hline Calcium (Ca\({}^{2}\)) & 244 & 61 & 305 \\ Potassium (K\({}^{+}\)) & 105 & 26 & 131 \\ Nitrogen (N) & 112 & 23 & 135 \\ Total & 461 & 110 & 571 \\ \hline \hline \end{tabular}
\end{table}
Table 1: Summary of the dataset used for training and validation in this study.  
Figure 2: The symptoms of nutrient deficiency. (**a**) Calcium deficiency; (**b**) Potassium deficiency; (**c**) Nitrogen deficiency. The raw images were collected under different environmental conditions.  
Each image in the database is labeled according to the development stage of each selected nutrient to be tested. In this article, to predict and classify nutritional deficiencies with respect to three macronutrients, we employed two forecast models: Inception-ResNet v2 and Autoencoder. The neural network requires all images used for training to be of a similar size. Hence, the images were preprocessed in order to scale to \(299\times 299\) pixels.  
The Application of the Deep Convolutional Neural Network for Classifying and Predicting Nutrient Deficiencies  
In this study, we used two models of machine learning groups, including supervised learning (Inception-ResNet v2) and unsupervised learning (Autoencoder), to classify and forecast deficiencies in three macronutrients, including Calcium, Potassium, and Nitrogen. Both models were based on CNN, both for training and to evaluate the predictive results. A CNN architecture is built with convolutional layers with various sizes of the kernel. It is able to convert an input image into smaller and smaller convolutional layers by means of the network using a number of feature maps. In addition, we use Ensemble Averaging to combine two given models for improving predictive accuracy.