This is code and data for manuscript: "KGML-ag: A Modeling Framework of Knowledge-Guided Machine Learning to Simulate Agroecosystems: A Case Study of Estimating N2O Emission using Data from Mesocosm Experiments" Licheng Liu, Shaoming Xu, Zhenong Jin*, Jinyun Tang, Kaiyu Guan, Timothy J. Griffis, Matt D. Erickson, Alexander L. Frie, Xiaowei Jia, Taegon Kim, Lee T. Miller, Bin Peng, Shaowei Wu, Yufeng Yang, Wang Zhou, Vipin Kumar All the files belong to Prof. Zhenong Jin, University of Minnesota, UA. jinzn@umn.edu "code" foler includes code for data processing, model training, and results plotting. "trained_model_saved" includes all trained model so you can use to reproduce the results showed in the study; "data" includes all data presented in the study.