Machine learning approach to remove ion interference effect in agricultural nutrient solutions

High concentration agricultural facilities such as vertical farms or plant factories consider hydroponic techniques as optimal solutions. Although closed-system dramatically reduces water consumption and pollution issues, it has ion-ratio related problem. As the root absorbs individual ions with different rate, ion rate in a nutrient solution should be adjusted periodically. But traditional method only considers pH and electrical conductivity to adjust the nutrient solution, leading to ion imbalance and accumulation of excessive salts. To avoid those problems, some researchers have proposed ion-balancing methods which measure and control each ion concentration. However, those approaches do not overcome the innate limitations of ISEs, especially ion interference effect. An anion sensor is affected by other anions, and the error grows larger in higher concentration solution. A machine learning approach to modify ISE data distorted by ion interference effect is proposed in this paper. As measurement of TDS value is relatively robust than any other signals, we applied TDS as key parameter to build a readjustment function to remove the artifact. Once a readjustment model is established, application on ISE data can be done in real time. Readjusted data with proposed model showed about 91.6 ~ 98.3% accuracies. This method will enable the fields to apply recent methods in feasible status.


INTRODUCTION
Development of IoT applications enabled the propagation of smart farms around agricultural industries. Even small farm owners now adopts smart farm facilities to reduce human resource. Highly concentrated facilities such as vertical farm or plant factories are one of the greatest issue in smart farm area. Aqua cultural methods such as NFT(nutrient film technique), DWT(deep water technique), water dripping or aeroponics are now considered as optimal solutions for highconcentrated smart farms because it becomes significantly efficient to control nutritional environment of whole facility with hydroponic approaches.
Opened hydroponic system discards once-used nutrient solution because the nutritional ions are already uptaken by plant roots. This approach tries to supply stable and balanced nutrition to plants. However, the wastage of nutrition water is hazard to environment so closed hydroponic systems becomes popular [1]. Closed system recycles the nutrient solution so it significantly reduces the cost and possibility of pollution.
It is one of the most important issue in closed system to maintain nutritional balance. Traditional approaches measure electrical conductivity and pH of the nutrient solution to monitor the fertilization [2][3]. However, those methods cannot distinguish the imbalance of nutrient ions and accumulation of useless components, caused by the difference between absorption rate of individual ions at plant roots. It requires additional maintenance labors such as foliar spray to avoid nutrition disorder which may lead to poor yield or death of crops.
Researchers recently suggests application of the ion selective electrodes(ISEs) approaches to measure individual ion's concentration from the nutrient solution [1,[4][5][6]. Readjustment of low-concentrated ions with ion selective measurement seems to enable avoidance of nutrient balance collapse. However, applying ISEs on nutrient solution measurement have significant problem: ion interference effect.
ISEs acquires concentration of ion by measuring electrical potential. ISE has ion-selective permeable film and the ionexchange of specific ion fit for the film provides Nernst potential, described on equation (1). F is Faraday constant and z is the number of ions exchanged along the membrane.
However, because of the nature of ISE, ion-exchange along the membrane is interfered by other ions. This phenomenon is described with Nikolsky-Eisenman equation [7] given on equation (2) where is the activity, is the selectivity coefficient and is the exchange of interfering ion i along the membrane.
The activity parameter for target ion and the selectivity coefficients of all the other ions of solution are required to predict the magnitude of ion interference potential. It is not feasible. For example, Yamazaki's nutrient solution for lettuce [8] contains 23 different ions. Acquisition of those parameter with experiments to maintain agricultural fertilizer is not desirable. Liberti et al. suggested readjustment method using Gran's plots [9] but it also requires prior knowledge for some specific parameter.
We suggest a machine learning approach to train a readjustment function, which removes ion interference effect from ISE measured data without any prior knowledge chemicophysical parameter.

II. ION INTERFERENCE EFFECT
We measured ion interference effect with ISEs to figure out the exact magnitude of the artifact. Also the data was used for the machine learning algorithm.

A.
Equipments for experiment Ion selective electrodes were used to measure the concentration of ions. We used Vernier's Go Direct® sensor series. GDX-NO3 was used to measure NO3ion, and GDX-NH4 was used for NH4 + , GDX-CA was used for Ca 2+ , and GDX-K was used for K + ion concentration. The sensors were connected to Arduino to transform analog signal into digital value.
Yamazaki's nutrient solution for lettuce [8] was selected as experimental environment because it is one of the most popular fertilizer in hydroponics area. But we eliminated the low-concentrated ions in order to avoid ISE-unmeasurable ions. KNO3, Ca(NO3)2-4H2O and NH4H2PO4 were used to reproduce the simplified Yamazaki's solution. The experimental solution contains K + , NO3 -, Ca 2+ , NH4 + , which are measurable with ISEs, and HxPO4 3-x families which are the only unmeasurable value. The concentration of H + is measurable with pH meter but we did not measured it because pH of the solution is around 7 so we did not expect any significant interference effect on pH meter.

B.
Calibration with machine learning algorithm Vernier's manual recommended to measure 2 standard buffer solution to acquire 2 voltage value, and perform linear regression on exp(volt) term along the theoretical value of ion concentration. They presents voltage-concentration equation as equation (3), which fits for Nernst potential described on equation (1). Generally, α describes the sensitivity of sensor and β describes standard potential offset of the electrode.
However, we figured out that Vernier's ISE does not work as equation (3). 10 times of buffer solution measurement showed that the correlation between concentrations and exp(volt) values showed exponential behaviors. The distribution of measured buffer solution data is described on Figure 1.
It means that Vernier's ISE does not work robustly. The behavior of sensor in thin solution differs from the behavior in dense solution. The concentration of buffer solutions, measured voltage and coefficients for equation (4) of each ion is presented in Table 1. Coefficients are driven with linear regression between log scaled concentration and exp(volt) values. The R 2 for each regression lines are also listed on Table 1. Regression models with equation (4) fits for the experimental data.

C.
Ion interference effect measurement We prepared 100 times more concentrated version of simplified Yamazaki's solution. We added this ampoule 10 times to 1 liter water with 4 ISEs installed. The theoretical values of ionic concentration for each steps and the experimental values are presented on Table 2.
Comparison between the experimental values and the theoretical values are described on Figure 2. The interference effect becomes larger at higher-concentration status because the flux of undesirable ions through the membrane of ISE becomes greater magnitude of ion interference effect is understood as the distance between the blue and orange lines.

III. METHOD
A readjustment method to remove ion interference effect is proposed in this section. In order to provide a rapid and feasible solution to the industrial field, we avoided evaluation of chemicophysical parameters. We applied simple machine learning algorithm which doesn't even requires any GPU devices.

A.
Equipments The regression process was performed on Microsoft's Azure VM standard D4s v3, which has4 vcpus and 16 GiB memory. The operation system is ubuntu 18.04 and we used R and R Studio Server for data analysis and regression.

B.
Data preperation Experimental data on Table 2 from ion interference effect measurement was used. We randomly separated 3 columns for test data and the other 7 columns for training data. Column 5, 7 and 9 were selected as test data and the others were fed to the model for training.

C.
Readjustment method We applied simple readjustment method in order to application of the trained model on readjustment as simple as possible because real-time and on-site readjustment is one of the biggest issue in the agricultural industry [1].
As TDS(total dissolved solids) is calculated regardless of ion composition in the solution, we took TDS value as key independent variable. The readjustment method is described as equation (5), where Cr is readjusted value for concentration, CISE is experimentally driven value for concentration and μ is a function of TDS value.
We assumed the concentration of each ion and the magnitude of ion interference effect as functions of TDS in Yamazaki's nutrient solution system because the imbalance of ionic balance does not occur fast. Also, with continuous readjustment on the nutrient solution, the ionic balance is maintained continuously.  Regression of function TDS values were calculated from the theoretical value of ion concentrations from Table 2. TDS is calculated as equation (6). Mion is the molecular weight and [ion] is molarity.
And we expect the readjusted value Cr to converge toward theoretical value Ct. Therefore, we launched regression to fit equation (9).
The values of μ(TDS) driven from 7 points of training data are plotted on Figure 3 as blue dots.
As the behavior of voltage along ion concentration from equation (1) and the interference effect driven from equation (2) are both logarithm, we expected that the error correction coefficient μ to show logarithmic distribution. However, quadratic regression fit much better than log regression. Mean R 2 from log regression was 0.70615 while quadratic regression showed 0.96158. The regression lines are described as orange lines on Figure 3. Parameters for quadratic regression model equation (10) and R 2 values for the models are also presented in Table 3.
IV. EXPERIMENT

A. Evaluation on training data
To evaluate the trained model on training data, we calculated μ(TDS) from equation (10), rather than equation (9) because value from equation (9) will provide 100% correctness, which is meaningless. The driven μ are multiplied with CISE to show whether the ion interference effect were removed. The results are presented on Figure 4. The model removed 45.8752%, 63.2386%, 81.5443% and 92.434% of ion interference effect from K + , Ca 2+ , NO3and NH4 + . R 2 of Ca 2+ is greater than that of NO3but NO3showed better result.

B.
Evaluation on test data Evaluation on test data was performed by trained model. We apply untrained TDS value as input to μ function, and multiplied that to CISE of test data.

V. RESULTS
Test data was applied on the trained quadratic model. The result is described on Figure 5 and Table 3-4. The error was defined as equation (11), where C stands for both CISE and corrected concentration. Accuracy was defined as 100%error.
The errors on whole date are presented on Figure 3. Except only one case, column 5 from K + , proposed method successfully removed the ion interference effect. Especially, NH4 + model showed remarkable result. Average accuracy values are presented on Table 4. The model worked on both training data and test data. The accuracy between training data and test data from Ca + was significantly different. However, the proposed method successfully increased the accuracy of test data, 59.331%, into 93.209 %.

VI. CONCLUSION
Machine learning algorithm with low computational complexity to remove ion interference effect was presented. Ion interference effect exists and gets stronger in denser environment. Quadratic regression on equation (9) successfully removed ion interference effect from almost all the data point, except only one case. As the computational resource for using pre-trained quadratic model is small enough, the presented method is highly feasible to industries. Even an embedded device can run the inference process in milliseconds. We expect applying higher-variance machine learning algorithms such as deep neural network, rather than high-bias and low variance model such as quadratic regression, would enhance the ability of artifact removal.
ACKNOWLEDGMENT Special thanks to Janghun Lee for selecting ISE devices and establishing measurement pipeline with Arduino.  Table 4. Error rate of raw data and proposed method (in %) The column 5, 7 and 9 are training data and the other columns are used for training. Table 5. Accuracy of raw data and proposed method (in %)