2.4.3. Establishment of the Model

The backpropagation neural network (BPNN) is a powerful learning system that can realize highly nonlinear mapping between the input and output [19]. The number of units in the input layer of the BPNN model is the number of principal component feature variables, while its output layer is the disease spot area percentage; that is, the grade of tomato leaf mildew in this study. The non-linear Sigmoid type function was selected as the action function of the model, the learning rate was set to 0.6, the number of iterations was set to 300, the target deviation was set to 10–5, and other settings were kept as the default settings of the MATLAB self-contained toolbox. The activation function of the hidden layer was tansig and the activation function of the output layer was purelin.

Bayesian reasoning is a commonly used method of statistical reasoning. The main way to obtain information and evidence is by the updating of probability assumptions by the Bayesian theorem [20]. The steps for the classification and recognition of tomato leaf mildew samples by Bayesian reasoning are as follows.

(1) Calculate the prior probability; that is, the proportion of each level in the tomato leaf mildew sample. The prior probability formula is as shown below:

$$P(Y = c\_k) = \frac{\sum\_{i=1}^{N} (y\_i = c\_k)}{N}, k = 1, 2, \dots, K \tag{2}$$

(2) Calculate the conditional probability; that is, the conditional probability of each attribute in the training data set:

$$\begin{cases} P\left(X^{(j)} = a\_{jl} \middle| Y = \mathbb{C}\_k\right) = \frac{\sum\_{i=1}^{N} I\left(X\_i^{(j)} = a\_{jl}, y\_i = c\_k\right)}{\sum\_{i=1}^{N} I(y\_i = c\_k)} \\ \mathbf{j} = 1, 2, \dots, n, l = 1, 2, \dots, s\_{j'} \\ \mathbf{k} \text{ } l \text{ } k \text{ } l \text{ } k \text{ } s\_{j'} \text{ } k = 1, 2, \dots, K \end{cases} \tag{3}$$

(3) For a given example *xi* = *<sup>x</sup>*(1), *<sup>x</sup>*(2), ··· , *<sup>x</sup>*(*n*) *T* , *a posteriori* probability is calculated. (4) Calculate the maximum *a posteriori* probability and determine the class of instance *x* according to the value of the maximum *a posteriori* probability:

$$y = \underset{c\_k}{\text{arg}\max} P(Y = c\_k) \prod\_{j=1}^{n} P\left(X^{(j)} = x^{(j)} \mid Y = c\_k\right) \tag{4}$$

There are three types of node variables in the Bayesian network model: hyperspectral characteristic band nodes representing the health status of tomato leaves

*fa* = { *fa*1, *fa*2, ··· , *f*aN}, THz characteristic band nodes representing the health status of tomato leaves *fb* = { *fb*1, *fb*2, ··· , *f*bN}, and parameter nodes representing the health status of tomato leaves *Y* = {*Y*1,*Y*2, ··· ,*YM*}. The functional relationship between hyperspectral, TH, and parameter characteristic band nodes representing the health status of tomato leaves is as shown below:

$$\mathcal{Y} = \mathcal{F}(u, f\_{a\prime} f\_b) \tag{5}$$

After introducing the new node λ, the health status analysis of tomato leaves based on the Bayesian network model is obtained, as shown in Figure 6. Bayesian networks can be introduced by virtue of the prior distribution of health parameters. In the Bayesian network model, λ is the percentage of the diseased spot area; that is, the threshold value, which is set to 0.5.

**Figure 6.** Improved Bayesian network model for the health state analysis of tomato leaves.
