scieee AI-readable full text Open interactive document viewer

Forecasting Greenhouse Temperature Using Machine Learning Models: Optimizing Crop Production in Andalucia

Vega Márquez, Belén; Pardo-Martínez, Juan; Villegas-Oliva, María del Mar; Riquelme Santos, José Cristóbal

Abstract

Successful crop production in greenhouses is determined mainly by not only internal and external climatic variables but also by the characteristics of the greenhouse itself. One of the most important variables is the internal temperature, as it greatly determines whether or not the crop will succeed. The objective of this work is to use machine learning models capable of giving a short-term forecast of the indoor temperature of greenhouses in the future. This model will be able to guide growers in determining the best location for new greenhouses, as they will be able to see what the future indoor temperature will be based on the other predictors. The main challenge of this work has been that we have not used the past of the variable to predict, but only the past of the predictor variables. The results obtained show that the model is capable of predicting indoor temperature with significant precision, suggesting that the proposed methodology may be useful to optimize the selection process of greenhouse locations.

Full text

Forecasting Greenhouse Temperature Using Machine Learning Models: Optimizing Crop Production in Andalucia Bel´en Vega-M´arquez1(B), Juan Pardo-Mart´ınez2, Mar´ıa del Mar Villegas-Oliva3,andJos´e C. Riquelme1 1Department of Computer Languages and Systems, University of Seville, Seville, Spain {bvega,riquelme}@us.es 2Greenhouse Technical Department, Novagric, Murcia, Spain [email protected] 3Greenhouse Technology Area, Tecnova Foundation, Almer´ıa, Spain [email protected] Abstract. Successful crop production in greenhouses is determined mainly by not only internal and external climatic variables but also by the characteristics of the greenhouse itself. One of the most important variables is the internal temperature, as it greatly determines whether or not the crop will succeed. The objective of this work is to use machine learning models capable of giving a short-term forecast of the indoor temperature of greenhouses in the future. This model will be able to guide growers in determining the best location for new greenhouses, as they will be able to see what the future indoor temperature will be based on the other predictors. The main challenge of this work has been that we have not used the past of the variable to predict, but only the past of the predictor variables. The results obtained show that the model is capable of predicting indoor temperature with significant precision, suggesting that the proposed methodology may be useful to optimize the selection process of greenhouse locations. Keywords: internal temperature ·greenhouse ·time series forecasting ·machine learning 1 Introduction Today, the ever-increasing population means that the demand for food is constantly on the rise. This has led the agricultural sector to focus on finding alternatives to ensure that increased production does not lead to a decrease in quality [10]. To achieve this goal, it is necessary to use more advanced methodologies, such as greenhouse cultivation. The use of greenhouses for cultivation has a number of advantages. First, they allow farmers to establish the most suitable climatic conditions for each https://doi.org/10.1007/978-3-031-42529-5_23 240 B. Vega-M´arquez et al. crop. Secondly, the use of greenhouses is related to higher production and better quality, and finally, they are able to provide greater control over pests and extreme weather conditions. These benefits are significant, but careful management of temperature, humidity, light availability and water use is necessary to maintain the environmental conditions required for plant development [7]. Greenhouses are very complex systems whose behavior is non-linear [1]. The success of crop production is determined by the microclimatic variables within the greenhouse, especially the temperature. These internal variables are influenced not only by external conditions, such as outside temperature or radiation, but also by other variables directly related to the condition of the greenhouse, such as the position of the screens or the ventilation of the greenhouse. All these variables have one thing in common, that is, they belong to the time series category. A time series is an ordered chronological sequence of values that have been recorded over time [9]. A variable’s previous behavior can be studied in great detail in order to predict its future behavior. Although deep learning models have proven to be a very good alternative for modeling the energy conditions inside a greenhouse, they have a disadvantage that is the large number of parameters that need to be optimized, as well as their higher computational cost. Therefore, in this work, it has been decided to use machine learning models to model the interior temperature of greenhouses. The main objective of this work is to offer farmers a new methodology to locate new greenhouses. By accurately predict indoor temperature, farmers can identify the most suitable locations for new greenhouses based on environmental conditions. In addition, the methodology can help farmers optimize the design and operation of existing greenhouses. 2 Related Works In recent years, deep learning models have emerged as a promising tool to predict time series due to their ability to effectively model nonlinear systems. These models can learn from historical data to identify patterns and make accurate predictions. In [8] three deep learning-based neural network models (ANN, NARX, and RNN-LSTM) were used to determine the best approach to predict environmental changes in temperature, humidity, and CO2levels within greenhouse temperature. The 2017 paper by [2] develops a Multi-Layer Perceptron ANN, trained by a Levenberg-Marquardt back-propagation algorithm to predict the inside greenhouse temperature. Although their efficiency is very promising, one of the main problems with this type of models is the computational capacity they require, since the parameter optimization needed is a costly process in terms of time. In addition to deep learning models, machine learning models have emerged as viable alternatives in the context of our study. Several studies have shown its effectiveness as reliable predictors of the specific problem under investigation. For example, in [12] machine learning techniques were used for greenhouse simulation. The study investigates their suitability to model greenhouse environments and provides insights into their potential to improve crop production. In Hamiltonian Mechanics 241 addition, in [4] 5 greenhouse temperature and humidity prediction models were tested and implemented. The results show that machine learning models are a good alternative to deep learning models, obtaining even better results in terms of nRMSE. In light of these findings, we evaluate four different machine learning models: GradientBoostingRegressor, LGBMRegressor, XGBRegressor, and Random- ForestRegressor. The data used correspond to a greenhouse located in the eastern part of Andaluca. We train the models on data from 2020–2021 and validate them on data from 2022. Our results could have significant implications for improving greenhouse operations and plant growth while reducing environmental impact and optimizing resource consumption. 3 Methodology This section describes the methodology used to forecast the greenhouse temperature. First, a description of the experimental setup will be given. Second, the learning models used will be presented. 3.1 Experimental Setup In order to achieve the objectives of this work, the steps shown in Fig. 1have been followed. Fig. 1. Experimental setup followed in the study. First, data collection was performed by Tecnova Foundation and Novagric company. This data collection consisted of obtaining measurements using strategically placed sensors in the greenhouse to be studied in order to obtain as reliably as possible the greatest possible variability of the variables to be studied. Once the data were collected, preprocessing of the data was carried out, since, in some temporary instants, the measurements had not been collected or were incorrect. At the end of this step, what was obtained was a data matrix Xwith as many columns as the variables measured by the sensors and as many rows as the time points considered. Another objective was to create robust models that were not costly in training time, since the idea is that this system can be implemented in a real environment, which is why it was decided to use Machine Learning models and not 242 B. Vega-M´arquez et al. deep learning. To convert a time series prediction problem into a random forest regression model, we transformed the series regressors into a vector T that contains the most recent observations of each series in the feature matrix X. To assess the performance and precision of the proposed models, we used the mean absolute error (MAE). This metric measures the average absolute error between the real and forecast time series, giving a result that is easy to interpret since it is in the same unit as the variable under study. 3.2 Machine Learning Models With the aim of achieving the best result, it has been decided to use 4 Machine Learning models that have been shown to be good predictors in the literature. Each of them will be listed and described below: –Gradient Boosting: Gradient boosting (GB) is a classification and regression machine learning method that constructs a model from a set of weak patterns or learners, typically decision trees [6]. –LightGBM: Light Gradient Boosting Machine is a novel Gradient Boosting Decision Tree (GBDT) algorithm which combines a novel classification method with a data sampling one: Gradient-Based One-Side Sampling and Exclusive Feature Bundling [11]. –XGBoost: Extreme Gradient Boosting was first introduced in [3]. It is a scalable distributed gradient-boosted decision tree (GBDT). To achieve the best model, it employs a recursive binary splitting approach, selecting the best split at each step. –Random Forest: To solve regression tasks, it generates a large number of regression trees. To arrive at a final decision, these trees, which serve as regression functions, are combined using bootstrap or ensemble techniques [5]. Compared to other methods, this model is less sensitive to overfitting and noise because it makes a selection of internal features. 4 Results and Discussion In this section, we will describe the results after applying the methodological approach followed in Sect. 3. First, we will show the main characteristics of the data set to be studied, focusing on the predictor variables and the variable to be predicted. Finally, the results obtained with the 4 regression models used in this work will be presented. A study of the predictions obtained will also be made in such a way as to see the behavior of the models on the validation set. 4.1 Data Description The study data for this work correspond to attributes collected from a greenhouse located in the eastern part of the Andalusia region (Spain) by Tecnova Foundation and Novagric company. The number of attributes collected for the Hamiltonian Mechanics 243 study was 13: 2 characteristics related to external factors of the greenhouse, as well as 11 related to indoor conditions. The sampling frequency of the sensors is 5 min, which coincides with the forecast horizon. The description of each feature is provided in Table 1. This table shows, for each of the variables used in the training process, their minimum, maximum, mean, and standard deviation. Table 1. Statistics of the features used in the study. The target feature is “Indoor temperature [oC]”. Attribute Mean Std. Min. Max Window position side 1 [/%] (zenithal) 38,645 43,350 0,000 100,000 Window position side 2 [/%] (zenithal) 39,387 44,153 0,000 100,000 Outdoor temperature [oC] 18,965 6,303 –25,000 64,600 Wind speed [m/s] 2,158 1,7786 0,000 14,700 Wind direction [o]176,613 110,940 0,000 359,000 Radiation Intensity [W/mˆ2] 211,925 291,588 0,000 1085,000 Outdoor relative humidity [%] 62,659 18,397 0,000 99,000 Movable screen position [%] 30,065 44,043 0,000 100,000 Window position side 1 [/%] (side) 17,729 33,929 0,000 100,000 Window position side 2 [%] (side) 0,000 0,000 0,000 0,000 Indoor relative humidity [%] 71,503 15,592 11,800 100,000 Heating status Binary variable (on-off) Indoor temperature [oC] 20,519 5,913 -0,200 43,800 Although the sensors used in industry have become more reliable over the years, there are still certain irregularities in the data collected from them. These irregularities are mainly due to a poor sensor connection or an external problem that makes data collection less efficient. One of the main problems with the dataset we are working with is that there were certain intervals where the values were null. Therefore, it has been decided to preprocess the data. This preprocessing has mainly consisted of two tasks. The first has been to remove data for those time intervals where there was no measurement for all variables. The second has been to consider only those days with complete data in the study, which means that all time intervals had values for all variables. For the generation of lags, an interval of half an hour before the instant to be predicted has been taken into account, i.e. to predict the value of the indoor temperature at instant t, the information of the exogenous variables at instants t-5,t-10,t-15,t-20,t-25, t-30 has been used. To validate the effectiveness of the trained models, the data set was divided into train and test: 2020–2021 as training years and 2022 as test year. Figure 2provides a more detailed view of the evolution of the variable to be predicted over time. There is a total of three years of data (2020–2023) with a sampling frequency of 5 min by the sensors. As can be seen, there is a clear 244 B. Vega-M´arquez et al. pattern over the years that makes the variable to be predicted easy to model. However, as mentioned in previous sections, the objective of this work is to use only exogenous variables to predict the target variable. Fig. 2. Internal temperature [oC] of the greenhouse for the three years used in this study (2020, 2021, and 2022). 4.2 Experimental Results Gradient Boosting, LightGBM, XGBoost and Random Forest models are used to develop prediction models for the inside greenhouse temperature with a prediction horizon of 5 min. Table 2shows the results in terms of MAE obtained with each regression model used. In order to corroborate that machine learning models are an alternative to deep learning models, an experiment was conducted with a multilayer neural network (MLP). To train the models, data from 2020– 2021 were used. The remaining portion (year 2022) was utilized to assess the models’ proficiency. After several experiments with different parameters, it was decided to use the default parameters, since there were no significant differences in the results and it would simplify the process. Table 2. Results in terms of MAE for each of the models used. These results have been obtained training with the 2020-2021 data and validating on the year 2022. Model MAE GradientBoostingRegressor 1,664 LGBMRegressor 1,485 XGBRegressor 1,626 RandomForestRegressor 1,705 MultiLayerPerceptron 1,667 The results show that the LGBMRegressor model achieved the lowest MAE of 1.485. Taking into account the temperature range, this indicates that the LGBMRegressor model can predict the indoor temperature with a high degree Hamiltonian Mechanics 245 of accuracy, as the MAE is relatively small compared to the overall temperature range. The XGBRegressor model achieved a slightly higher MAE of 1.626, which is still within an acceptable range given the temperature range of the greenhouse. The GradientBoostingRegressor model achieved a MAE of 1.664, which is slightly higher than the XGBRegressor model, but still relatively small compared to the temperature range. The RandomForestRegressor model achieved the highest MAE of 1.705, which indicates that it is the least accurate model among the four. Overall, based on the MAE metric and considering the indoor temperature range, the LGBMRegressor and XGBRegressor models are the most suitable to forecast indoor temperature in greenhouses. Finally, it should be noted that the deep learning model (MLP) only improves one of the proposed machine learning models (Random Forest). Perhaps optimization of the network parameters would have improved the results, but in order to make the results fully comparable with the other models, it was decided not to optimize the network parameters. A graphical representation can provide a visual understanding of the accuracy of the prediction made by the machine learning model. Ideally, the forecasted values should be as close to the actual values as possible. Figure 3shows the day on which the best results were obtained (12-11-2022). In the case of the best day, the model with the lowest MAE, i.e. the LGBMRegressor model, gives a result of 0.4. The graphical representation likely includes two lines: one for the actual indoor temperature values and one for the predicted values generated by the LGBMRegressor model. Fig. 3. Real and forecasted value of indoor temperature for the day on which the best result was obtained. This day was November 12, 2022. Although there were days when the predictions were very good, it was also observed that in some very specific months the errors deviated a little more from the average. This pattern can be seen in Fig. 4. This figure shows the MAE values for each month, where each bar represents the MAE value for the predictions for 246 B. Vega-M´arquez et al. that month using the LGBMRegressor. Based on the results, January, February, March, and April had the highest MAE values, indicating that these months were more difficult to predict accurately than the other months. This may be due to various factors, such as changes in external weather conditions, changes in greenhouse operations, or changes in plant growth patterns. It is also possible that certain events or anomalies occurred during these months, which could have affected the accuracy of the predictions. For example, it is likely that the contribution of heaters (turned on in the cold months) was not well modeled by the regressor, as their frequency in the training data was unrepresentative. Overall, the graph suggests that the accuracy of the predictions varies by month and that the machine learning models may perform differently depending on the time of year. This highlights not only the importance of considering seasonal trends and other external factors when forecasting indoor temperature in greenhouses, but also the need to collect more data. Collecting more data can help capture seasonal trends and other external factors that can affect indoor temperature, and it can also help identify patterns and relationships that may not be evident in smaller datasets. By incorporating more data into the machine learning models, it may be possible to improve the accuracy of the predictions, especially during the months with the highest MAE values. Despite encountering occasional suboptimal results during certain months, overall, we deem the performance of the models to be satisfactory. As a result, it could be considered that these models can aid greenhouse managers in their decision-making process to determine the best location for their greenhouses. By using these prediction models, they could predict if this type of greenhouse would be suitable for the location of interest, taking into account the values of the variables in this specific location. Fig. 4. Average MAE obtained per month. Hamiltonian Mechanics 247 5 Conclusions In this study, we explored the use of machine learning models to forecast indoor temperature in greenhouses. Specifically, we evaluated four different models: GradientBoostingRegressor, LGBMRegressor, XGBRegressor, and Random- ForestRegressor. We trained the models on data from 2020-2021 and validated them on data from 2022. The main objective of this work was to build a model that allows farmers to simulate the indoor temperature of a greenhouse that has not yet been constructed based on specific conditions. Therefore, the challenge of this work was that it was not possible to use the past information from a time series to predict. Instead, we relied solely on information about the conditions that will be present during the simulation to build the model. This represents a unique challenge, as it requires the model to accurately predict indoor temperature based only on input conditions and not on previous data. Our results show that the LGBMRegressor model performed the best, with the lowest MAE value of 1,485. However, we also observed some variation in the accuracy of the predictions by month, with the highest MAE values occurring in January, February, March, and April. These findings highlight the importance of considering seasonal trends and other external factors when forecasting indoor temperature in greenhouses. Although our study has provided valuable insights into greenhouse temperature prediction, it is essential to acknowledge the limitation of training our models in a single location. Although the data with which we have studied have varied over the years studied, we propose to collect data on the same type of greenhouse in other locations, as well as on other types of greenhouses, as a future work. The results of our study suggests that machine learning models can be a valuable tool to predict indoor temperature in greenhouses. However, it is important to select an appropriate model, consider external factors, and continuously update the model based on new data and trends. With these considerations in mind, machine learning can play a critical role in optimizing greenhouse operations and improving plant growth and yields. Acknowledgement. This research has been funded by Andalusian Regional Government PYC20 RE 078 USE and by FEDER/Ministerio de Ciencia, Innovaci´on y Universidades-Agencia Estatal de Investigaci´on/Proyecto under the projects MICINN PID2020-117954RB-C22 and MICIN TED2021-131311B. References 1. Allouhi, A., Choab, N., Hamrani, A., Saadeddine, S.: Machine learning algorithms to assess the thermal behavior of a moroccan agriculture greenhouse. Cleaner Eng. Technol. 5, 100346 (2021) 2. Casta˜neda-Miranda, A., Casta˜no, V.M.: Smart frost control in greenhouses by neural networks models. Comput. Electr. Agricul. 137, 102–114 (2017)