# Enhancing Ammonia Concentration Prediction with a Transfer-Learning-Based Model: Application in a Pig Farm

**Authors:** Sunhyoung Lee, Rack-Woo Kim, Hakjong Shin, Sang-Shin Lee, Won-Gi Choi

PMC · DOI: 10.3390/ani16040609 · Animals : an Open Access Journal from MDPI · 2026-02-14

## TL;DR

A new AI model using transfer learning accurately predicts ammonia levels in pig farms, even with limited data, helping improve animal and worker health.

## Contribution

A transfer-learning-based model for ammonia prediction in pig farms that outperforms traditional methods with sparse data.

## Key findings

- Transfer learning models outperformed standalone models across all data collection intervals.
- Random Forest and XGBoost models achieved high accuracy with R2 of 0.969 and MAPE below 5%.
- The model supports sustainable pig farming by reducing reliance on costly physical sensors.

## Abstract

Pig farms around the world are becoming larger and more intensive. This can lead to high levels of ammonia gas, which can adversely affect the health of pigs and workers and cause strong odours around farms. Measuring this gas with physical sensors at every farm is costly and can be difficult to maintain. In this study, we built a computer-based model to predict ammonia concentrations using data collected at commercial pig farms, including the number and weight of pigs, indoor temperature and humidity, and the rate of air exchange. The model was first trained on detailed data from one farm and then tested for its applicability to another farm with only a small amount of data. The adapted model predicted ammonia concentrations more accurately than a model trained only on the smaller local dataset. This indicates that farms with limited data can still obtain accurate predictions of harmful gas levels by using knowledge learned from other farms. Such tools can help farmers improve animal welfare, protect workers and nearby residents, and support more sustainable and environmentally friendly pig production.

Globally, the swine industry is a major component of agricultural production, and the increasing scale and intensification of pig farming have heightened concerns about NH3 emissions. As farms expand and adopt smart farming technologies, there is a need for reliable prediction of NH3 concentrations without relying solely on costly physical sensors. In this study, we developed an artificial intelligence-based prediction model for NH3 concentration in commercial pig houses and examined the effects of data collection intervals and learning strategies. We compared a standalone model trained only on local data with a transfer learning model that adapts a pre-trained model to a target farm with limited data. Transfer learning consistently outperformed the standalone approach across all data collection intervals (10, 20, 30 and 60 min). The best-performing Random Forest and XGBoost models achieved a coefficient of determination (R2) of 0.969, root mean square error (RMSE) of about 1.0 ppm and mean absolute percentage error (MAPE) below 5%. These results show that transfer learning can provide accurate NH3 predictions in swine housing even with sparse data, supporting more sustainable and data-efficient environmental management.

## Linked entities

- **Chemicals:** ammonia (PubChem CID 222), NH3 (PubChem CID 222)

## Full-text entities

- **Diseases:** injury to (MESH:D014947)
- **Chemicals:** CH4 (MESH:D008697), nitrogen (MESH:D009584), Ammonia (MESH:D000641), CO2 (MESH:D002245)
- **Species:** Homo sapiens (human, species) [taxon 9606], Sus scrofa (pig, species) [taxon 9823]

## Full text

_Full body text omitted from this summary view._ Fetch the complete paper as Markdown: https://tomesphere.com/paper/PMC12937439/full.md

## Figures

16 figures with captions in the complete paper: https://tomesphere.com/paper/PMC12937439/full.md

## References

40 references — full list in the complete paper: https://tomesphere.com/paper/PMC12937439/full.md

---
Source: https://tomesphere.com/paper/PMC12937439