# Evaluation of Electrical Impedance Spectra by Long Short-Term Memory to Estimate Nitrate Concentrations in Soil

^{*}

## Abstract

**:**

## 1. Introduction

- The method of measuring nitrate concentration in soil based on the combination of EIS with LSTM networks is characterized for the first time.
- The advantage of a new feature selection method over conventional methods, especially random forest, is demonstrated for the first time, the advantage being a higher coefficient of determination between the actual nitrate concentration and the concentration predicted by the LSTM network fed with the selected features.
- The results presented improve the quantitative understanding of the potential of the described approach in the context of the low-cost, robust, fast, in situ, and soil property-independent measurement of nitrate concentrations in soils.

## 2. Materials and Methods

## 3. Results

#### 3.1. Feature Selection

#### 3.1.1. Feature Selection by Random Forest

#### 3.1.2. Feature Selection by Sequential Forward Selection (SFS) Based on LSTM

#### 3.1.3. Comparison

#### 3.2. Experimental Results for Nitrate Concentration Measurement

#### 3.3. Literature Comparison

## 4. Conclusions

## Author Contributions

## Funding

## Institutional Review Board Statement

## Informed Consent Statement

## Data Availability Statement

## Conflicts of Interest

## References

- Jakobs, I.; Grimm, F.; Keppner, L.; Hilliges, F. Nitratbericht 2020: Gemeinsamer Bericht der Bundesministerien für Umwelt, Naturschutz und nukleare Sicherheit sowie für Ernährung und Landwirtschaft (= Nitrate Report 2020: Joint Report of the Federal Ministries for […]); German Ministry for Food and Agriculture and German Ministry for the Environment, Nature Conservation and Nuclear Safety: Bonn, Germany, 2020. (In German)
- EN ISO 13395; 1996-07: Water Quality–Determination of Nitrite Nitrogen and Nitrate Nitrogen and the Sum of Both by Flow Analysis (CFA and FIA) and Spectrometric Detection. CEN: Brussels, Belgium, 1996.
- Narayana, B.; Sunil, K. A spectrophotometric method for the determination of nitrite and nitrate. Eurasian J. Anal. Chem.
**2009**, 4, 204–215. [Google Scholar] - Subhash, C.; Malik, A.; Zargar, M.Y.; Bhat, M.A. Nitrate Pollution: A menace to human, soil, water and Plant. Univ. J. Environ. Res. Technol.
**2011**, 1, 22–32. [Google Scholar] - Ilsemann, J.; Goeb, S.; Bachmann, J. How many soil samples are necessary to obtain a reliable estimate of mean nitrate concentration in an agricultural field? J. Plant Nutrition Soil Sci.
**2001**, 164, 585–590. [Google Scholar] [CrossRef] - Bifano, L.; Fischerauer, A.; Liedtke, A.; Fischerauer, G. Characterization of sand and sand-binder systems from the foundry industry with electrical impedance spectroscopy. J. Sens. Sens. Syst.
**2021**, 10, 43–51. [Google Scholar] [CrossRef] - Xu, Y.; Li, C.; Jiang, Y.; Guo, M.; Yang, Y.; Yang, Y.; Yu, Y. Electrical Impedance Spectroscopic Detection of E. Coils with Machine Learning. J. Electr. Soc.
**2020**, 167, 047508. [Google Scholar] [CrossRef] - Berecibar, M.; Gandiaga, I.; Villarreal, I.; Omar, N.; Van Mierlo, J.; Van den Bossche, P. Critical review of state of health estimation methods of Li-ion batteries for real applications. Renew. Sustain. Energy Rev.
**2016**, 56, 572–587. [Google Scholar] [CrossRef] - Itagaki, M.; Honda, K.; Hoshi, Y.; Shitanda, I. In-situ EIS to determine impedance spectra of lithium-ion rechargeable batteries during charge and discharge cycle. J. Electroanal. Chem.
**2015**, 737, 78–84. [Google Scholar] [CrossRef] - De Beer, D.J.; Joubert, T.-H. Validation of Low-Cost Impedance Analyzer via Nitrate Detection. Sensors
**2021**, 21, 6695. [Google Scholar] [CrossRef] [PubMed] - Grossi, M.; Parolin, C.; Vitali, B.; Riccò, B. Electrical Impedance Spectroscopy (EIS) characterization of saline solutions with a low-cost portable measurement system. Eng. Sci. Technol.
**2019**, 22, 102–108. [Google Scholar] [CrossRef] - Kanoun, O.; Tetyuev, A.; Tränkler, H. Boden feuchtemessung mittels Impedanzspektroskopie (= Soil moisture measurement with impedance spectroscopy). TM–Tech. Mess.
**2004**, 71, 475–485. (In German) [Google Scholar] [CrossRef] - Gavish, N.; Promislow, K. Dependence of the dielectric constant of electrolyte solutions on ionic concentration: A micro field approach. Phys. Rev. E.
**2016**, 94, 012611. [Google Scholar] [CrossRef] [PubMed] [Green Version] - Hasted, J.B. Aqueous Dielectrics; Chapman and Hall: London, UK, 1973; pp. 238–252. [Google Scholar]
- Ishai, P.B.; Talary, M.S.; Caduff, A.; Levy, E.; Feldman, Y. Electrode polarization in dielectric measurements: A review. Meas. Sci. Technol.
**2013**, 24, 102001. [Google Scholar] [CrossRef] - Kumaragamage, D.; Warren, J.; Spiers, G. Soil Chemistry. In Digging into Canadian Soils: An Introduction to Soil Science; Krzic, M., Walley, F.L., Diochon, A., Paré, M.C., Farrell, R.E., Eds.; Canadian Soc. Soil Sci.: Pinawa, MB, Canada, 2021; pp. 150–190. [Google Scholar]
- Rockström, J.; Steffen, W.; Noone, K.; Persson, Å.; Chapin, F.S.; Lambin, E.F.; Lenton, T.M.; Scheffer, M.; Folke, C.; Schellnhuber, H.J.; et al. A safe operating space for humanity. Nature
**2009**, 461, 472–475. [Google Scholar] [CrossRef] [PubMed] - Zoltán, L.; Tamás, K. A generalized model of the equivalent circuits in the electrochemical impedance spectroscopy. Electrochim. Acta
**2020**, 363, 137199. [Google Scholar] [CrossRef] - Schönleber, M.; Klotz, D.; Ivers-Tiffée, E. A Method for Improving the Robustness of linear Kramers-Kronig Validity Tests. Electrochim. Acta
**2014**, 131, 20–27. [Google Scholar] [CrossRef] - Gao, P.; Zhang, C.; Wen, G. Equivalent circuit model analysis on electrochemical impedance spectroscopy of lithium metal batteries. J. Pow. Sourc.
**2015**, 294, 67–74. [Google Scholar] [CrossRef] - Taylor, S.R.; Gileadi, E. Physical Interpretation of the Warburg Impedance. Corrosion
**1995**, 51, 664–671. [Google Scholar] [CrossRef] - Brug, G.J.; van den Eeden, A.L.G.; Sluyters-Rehbach, M.; Sluyters, J.H. The analysis of electrode impedances complicated by the presence of a constant phase element. J. Electroanal. Chem.
**1984**, 176, 275–295. [Google Scholar] [CrossRef] - Nohl, M.; Raut, G.; Wolf, S.E.; Duyster, T.; Dittrich, L.; Vinke, I.C.; Eichel, R.A.; De Haart, L.G.J. Analysis of the DRT as Evaluation of EIS Data Analysis. ECS-Trans.
**2021**, 103, 1403. [Google Scholar] [CrossRef] - Xia, J.; Wang, C.; Wang, X.; Bi, L.; Zhang, Y. A perspective on DRT applications for the analysis of solid oxide cell electrodes. Electrochim. Acta
**2020**, 349, 136328. [Google Scholar] [CrossRef] - Pandey, G.; Kumar, R.; Weber, R.J. Real time detection of soil moisture and nitrates using on-board in situ impedance spectroscopy. In Proceedings of the 2013 IEEE International Conference on Systems, Man, and Cybernetics, Manchester, UK, 13–16 October 2013; pp. 1081–1086. [Google Scholar] [CrossRef]
- Liakos, K.G.; Busato, P.; Moshou, D.; Pearson, S.; Bochtis, D. Machine Learning in Agriculture: A Review. Sensors
**2018**, 18, 2674. [Google Scholar] [CrossRef] - Hochreiter, S.; Schmidhuber, J. LSTM can solve hard long time lag problems. In Proceedings of the 10th Advances in Neural Information Processing Systems, Denver, CO, USA, 2–5 December 1996; pp. 473–479. [Google Scholar]
- Houdt, G.V.; Mosquera, C.; Nápoles, G. A Review on the long short-term memory model. Artificial Intell. Rev.
**2020**, 54, 5929–5955. [Google Scholar] [CrossRef] - Caponetto, R.; Guarnera, N.; Matera, F.; Privitera, E.; Xibilia, M.G. Application of Electrochemical Impedance Spectroscopy for prediction of Fuel Celldegradation by LSTM neural networks. In Proceedings of the 2021 29th Mediterranean Conference on Control and Automation (MED), PUGLIA, Italy, 22–25 June 2021; pp. 1064–1069. [Google Scholar] [CrossRef]
- Li, D.; Yang, D.; Li, L.; Wang, L.; Wang, K. Electrochemical Impedance Spectroscopy Based on the State of Health Estimation for Lithium-Ion Batteries. Energies
**2022**, 15, 6665. [Google Scholar] [CrossRef] - Kratsios, A.; Hyndman, C. NEU: A Meta-Algorithm for Universal UAP-Invariant Feature Representation. J. Mach. Learn. Res.
**2021**, 22, 4102–4152. [Google Scholar] [CrossRef] - Sin, S.; Cho, S.; Lee, P.; Abbas, M.; Lee, S.; Kim, J. Data-driven prediction of battery degradation using EIS-based robust features. In Proceedings of the 2022 IEEE Energy Conversion Congress and Exposition (ECCE), Detroit, MI, USA, 9–13 October 2022; pp. 1–5. [Google Scholar] [CrossRef]
- Tao, C.; Lu, J.; Lang, J.; Peng, X.; Cheng, K.; Duan, S. Short-Term Forecasting of Photovaltaic Generation Based on Feature Selection and Bias Compensation-LSTM Network. Energies
**2021**, 14, 3086. [Google Scholar] [CrossRef] - Sun, P.; Jiang, C.; Wang, X.; Yang, X. Short-Term Buidling Load Forecast Based on a Data-Mining Feature Selection and LSTM-RNN Method. IEEE Trans. Electr. Electr. Eng.
**2020**, 15, 1002–1010. [Google Scholar] [CrossRef] - Breiman, L. Random Forests. Mach. Learn.
**2001**, 45, 5–32. [Google Scholar] [CrossRef] [Green Version] - Menze, B.H.; Kelm, B.M.; Masuch, R.; Himmelreich, U.; Bachert, P.; Petrich, W.; Hamprecht, F.A. A comparison of random forest and its Gini importance with standard chemometric methods for the feature selection and classification of spectral data. BMC Bioinform.
**2009**, 10, 213. [Google Scholar] [CrossRef] [Green Version] - Strobl, C.; Boulesteix, A.L.; Zeileis, A.; Hothorn, T. Bias in random forest variable importance measures: Illustions, sources and a solution. BMC Bioinform.
**2007**, 8, 25. [Google Scholar] [CrossRef] - Luz Calle, M.; Urrea, V. Letter to the Editor: Stability of Random Forest importance measures. Brief. Bioinform.
**2011**, 12, 86–89. [Google Scholar] [CrossRef] [Green Version] - Nicodemus, K. Letter to the Editor: On the Stability and ranking of predictors from random forest variable importance. Brief. Bioinform.
**2011**, 12, 369–373. [Google Scholar] [CrossRef] [PubMed] [Green Version] - Daoud, J.I. Multicollinearity and Regression Analysis. J. Phys. Conf. Ser.
**2017**, 949, 012009. [Google Scholar] [CrossRef] - Breiman, L.; Friedman, J.H.; Olshen, R.A.; Stone, C.J. Classification and Regression Trees; Wadsworth: Belmont, CA, USA, 1984; Chapter 5; pp. 140–149. [Google Scholar]
- Bagshaw, D.; Moody, J.; Pattison, T. Soil health for vegetable production in Australia; Queensland Government: Queensland, Australia, 2010; p. 27.
- Ma, X.; Bifano, L.; Oehme, M.; Fischerauer, G. Validation of the Suitablitiy of Electrical Impedance Spectroscopy for the In-Situ Monitoring of Nitrate in Sandy Soil. ITG-Fachbericht 303 (= Proc. 21. GMA/ITG-Fachtagung Sensoren und Messsysteme, Nuremberg, Germany, May 10–11, 2022); VDE Verlag: Berlin, Germany, 2022; pp. 352–355. [Google Scholar]
- Ma, X.; Fischerauer, G. Investigation of long short-term memory artificial neural networks as estimators of nitrate concentrations in soils from measured electrical impedance. In Proceedings of the 2022 International Workshop on Impedance Spectroscopy (IWIS), Chemnitz, Germany, 27–30 September 2022; pp. 117–120. [Google Scholar] [CrossRef]
- Yeshno, E.; Arnon, S.; Dahan, O. Real-time monitoring of nitrate in soils as a key for optimization of agricultural productivity and prevention of groundwater pollution. Hydrol. Earth Syst. Sci.
**2019**, 23, 3997–4010. [Google Scholar] [CrossRef]

**Figure 1.**Contributions to the imaginary part ${\epsilon}_{\mathrm{r}}^{\u2033}={\epsilon}^{\u2033}/{\epsilon}_{0}$ of the relative permittivity of soil (after [14]). B: bound water relaxation; MW: Maxwell–Wagner effect; S: surface conductivity; X: crystal water relaxation.

**Figure 2.**Parallel-plate impedance sensor. (

**a**) Cross section. (

**b**) View of the right plate from the left. (

**c**) Photograph of the setup with impedance meter and computer.

**Figure 3.**Measured test cell conductance (

**a**) and susceptance (

**b**) as a function of the nitrate-N concentration (in mg/L) and of the water content (in g/L) in synthetic soil (quartz sand), and of frequency, reprinted from Ref. [43].

**Figure 4.**Feature association estimation (

**a**) and importance estimation (

**b**) using RF, reprinted from Ref. [44].

**Figure 6.**Nitrate-N concentrations predicted by RF-built regression models from measured impedance spectra of synthetic soil samples plus selected other physical variables. (

**a**) Results based on the conductance spectrum G as feature. (

**b**) Results with features G and ${\mathsf{\theta}}_{\mathrm{w}}$. (

**c**) Results with features G, ${\mathsf{\theta}}_{\mathrm{w}}$, and ${\mathsf{\rho}}_{\mathrm{b}}$. (

**d**) Results with features G, ${\mathsf{\theta}}_{\mathrm{w}}$, ${\mathsf{\rho}}_{\mathrm{b}}$, and B. Blue dots: estimation results for each of the 360 validation data sets. Straight lines: goal (predicted value = actual value). The R

^{2}values shown in each chart are the coefficients of determination.

**Figure 7.**Nitrate-N concentrations predicted by LSTM-built regression models from measured impedance spectra of synthetic soil samples plus selected other physical variables. (

**a**) Results based on the susceptance spectrum B as feature. (

**b**) Results with features B and ${\mathsf{\theta}}_{\mathrm{w}}$. (

**c**) Results with features B, ${\mathsf{\theta}}_{\mathrm{w}}$, and ${\mathsf{\rho}}_{\mathrm{b}}$. (

**d**) Results with features B, ${\mathsf{\theta}}_{\mathrm{w}}$, ${\mathsf{\rho}}_{\mathrm{b}}$, and G. Blue dots: estimation results for each of the 360 validation data sets. Straight lines: goal (predicted value = actual value). The R

^{2}values shown in each chart are the coefficients of determination between true and estimated concentrations.

**Table 1.**Hyperparameters to be optimized using Bayesian optimization with predefined parameter ranges.

No. of Hyperparameter | Description | Range | Type |
---|---|---|---|

1 | Number of LSTM layers, N | 1…3 | Integer |

2 | Numbers of neurons in each hidden layer | (1…100) × N | Integer × N |

3 | miniBatchSize ^{1} | 2…20 | Integer |

4 | initialLearnRate ^{1} | 10^{−3}…10^{−1} | Real |

^{1}Nomenclature of MATLAB R2021a Deep Learning Toolbox.

**Table 2.**Results of feature selection by SFS with the validation RMSE of the LSTM output as criterion to be minimized.

Step | Features | Validation RMSE, in mg/L | Optimum Value of Hyperparameter No. (cf. Table 1) | |||
---|---|---|---|---|---|---|

1 | 2 | 3 | 4 | |||

1 | B | 2.1920 | 2 | (25,75) | 18 | 0.005 |

2 | B and ${\mathsf{\theta}}_{\mathrm{w}}$ | 1.2364 | 2 | (60,12) | 16 | 0.007 |

3 | B, ${\mathsf{\theta}}_{\mathrm{w}}$, and G | 0.6873 | 2 | (89,99) | 12 | 0.001 |

4 | B, ${\mathsf{\theta}}_{\mathrm{w}}$, G, and ${\mathsf{\rho}}_{\mathrm{b}}$ | 0.1431 | 2 | (77,45) | 16 | 0.001 |

Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |

© 2023 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).

## Share and Cite

**MDPI and ACS Style**

Ma, X.; Bifano, L.; Fischerauer, G.
Evaluation of Electrical Impedance Spectra by Long Short-Term Memory to Estimate Nitrate Concentrations in Soil. *Sensors* **2023**, *23*, 2172.
https://doi.org/10.3390/s23042172

**AMA Style**

Ma X, Bifano L, Fischerauer G.
Evaluation of Electrical Impedance Spectra by Long Short-Term Memory to Estimate Nitrate Concentrations in Soil. *Sensors*. 2023; 23(4):2172.
https://doi.org/10.3390/s23042172

**Chicago/Turabian Style**

Ma, Xiaohu, Luca Bifano, and Gerhard Fischerauer.
2023. "Evaluation of Electrical Impedance Spectra by Long Short-Term Memory to Estimate Nitrate Concentrations in Soil" *Sensors* 23, no. 4: 2172.
https://doi.org/10.3390/s23042172