## 2 Materials and Methods
### Structure and Training of Selected Models
#### 2.3.2 Machine Learning Models (LSTM, CNN, XGBoost, RF)  
The selected ML models were built using Keras framework [46] (LSTM and CNN) and scikit-learn library [47] (RF and XGBoost). The models were tuned (hyperparameter selection) by using library extensions, such as keras-tuner and sklearn.model_selection. There were no modifications made to the selected ML models regarding their base architectures. The models were compared by varying hyperparameter values of each model. In order to find the best hyperparameter configuration, the LSTM and CNN models were tuned using the Hyperband algorithm [38], but the decision tree-based models--using  
Figure 3: Environmental (temperature and relative humidity, represented by blue and orange colored lines, respectively) and feeding data (feed and water consumption per hen, represented by green and red colored lines, respectively) recorded during 1 st (left side) and 2 nd (right side) production cycle.  
Random Search [48]. The search spaces of the hyperparameters for each model are shown in Tables 1-4.  
Early stopping technique (with a patience value 10) was used for LSTM and CNN models to potentially decrease the overfitting problem. The early stopping was also used in XGBoost hyperparameter search and training phase but the cross-validation technique in the RF case.  
Refer to Appendix A for the summarised results regarding sliding window sizes and the best hyperparameter values.  
The training of the models was performed using factors that were monitored daily in the poultry farm and production-related data with varying input sequence lengths, e.g.,  
\begin{table}
\begin{tabular}{c c} \hline \hline
**Hyperparameter** & **Range of Considered Values** \\ \hline Input size & 32, 48, 64, 80, 96, 112, 128 \\ \hline Dropout rate & 0, 0.1, 0.2, 0.3, 0.4, 0.5 \\ \hline Optimizer & Adam \\ \hline Learning rate & 0.01, 0.001, 0.0001 \\ \hline Activation function & ReLU, sigmoid \\ \hline Early stopping patience & 10 \\ \hline Loss function & Mean Squared Error \\ \hline \hline \end{tabular}
\end{table}
Table 1: Hyperparameters and their considered values for LSTM model.  
\begin{table}
\begin{tabular}{c c} \hline \hline
**Hyperparameter** & **Range of Considered Values** \\ \hline Max depth & 3, 6, 10 \\ \hline Learning rate & 0.01, 0.05, 0.1 \\ \hline Number of estimators & 100, 500, 1000 \\ \hline Colsample bytree & 0.3, 0.7 \\ \hline \hline \end{tabular}
\end{table}
Table 3: Hyperparameters and their considered values for XGBoost model.  
\begin{table}
\begin{tabular}{c c} \hline \hline
**Hyperparameter** & **Range of Considered Values** \\ \hline Max depth & 3, 6, 10 \\ \hline Learning rate & 0.01, 0.05, 0.1 \\ \hline Number of estimators & 100, 500, 1000 \\ \hline Colsample bytree & 0.3, 0.7 \\ \hline \hline \end{tabular}
\end{table}
Table 4: Hyperparameters and their considered values for RF model.  
using the sliding window approach. When using such a technique, an important step is to determine the size of the window, as this defines the additional requirement for model input--the number of past productivity values, e.g., egg production in this case. If a sliding window of size 1 is chosen, it means the inputs require production data from the previous day. During the initial development stage, multiple feature selection approaches were considered, and it was determined that forward feature selection would be appropriate for usage for general ML algorithms based on the data obtained from the farm.  
The selected ML models were trained on the first production cycle (that was further split into 90% train and 10% validation set in order to avoid data leakage [49] and overfitting problems [50]) and tested on the second production cycle to forecast productivity for the next day. The models' input was formed from 12 parameters (see Figure 4) (and, additionally, the historical production data depending on the sliding window size).