# Low-Complexity Microclimate Classification in Smart Greenhouses: A Fuzzy-Neural Approach
## 4 Methodology
### Hybrid Neural Network and Fuzzy Proposed Approach  
Our hybrid approach incorporates a NN for time series prediction, followed by a fuzzy layer to classify the NN's output; specifically, greenhouse microclimate conditions. The primary objective is to reduce NN complexity while maintaining performance levels in a way that is comparable to those of a standard NN classifier. In particular, we have chosen a FFNN as our reference NN model, as explained in Section 3. The FFNN consists of an input layer, a hidden layer, and an output layer. The input layer receives past temperature and humidity values at hourly intervals. During the search \begin{table}
\begin{tabular}{l l l l l l l l l l} \hline \hline  & **Temp-GH1** & **Hum-GH1** & **Temp-GH2** & **Hum-GH2** & **Temp-GH3** & **Hum-GH3** & **Temp-GH4** & **Hum-GH4** & **Global-Temp** & **Global-Hum** \\ \hline Min & 1.16 & 9.84 & \(-\)4.04 & 12.25 & \(-\)2.55 & 15.18 & \(-\)1.26 & 11.70 & \(-\)4.04 & 9.84 \\ \hline Max & 53.43 & 93.67 & 52.58 & 99.07 & 47.78 & 98.49 & 46.21 & 99.15 & 53.43 & 99.15 \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Maximum and minimum dataset values. Figure 4: Standard deviation of temperature (**a**) and humidity (**b**) values for different greenhouses and seasons. Figure 3: Average temperature (**a**) and humidity (**b**) values for different greenhouses and seasons. for the optimal configuration, the number of input features will be varied, as discussed in Section 5. Additionally, the size of the hidden layer, defined by the number of interconnected nodes between the input and output layers, will be adjusted in the experimental trials. Finally, the output layer generates two numerical outputs, corresponding to the predicted temperature and humidity for the next hour. These predicted values will then be processed by the fuzzy layer to produce the final microclimate classification. Our proposed solution is compared to the standard approach, in which the NN directly outputs the final microclimate classification. For training both the proposed and standard NN models, we employed the Levenberg-Marquardt algorithm [34], which is commonly used for this purpose. Regarding the activation function, our approach utilizes the ReLU function, as it provides the numerical temperature and humidity predictions required for the fuzzy layer. In contrast, the standard approach employs the sigmoid function, which outputs probabilities for microclimate classification. For backpropagation, both approaches use MSE to compute the gradient of the loss function with respect to the selected weights and biases. More specifically, our approach integrates numerical predictions from the FFNN with the concept of granular computing, in particular fuzzy sets, aiming not only to reduce the complexity and size of the NN architecture but also to enhance the interpretability and reliability of the predicted classifications. Fuzzy sets are defined as follows [43]:  
**Definition 1**. : _Given a domain \(\mathcal{X}\), with \(x\) being a generic element of \(\mathcal{X}\), the fuzzy set \(A\) in \(\mathcal{X}\) is defined as the set of pairs \(A=(x,f_{A}(x))\), characterized by a membership function \(f_{A}(x)\) that associates a real number in the interval \([0,1]\) with each element of \(\mathcal{X}\). The value of \(f_{A}(x)\) represents the degree of membership of \(x\) in \(A\)._  
* _For_ \(f_{A}(x)=1\)_,_ \(x\) _definitely belongs to_ \(A\)_._
* _For_ \(f_{A}(x)=0\)_,_ \(x\) _does not belong to_ \(A\)_._
* _For_ \(0<f_{A}(x)<1\)_,_ \(x\) _partially belongs to_ \(A\)_._  
For the fuzzy sets, we employed triangular membership functions, as they provide a more accurate representation of phenomena exhibiting gradual and continuous variations. The triangular membership function is defined as follows:  
\[f_{A}(x;a,b,c)=\max\biggl{(}\min\biggl{(}\frac{x-a}{b-a},\frac{c-x}{c-b} \biggr{)},0\biggr{)}, \tag{5}\]  
where \(a\) and \(c\) define the base points of the triangle, while \(b\) represents the peak position.