Evolution and Neural Network Prediction of CO2 Emissions in Weaned Piglet Farms

This paper aims to study the evolution of CO2 concentrations and emissions on a conventional farm with weaned piglets between 6.9 and 17.0 kg live weight based on setpoint temperature, outdoor temperature, and ventilation flow. The experimental trial was conducted during one transition cycle. Generally, the ventilation flow increased with the reduction in setpoint temperature throughout the cycle, which caused a reduction in CO2 concentration and an increase in emissions. The mean CO2 concentration was 3.12 g m–3. Emissions of CO2 had a mean value of 2.21 mg s−1 per animal, which is equivalent to 0.195 mg s−1 kg−1. A potential function was used to describe the interaction between 10 min values of ventilation flow and CO2 concentrations, whereas a linear function was used to describe the interaction between 10 min values of ventilation flow and CO2 emissions, with r values of 0.82 and 0.85, respectively. Using such equations allowed for simple and direct quantification of emissions. Furthermore, two prediction models for CO2 emissions were developed using two neural networks (for 10 min and 60 min predictions), which reached r values of 0.63 and 0.56. These results are limited mainly by the size of the training period, as well as by the differences between the behavior of the series in the training stage and the testing stage.


Introduction
Animal production is a fundamental activity for meeting the increasing global demand for food. However, this activity is a key contributor to global GHG emissions [1,2] and to the global problem of climate change [3]. Pig production accounts for a significant portion of these emissions [4], with a contribution of between 9 and 13% [2,3]. Considering the GHG produced by pigs and manure at pig house level, the gas that contributes the most to the greenhouse effect is CO 2 , with approximately 81% of emissions [5]. However, direct CO 2 emissions, arising from the animals and manure, are generally excluded from GHG evaluation, because they are supposed to be compensated by CO 2 consumption through photosynthesis, performed by the plants used as feed. For this reason, CO 2 production is rarely addressed in the literature [5]. CO 2 emissions from farms depend on two factors, CO 2 production and ventilation rate. Here, the main source of CO 2 is animal metabolism, followed by manure [6], although other sources may exist, such as heaters using propane or natural gas [7]. More specifically, the carbon dioxide produced by animals depends on animal weight and daily gain, while CO 2 emissions are also strongly affected by variations in animal activity [8][9][10][11][12]. Carbon dioxide emissions have also been reported to be affected by other factors, such as diet composition [13,14] and conversion efficiency, droppings management, or environmental conditions [15], following a sinusoidal pattern of daily emission [8,9]. Nevertheless, there are some discrepancies between the results that have been reported so far, probably due to variations in animal species, feeding level, farm practices, control strategy, manure management systems, animal density, geography, climate, season, and other factors [7,10]. In relation to pig production, variations have been found between physiological stages [5,16], which could be attributed to the conditions of the building, ventilation system, management, diet, or even gas measurement method. Thus, while different authors [17,18] have reported fairly similar CO 2 emissions during the fattening period, larger variations have been found during the other physiological stages [19][20][21], especially during weaning [5]. In fact, CO 2 production per unit of total heat production is much lower for weaning pigs than for growing finishing pigs [12]. In addition, large variations have been found in GHG emissions per unit of product across EU countries, mainly because of the differences observed in the production systems [5], feed type, and efficiency of nutrient use [22].
Farm buildings for piglets in transition, where weaned piglets are housed from weaning up to fattening, as well as delivery rooms, are the facilities with the highest levels of CO 2 concentration. This is because ventilation rates are kept reduced at this stage owing to the fact that animals require high temperatures and are very sensitive to air currents [23]. Consequently, although CO 2 emissions are affected considerably more by ventilation rate than by indoor air concentration [24], these farms present high levels of CO 2 emissions into the atmosphere due to the relationship between concentration and emission through the ventilation rate [24,25]. Moreover, the ventilation system and the control strategy can significantly affect the airflow inside livestock rooms, which can further affect the emission of gaseous contaminants from animal buildings [6].
Intelligent livestock farming, with a continuous improvement in the production efficiency of management systems, can contribute to decreasing GHG emissions [26,27]. In recent years, technological progress has contributed to obtaining positive results in the reduction of GHG emissions from pig production [28], although other studies have shown that these efforts may not be enough to achieve a sustainable level [29,30]. Therefore, there is a need to find housing systems that minimize ammonia and GHG emissions, and improve animal welfare [31]. In this respect, most existing studies focus on GHG emissions for ruminants, partly because of their high emission per unit of production. In contrast, fewer studies focus on monogastric animals, like pigs [32,33]. New research is thus necessary in order to obtain accurate emission factors [4,10,15], mainly under farm conditions [34], that cover the full production seasons [14].
A number of studies have been performed to evaluate emissions from farms with weaned piglets, both in field conditions [14] and in experimental rooms, during part of the transition period [3,13]. Two of those studies focused on determining the influence of different diets on GHG emissions and found that including dried distillers grains with solubles in the diet of piglets did not cause significant differences in CO 2 emissions [3]. In addition, using five different isoenergetic diets (control, low protein, inclusion of sugar beet pulp, addition of benzoic acid, and a combination of previous diets) only caused a 15% decrease in CO 2 emissions for the combined diet [13]. Different floor systems (strawbased deep litter, sawdust-based deep litter, and fully slatted floors) were also analyzed, but no significant differences in CO 2 emissions were found between systems [3]. There is a lack of studies aimed at quantifying CO 2 emissions on farms raising weaned piglets based on continuous measurements performed under field conditions. In contrast to the above studies, in this paper, we analyze the data for a complete production cycle, from weaning to fattening, from a conventional farm. Continuous measurements of environmental parameters and ventilation flow have been used, which results in quality data for a largely unexplored production stage.
In addition to quantifying emissions, generating models that are capable of predicting the emission of gases from farms is necessary to achieve emission control through intelligent livestock farming. One of the emerging technologies for modelling and predicting farm emissions is artificial intelligence (AI), which has already been used for developing many applications and papers in the field of smart farming. The most common AI models used for the modelling, prediction, and management of variables related to livestock farming are artificial neural networks (ANN), convolutional neural networks, deep learning, adaptive neural fuzzy inference system (ANFIS), machine learning, and pattern recognition [35]. Specifically, ANFIS models have been used for modelling ammonia emissions in pig farms [36], and ANN and ANFIS (artificial neural network and adaptive neuro-fuzzy inference systems, respectively) have been used for modelling and predicting energy output and greenhouse gas emissions from calf fattening farms [37].
This paper aims to quantify and study the evolution of CO 2 concentration and emissions on a pig farm with weaned piglets from 6.9 to 17 kg LW during a complete transition cycle under field conditions. Our aim is to find the relationship between CO 2 concentration and emissions, and some control parameters of the air conditioning system, such as setpoint temperature, outdoor temperature, or ventilation flow, during one transition cycle. In addition, we present a neural network-based model for the prediction of 10 min and 60 min CO 2 emissions that can be incorporated into the environmental control system.

Materials and Methods
Research was conducted in a conventional farm for the production of piglets located in NW Spain. Measurements were performed in a transition room, where piglets entered with an average weight of 6.9 kg at day 28 after birth and exited with 17.0 kg LW at day 65 after birth, covering a complete transition cycle, from 27 February to 4 April. An intermediate room was chosen in order to avoid the boundary effect of lateral positions in the building. The inner dimensions of the room, with polypropylene slats on the floor, were 11.82 m long by 5.86 m wide, and between 2.25 and 2.50 m high. The mean depth of the pit was 0.45 m. At the end of each cycle, the room was completely cleaned and manure was completely removed from the pit. The room had six pens on both sides of a central corridor and housed a maximum of 300 weaned piglets, with 50 piglets per pen, with 0.20 m 2 per piglet ( Figure 1). veloping many applications and papers in the field of smart farming. The most commo AI models used for the modelling, prediction, and management of variables related t livestock farming are artificial neural networks (ANN), convolutional neural network deep learning, adaptive neural fuzzy inference system (ANFIS), machine learning, an pattern recognition [35]. Specifically, ANFIS models have been used for modelling am monia emissions in pig farms [36], and ANN and ANFIS (artificial neural network an adaptive neuro-fuzzy inference systems, respectively) have been used for modelling an predicting energy output and greenhouse gas emissions from calf fattening farms [37]. This paper aims to quantify and study the evolution of CO2 concentration an emissions on a pig farm with weaned piglets from 6.9 to 17 kg LW during a complet transition cycle under field conditions. Our aim is to find the relationship between CO concentration and emissions, and some control parameters of the air conditioning sys tem, such as setpoint temperature, outdoor temperature, or ventilation flow, during on transition cycle. In addition, we present a neural network-based model for the predictio of 10 min and 60 min CO2 emissions that can be incorporated into the environmenta control system.

Materials and Methods
Research was conducted in a conventional farm for the production of piglets locate in NW Spain. Measurements were performed in a transition room, where piglets entere with an average weight of 6.9 kg at day 28 after birth and exited with 17.0 kg LW at da 65 after birth, covering a complete transition cycle, from 27 February to 4 April. An in termediate room was chosen in order to avoid the boundary effect of lateral positions i the building. The inner dimensions of the room, with polypropylene slats on the floo were 11.82 m long by 5.86 m wide, and between 2.25 and 2.50 m high. The mean depth o the pit was 0.45 m. At the end of each cycle, the room was completely cleaned and ma nure was completely removed from the pit. The room had six pens on both sides of central corridor and housed a maximum of 300 weaned piglets, with 50 piglets per pen with 0.20 m 2 per piglet ( Figure 1).  The sensors for the speed of the air extracted through the ventilation system (V m ) and CO 2 concentration at the ventilation air outlet (C OUTLET ) were located at (A) and the sensor for CO 2 concentration in the exterior corridor of air inlet (C INLET ) was located at (E). The air conditioning system comprised ventilation and warm water underfloor heating facilities. Environmental control was performed in the building through a temperature probe, without altering the usual conditions of the farm. The setpoint temperatures (T S ) defined for environmental control were between 26 and 23 • C with a bandwidth of ±1.5 • C, and decreased gradually with the increase in the age and weight of the animals (Table 1). Clean air entered the room through two windows with air deflectors on the wall opposite to the fan ( Figure 1E). The animals were provided feed ad libitum through a screw conveyor system with a feeder shared by two pens. Water was supplied through two drinking cups in each pen. Table 1. Setpoint temperature (T S ), day of the cycle on which T S was set, piglet age, mean weight of piglets, and number of data. The number of animals was registered daily. Animals were weighed at the beginning of the cycle, on day 28 after birth, on day 38 when the feed type was changed, and at the end of the cycle on day 65 after birth. In order to obtain the value for emissions per kg throughout the cycle, a linear interpolation was performed between the weighed values. Table 1 shows the mean weight of the piglets for each setpoint temperature. Table 2 shows the environmental variables measured and the sensors used to measure them. Variables were measured every second, and the averages for every 10 min interval were stored in a HOBO ® data logger (Bourne, MA, USA). Based on the speed of the air extracted, the flow extracted through the fan (Q) was calculated using the following expression: where: The emission of CO 2 per animal, E CO2 , was calculated according to the following expression:

Prediction of CO 2 Emissions
Neural networks were trained to predict CO 2 emissions at 10 min and 60 min intervals. An artificial neural network (ANN) is a method used for modelling non-linear relationships between input and output variables [38]. An ANN does not require previous knowledge about how to handle the system, which turns it into a very efficient and versatile technique in complex processes. Since the 2000s, ANNs have been the most recurring artificial intelligence models in the field of research on animal farming, mainly for detecting illnesses, estimating growth performance, or monitoring and controlling environmental conditions [35]. Since then, different training algorithms have been used, such as back propagation, radial basis function, or feed forward [37,39]. In this paper, a multilayer perceptron neural network was used. A resilient backpropagation method with weight backtracking, available in the "neuralnet" pack of R [40], was used to train the ANN. This algorithm is a first-rate optimization method similar to the backpropagation algorithm, but is generally faster, without the requirement of specifying free parameter values [41].
The number of neurons in the input and output layers is determined by the input and output variables of the model. In this case, three inputs were used, namely the values of Q, T IN , and C CO2 measured during the previous 10 min or 60 min periods, to obtain the output, E CO2 . On the contrary, there is no specific procedure to determine the number of neurons, M, of the hidden layer. This value is defined through a procedure of trial and error. After having checked the performance of different neural network structures, and having evaluated the average degree of fit of up to 40 training iterations with each structure, we chose a network with an input layer of three neurons and one output layer of one neuron, with two hidden layers, and a total of 3-4-4-1 neurons per layer. This structure was the most efficient at predicting emissions for both the 10 min and 60 min periods. Moreover, the initial weights of the network were allocated randomly. A logistic activation function was used because of the common use of these functions in the field of agriculture [37]. The stopping criterion was set to 0.01, with a maximum number of steps for the training of 1 × 10 5 .

Evaluation of the Performance of the Model
In order to evaluate the performance of the model, three statistical measures were used: root mean square error (RMSE), Pearson correlation coefficient (r), and mean absolute relative error (MARE). RMSE was used to measure the difference between the predictions of the model and the observed values. The values of RMSE are expressed in units, while MARE indicates the size of the error in relative terms. The Pearson correlation coefficient indicates the strength and direction of a linear relationship between the predicted and observed values. where y is the observed value; y is the predicted value; y and y are the average values of y and y , respectively; and n is the number of values.

Results and Discussion
The mean CO 2 concentration at the air outlet of the building where piglets between 6.9 kg and 17.0 kg were housed was 1852 ± 711 ppm, which is equivalent to 3.12 ± 1.20 g m -3 (Table 3). These values were near the lowest mean value of 1981-3253 ppm found in different trials for pigs between 5.5 and 118 kg, with highly extreme temperatures and very restricted ventilation over a prolonged period in the cycle [14], and slightly higher than the mean of 2.89 g m -3 found for pigs between 13 and 32 kg in environmental chambers [13]. All of these CO 2 concentrations were far below the 5.30 mg m −3 obtained for animals between 17 and 20 kg [20]. The mean CO 2 emission was 2.21 ± 1.09 mg s −1 pig −1 (Table 4), which is below the emissions reported by other authors in buildings with fully slatted floors [3] for pigs in the same growth stage, with very similar weights of 7 and 23 kg and emission values of 3.51 and 3.95 mg s −1 pig −1 . By transforming the unit based on animal weight, the emission obtained was 0.195 ± 0.074 mg s −1 kg −1 . This value was only above the 0.139 mg s −1 kg −1 found for pigs of 7 to 35 kg [19], and well below the values reported in other studies that analyzed different diets, with mean values of 0.293 mg s −1 kg −1 for piglets between 13 and 32 kg [13], and values of 0.423 mg s −1 kg −1 and 0.549 mg s −1 kg −1 for pigs between 5.5 and 118 kg [14]. Even though both studies focused on pigs with weights within the range analyzed in our study, the study in [13] started at much heavier weights than the weights studied in our paper and ended much later, while the study in [14] started at a slightly lower weight, but included the finishing stage, so that the animals ended up being much older. The weaned piglet stage is the one with the largest variations in CO 2 emissions, whereas other stages produce more homogenous emissions [5]. Despite this, the studies devoted to the effect of different diets on weaned piglets have not found significant differences on CO 2 emissions [13,14]. Likewise, using a fully slatted floor as opposed to straw-based deep litter or sawdust-based deep litter did not cause significant differences in CO 2 emissions [3].

Variation of CO 2 Concentration and Emissions with Setpoint Temperature
The CO 2 concentration in the building reached its peak with the highest setpoint temperature, 26 • C, set at the start of the cycle, and decreased as animals grew and the setpoint temperature was reduced (Table 3, Figure 2A). The mean CO 2 concentrations for every setpoint temperature were lower than the measurements reported by [42], although concentrations were always in the range reported by a number of authors for pig farms [43][44][45]. In summary, the CO 2 concentration declined as the animals grew. In contrast, another study reported increasing concentrations [13], which may be caused by the different ages of the animals (28 days vs. 37 days). As a result of age difference, higher temperatures and lower ventilation rates were required in our study to ensure animal welfare conditions. Actually, a trend of increasing concentrations was observed in the final stage of the cycle analyzed in our study (Figure 2A).

Variation of CO2 Concentration and Emissions with Setpoint Temperature
The CO2 concentration in the building reached its peak with the highest setpoint temperature, 26 °C, set at the start of the cycle, and decreased as animals grew and the setpoint temperature was reduced (Table 3, Figure 2A). The mean CO2 concentrations for every setpoint temperature were lower than the measurements reported by [42], although concentrations were always in the range reported by a number of authors for pig farms [43][44][45]. In summary, the CO2 concentration declined as the animals grew. In contrast, another study reported increasing concentrations [13], which may be caused by the different ages of the animals (28 days vs. 37 days). As a result of age difference, higher temperatures and lower ventilation rates were required in our study to ensure animal welfare conditions. Actually, a trend of increasing concentrations was observed in the final stage of the cycle analyzed in our study (Figure 2A).
CO2 emissions decreased at the beginning of the cycle because of the limitation of ventilation flows and the weight of piglets (Table 4 and Figure 2B). Emissions during the first five days (TS = 26 °C) were higher than on the following days (change to TS = 25 °C) because the piglets showed more activity as a consequence of post-weaning stress. From that moment, emissions increased with the age of the animals, which was particularly noticeable at the end of the cycle (from day 28), as stated by [2]. The regular increase in CO2 emissions over the cycle suggests the influence of animal weight [3], which results from an increase in the metabolic rate and in CO2 production due to breathing [14].   (Table 4 and Figure 2B). Emissions during the first five days (T S = 26 • C) were higher than on the following days (change to T S = 25 • C) because the piglets showed more activity as a consequence of post-weaning stress. From that moment, emissions increased with the age of the animals, which was particularly noticeable at the end of the cycle (from day 28), as stated by [2]. The regular increase in CO 2 emissions over the cycle suggests the influence of animal weight [3], which results from an increase in the metabolic rate and in CO 2 production due to breathing [14].

Variation of CO 2 Concentrations and Emission with Outdoor Temperature
The daily behavior of the CO 2 concentration was inverse to the evolution of the outdoor temperature ( Figure 3A), with the highest concentrations occurring at night. This resulted in a negative correlation, with a value of r = −0.695 for the cycle, which was above the value obtained by Ni et al. [46] for two manure-belt layer hen houses.
As shown in Figure 3B, during the first three days of the cycle, with TS = 26 °C, the outdoor temperature and CO2 emissions followed a similar pattern because of the effects of outdoor temperature on the ventilation system. On the following days, CO2 emissions decreased steadily until day 25, when outdoor temperature started to increase. During this interval, both variables showed a weak, inverse correlation (r = −0.475), which was in agreement with the correlation found by Ni et al. [46] for laying hens. This means that minimum emissions occurred at maximum outdoor temperatures. From that day until the end of the cycle, emissions followed a daily oscillation that was parallel to that of outdoor temperatures.

Variation of CO2 Concentrations and Emissions with Ventilation Flow
The ventilation flow was highly reduced during the first days of the cycle, until day 25, with a mean of 0.17 m 3 s −1 and a maximum of 0.50 m 3 s −1 (Figure 4). After that, a transition stage began for three days with a mean of 0.33 m 3 s −1 and a maximum of 0.82 m 3 s −1 . From day 28, ventilation flow was significantly increased, with a mean of 0.74 m 3 s −1 and a peak of 2.02 m 3 s −1 . Consequently, CO2 concentrations varied depending on the ventilation flow, such that, as the flow increased, concentration decreased both throughout the cycle [13] and on a daily basis [6]. Maximum CO2 concentrations ( Figure 4A) of 9.50 g m −3 were measured during the first 25 days, when the highest mean value of 3.63 g m −3 was reached. This means that, as stated by [23] and contrary to what is usually anticipated, maximum CO2 concentrations occurred when the animals were younger. Furthermore, as the ventilation flow increased, the CO2 concentration decreased near the fan, and, therefore, in the building [24,25,47]. Thus, higher ventilation rates involved lower CO2 concentrations inside the facilities, albeit with higher emission rates [6].
The relationship between CO2 concentration (CCO2 in g m −3 ) and the flow of air extracted through the fan (Q in m 3 s −1 ) during the cycle ( Figure 5A) is given by the following equation: The correlation coefficient between the CO2 concentration and ventilation flow is r = 0.82. As shown in Figure 3B, during the first three days of the cycle, with T S = 26 • C, the outdoor temperature and CO 2 emissions followed a similar pattern because of the effects of outdoor temperature on the ventilation system. On the following days, CO 2 emissions decreased steadily until day 25, when outdoor temperature started to increase. During this interval, both variables showed a weak, inverse correlation (r = −0.475), which was in agreement with the correlation found by Ni et al. [46] for laying hens. This means that minimum emissions occurred at maximum outdoor temperatures. From that day until the end of the cycle, emissions followed a daily oscillation that was parallel to that of outdoor temperatures.

Variation of CO 2 Concentrations and Emissions with Ventilation Flow
The ventilation flow was highly reduced during the first days of the cycle, until day 25, with a mean of 0.17 m 3 s −1 and a maximum of 0.50 m 3 s −1 (Figure 4). After that, a transition stage began for three days with a mean of 0.33 m 3 s −1 and a maximum of 0.82 m 3 s −1 . From day 28, ventilation flow was significantly increased, with a mean of 0.74 m 3 s −1 and a peak of 2.02 m 3 s −1 . Consequently, CO 2 concentrations varied depending on the ventilation flow, such that, as the flow increased, concentration decreased both throughout the cycle [13] and on a daily basis [6]. Maximum CO 2 concentrations ( Figure 4A) of 9.50 g m −3 were measured during the first 25 days, when the highest mean value of 3.63 g m −3 was reached. This means that, as stated by [23] and contrary to what is usually anticipated, maximum CO 2 concentrations occurred when the animals were younger. Furthermore, as the ventilation flow increased, the CO 2 concentration decreased near the fan, and, therefore, in the building [24,25,47]. Thus, higher ventilation rates involved lower CO 2 concentrations inside the facilities, albeit with higher emission rates [6]. CO2 emissions ( Figure 4B) increased with the age of the piglets, in agreement with Stin et al. [16]. Mean CO2 emissions of 2.21 mg s −1 per animal were found for piglets with a mean weight of 11.39 kg during the cycle, although there was a sharp increase from day 28, with a peak of 12.34 mg s −1 . Throughout the cycle, increasing the ventilation flow caused a rise in emissions, as observed for the fattening pigs [6,7]. As a consequence, CO2 emissions (ECO2 in mg s −1 ) and the flow of air extracted through the fan (Q in m 3 s −1 ) showed a linear relationship ( Figure 5B), which is given by the following equation: The correlation coefficient between CO2 emissions and ventilation flow is r = 0.85. The relationship between CO 2 concentration (C CO2 in g m −3 ) and the flow of air extracted through the fan (Q in m 3 s −1 ) during the cycle ( Figure 5A) is given by the following equation: The correlation coefficient between the CO 2 concentration and ventilation flow is r = 0.82.
(A) (B)  Table 5 shows the mean performance of the 10 min and 60 min prediction models after 40 iterations. • measured values throughout the cycle. CO 2 emissions ( Figure 4B) increased with the age of the piglets, in agreement with Stin et al. [16]. Mean CO 2 emissions of 2.21 mg s −1 per animal were found for piglets with a mean weight of 11.39 kg during the cycle, although there was a sharp increase from day 28, with a peak of 12.34 mg s −1 . Throughout the cycle, increasing the ventilation flow caused a rise in emissions, as observed for the fattening pigs [6,7]. As a consequence, CO 2 emissions (E CO2 in mg s −1 ) and the flow of air extracted through the fan (Q in m 3 s −1 ) showed a linear relationship ( Figure 5B), which is given by the following equation:

Neural Networks for the Prediction of CO2 Emissions
The correlation coefficient between CO 2 emissions and ventilation flow is r = 0.85. Table 5 shows the mean performance of the 10 min and 60 min prediction models after 40 iterations. Expectedly, the 10 min prediction was more accurate than the hourly prediction, although statistical differences were minimal. In particular, r values of 0.63 and 0.56 were obtained with the 10 min and 60 min prediction models, respectively, whereas the RMSE values were 1.21 and 1.27 mg s −1 , respectively. The prediction error of the models with regard to measured data in absolute terms (RMSE) was associated with very similar relative values (MARE), namely 0.23 for the 60 min prediction and 0.25 for the 10 min prediction. Figure 6 shows these differences. Furthermore, the hourly prediction model showed greater difficulty in predicting the peaks of CO 2 emission. although statistical differences were minimal. In particular, r values of 0.63 and 0.56 were obtained with the 10 min and 60 min prediction models, respectively, whereas the RMSE values were 1.21 and 1.27 mg s −1 , respectively. The prediction error of the models with regard to measured data in absolute terms (RMSE) was associated with very similar relative values (MARE), namely 0.23 for the 60 min prediction and 0.25 for the 10 min prediction. Figure 6 shows these differences. Furthermore, the hourly prediction model showed greater difficulty in predicting the peaks of CO2 emission. The prediction results were limited mainly by the size of the training period and the differences between the behavior of the series in the training stage and the testing stage. As shown in Figure 6, the period for the data chosen as the training data corresponded to a stage of certain stability in emission values, while the emissions showed greater daily oscillations during the testing stage. These differences in the series limited the performance of the model and could account for its poor performance compared to the model proposed in [48], which returned an r value near 0.99 using a multilayer perceptron neural network. However, other authors [37] obtained an r 2 of 0.733 and a MARE of 0.025 using an ANN prediction model of GHG emissions in a farm for calves. Xie et al., 2017 [36], used an ANFIS model to predict ammonia emissions in a fattening room for pigs and found an r 2 of 0.635 and 0.648, with a MARE of 0.312 and 0.237, in contrast to the values of 0.23 and 0.25 reported above. In the discussed cases, the available dataset was larger than the one used in this study. Self-learning in neural networks with a larger dataset would lead to a better performance of the models, particularly because two of the input variables (ventilation flow and CO2 concentration) were key parameters in the emissions. The prediction results were limited mainly by the size of the training period and the differences between the behavior of the series in the training stage and the testing stage. As shown in Figure 6, the period for the data chosen as the training data corresponded to a stage of certain stability in emission values, while the emissions showed greater daily oscillations during the testing stage. These differences in the series limited the performance of the model and could account for its poor performance compared to the model proposed in [48], which returned an r value near 0.99 using a multilayer perceptron neural network. However, other authors [37] obtained an r 2 of 0.733 and a MARE of 0.025 using an ANN prediction model of GHG emissions in a farm for calves. Xie et al., 2017 [36], used an ANFIS model to predict ammonia emissions in a fattening room for pigs and found an r 2 of 0.635 and 0.648, with a MARE of 0.312 and 0.237, in contrast to the values of 0.23 and 0.25 reported above. In the discussed cases, the available dataset was larger than the one used in this study. Self-learning in neural networks with a larger dataset would lead to a better performance of the models, particularly because two of the input variables (ventilation flow and CO 2 concentration) were key parameters in the emissions.

Innovative Potential of the Results
This paper focuses on CO 2 concentrations and emissions in pig farms during weaning, the production stage with the largest variations in values obtained for emissions [5]. Such variations may be related to the complexity of the farm climate control system, which has to meet the strict environmental requirements of piglets. Furthermore, these requirements change considerably throughout the cycle. For this reason, conventional farms usually have air conditioning systems that include heating and forced ventilation. These were the conditions for this research, performed in a conventional farm, during the complete transition cycle, from the weaning of piglets to their transfer to fattening. New values were provided for this stage, which requires deeper study in terms of the quantification of GHG concentrations and emissions [15,34]. CO 2 is the gas that contributes the most to the global emissions of greenhouse gases in pig production, accounting for approximately 81% [5]. Therefore, estimating CO 2 emissions provides highly relevant information for global estimations. CO 2 concentrations can be measured affordably, reliably, and with little maintenance using infrared sensors, which can be implemented on farms. Yet, the large number of rooms in transition farms would substantially increase the costs [49]. Moreover, for the estimation of emissions, the flow of the ventilation system must be determined. Ventilation flow may be obtained using the values provided by the controller, which can be easily measured, along with the fan curves or through previous calibrations using an anemometer.
This study evidenced the relationship between CO 2 concentrations and emissions with the different operating parameters of the climate control system, namely setpoint temperature or ventilation flow, and with outdoor temperature, which directly influences climate control. By using these parameters, the CO 2 concentrations and emissions can be estimated for any farm at any given moment, because 10 min values are used. In addition, we proposed Equations (6) and (7), which allow for a simple and direct estimation of the CO 2 concentrations and emissions with high correlation indexes. Furthermore, because CO 2 concentrations and emissions are linked to farm control parameters, emissions can also be regulated by operating the climate control system.
Finally, generating neural network-based models for 10 min and 60 min CO 2 emissions allows for the prediction of the evolution of the study variables based on the input variables, namely flow extracted through the fan, temperature inside the building, and CO 2 concentration, which provides a deeper understanding of the problem and the possibility to regulate emissions. In fact, good results have been obtained in studies focused on the optimization of environmental conditions in buildings based on machine learning systems [50]. These predictive systems can be incorporated into climate control systems to automatically optimize concentrations, consequently improving animal welfare, and emissions, consequently improving the environment.
In addition, an optimizer could be designed to simultaneously achieve a suitable distribution of temperatures and pollutant concentrations, yet using another model to predict indoor concentrations.

Conclusions
The following conclusions can be drawn from the analysis of variations in CO 2 concentration and emissions in a conventional farm building with a fully slatted floor and mechanical ventilation for weaned piglets from 6.9 to 17.0 kg LW, and the relationship of such variations with setpoint temperature, outdoor temperature, and ventilation flow during a complete production cycle:

1.
Generally, the ventilation flow increased with the reduction in setpoint temperature as the animals grew, which caused a reduction in CO 2 concentration in the building. The mean value of the CO 2 concentration was 3.12 g m -3 . Maximum concentrations were obtained during the first days of the cycle, when ventilation was restricted due to the demanding thermal requirements of the piglets and their susceptibility to air currents. 2.
CO 2 emissions increased throughout the cycle. The emission pattern matched the pattern of outdoor temperatures when the ventilation flow was low and setpoint temperatures were high, at the start of the cycle. On the contrary, with higher ventilation flows and lower setpoint temperatures, the daily evolution of CO 2 emissions was inverse to the evolution of the outdoor temperature. Emissions of CO 2 showed a mean of 2.21 mg s −1 per animal, which was equivalent to 0.195 mg s −1 kg −1 , with a total emission per animal of 7.05 kg at the end of the cycle.

3.
Mathematical expressions for 10 min values of CO 2 concentrations and emissions were obtained based on ventilation flow, a variable controlled by the climate control system, with r values of 0.82 and 0.85, respectively, which allowed for simple and direct quantification. 4.
Using two neural networks, the 10 min and 60 min prediction models for CO 2 emissions reached r values of 0.63 and 0.56. These results were mainly limited by the size of the training period, as well as by the differences between the behavior of the series in the training stage and the testing stage.

5.
Both the equations and the ANN models for farm emissions allowed for the prediction of the values of emissions from the variables involved in environmental control. Therefore, the proposed equations and models could be integrated into climate control systems, thus allowing for emission regulation.