<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Intelligent information system for the determination of iron in coagulants based on a neural network</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Andrii Safonyk</string-name>
          <email>a.p.safonyk@nuwm.edu.ua</email>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Maksym Mishchanchuk</string-name>
          <email>mishchanchuk_ak17@nuwm.edu.ua</email>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Volodymyr Lytvynenko</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Kherson National Technical University</institution>
          ,
          <addr-line>Kherson, 73009</addr-line>
          ,
          <country country="UA">Ukraine</country>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>National University of Water and Environmental Engineering</institution>
          ,
          <addr-line>11 Soborna St, Rivne, 33028</addr-line>
          ,
          <country country="UA">Ukraine</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>The construction of an intelligent system for determining the concentration of iron in the coagulant by its color on the basis of a neural network is considered. Based on the analysis of different types of neural networks, the most suitable neural network architecture was selected to solve the problem of determining the concentration of iron in the coagulant. The process of architecture design, analysis of teaching methods, data preparation for neural network training to determine the concentration iron in the coagulant by its color is described. Developed the structural and functional scheme of the neural network, which consists of input, hidden and output layers, activation functions are described. Analyzed the accuracy of neural network learning by comparing data obtained using different optimizers using a TensorFlow library. The developed web application can be used as a component of information and analytical system of automated control electrocoagulation cleaning technological process.</p>
      </abstract>
      <kwd-group>
        <kwd>1 Neural net</kwd>
        <kwd>TensorFlow</kwd>
        <kwd>iron concentration</kwd>
        <kwd>coagulant</kwd>
        <kwd>intelligent information system</kwd>
        <kwd>photocolorimeter method</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1. Introduction</title>
      <p>Wastewater treatment is one of the problems of modern humanity. Recently, small water treatment
plants have become popular for water purification. Equipping water treatment facilities with such
systems is especially important for agriculture, light industry, etc. But the use of reagents leads to the
creation of services to ensure their delivery and storage, which is costly compared to electrochemical
methods, which in turn allow to extract reagents on site from available raw materials. One of the most
promising methods that provide this opportunity is the electrocoagulation method. Currently, more
and more attention is paid to the study of this process using mathematical models, which helps to
improve the design features of the device and operating costs, as well as to predict the efficiency of
the process in a wide range of operations with minimal production costs. Also, these researches are
the basis for the development of automated control systems for electrocoagulation processes. The
process of obtaining a coagulant by electrocoagulation involves complex and expensive field
experiments to determine the content of a useful element (iron) in the coagulant. One of the laboratory
methods for finding iron in a coagulant is the photocolorimeter method. As for photocolometry
technologies, it is the development of technology for the absorption of light by matter due to the
visible spectrum, the conversion of light energy into electrical energy. This technology allows you to
more accurately and quickly assess the quality of multicomponent compounds. In addition, this
method is included in the standardized methods for determining the iron content in water, because the
water color intensity and the optical density of the medium change with changing iron concentration.
At present, almost no sensors for determining the concentration of iron coagulant in real time, so
urgent task is to develop an automated information system for the electrochemical production of
coagulant based on photocolorimeter analysis.</p>
      <p>Problem formulation. Given that the change in the concentration of iron in water changes the color
and color intensity of the solution, the experimental setup for laboratory research was decided to
supplement the automated information system that will analyze the color and intensity of light in
realtime.</p>
    </sec>
    <sec id="sec-2">
      <title>2. Related works</title>
      <p>
        During the analysis of literature sources it was found that a number of authors conducted research
using photocolometry and photocolometric analysis, so in [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ] developed a digital colorimeter with a
mobile application for iOS, using Euclidean distance theory to determine the content that detects color
components, remembering the data of red, green and blue, as well as the value of hue, saturation,
brightness calculated using standard color theory. A simple and quite effective method for
determining the concentration of iron in water samples according to the rules of the United States
Environmental Protection Agency is shown in [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ]. In the research [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ], the iron content in water was
determined using digital colorimetry of the image using a webcam. The least squares regression was
used to obtain an equation describing the dependence of iron content on color, based on shades of red,
green and blue, as well as their saturation and transparency. Two methods for determining the
concentration of chromium (Cr) and iron (Fe) are described in [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ]. All this work is based on tests to
determine the concentration in the laboratory, which is very expensive and time consuming. In [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ], a
portable device was developed that allows on-site colorimetric analysis and offers wide availability
with limited resources. The article [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ] describes the development of a mobile colorimetric analysis
tool - PhotoMetrix, which uses simple linear regression methods for one-dimensional analysis and
analysis of the main components for multidimensional analysis of research. These images are
captured by the device main camera and converted into red, green and blue histograms.
      </p>
      <p>Today there are a large number of different types of neural networks, as well as options for
implementing networks of the same type. Among the different types of neural networks, the most
common are:
1. Multilayer perceptron;
2. Convolutional neural network;
3. Recurrent neural network.</p>
      <p>Consider in more detail the networks types.</p>
      <p>
        Multilayer Perceptron (MLP) - is a class of direct artificial network that has at least three layers.
The first is the input layer with neurons from I1 to In, the second is the hidden layer with neurons from
H1 to Hm and the third is the output layer with neurons from O1 to Ok. These layers are connected so
that each neuron of the previous layer is connected to each neuron of the next layer [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ] (see Fig. 1).
There can be more than one hidden layer, and networks that contain multiple hidden layers are called
"deep" neural networks. MLP neural networks are often used to solve classification and forecasting
problems [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ].
      </p>
      <p>Convolutional neural networks are a class of deep neural networks that are widely used to analyze
visual images. Such neural networks use mathematical convolution operations. These neural networks
have the same structure as MPL networks.</p>
      <p>
        Recurrent neural networks are a class of networks in which connections between nodes form a
time-oriented graph. Such networks include long/short term memory networks [
        <xref ref-type="bibr" rid="ref9">9</xref>
        ] (LSTM). The
structure of such a network is shown in the Figure 2, where neurons from I1 to In is input layer
neurons, from H1 to Hm is hidden layer neurons with memory and repeat possibility, from O1 to Ok is
output layer. This neural network is often used for word sequence analysis, speech recognition, or
handwriting. These neural networks do not work well with data that can be represented as tables.
      </p>
      <p>The problem of determining the concentration of iron in the coagulant by its color can be
attributed to the class of problems of pattern recognition based on the classification of input data. The
most common type of neural networks for this class of problems are multilayer perceptron.</p>
      <p>The developed neural network has an input and output layer, between which there are two hidden
layers (see Fig 3). Input layer has 5 neurons and activation function is hyperbolic tangent. In two
hidden layers of 10 neurons and with the seul and relu activation functions, respectively. In the source
layer 1 neuron and as an activation function used the exponential function.</p>
    </sec>
    <sec id="sec-3">
      <title>3. Proposed methodology</title>
      <p>To solve this problem, the software for the Raspberry Pi 4 microcomputer and the connected
TCS230 color sensor was developed. The developed software determines the concentration of iron in
the coagulant using a neural network.</p>
      <p>To select the type of network that will be used to solve the problem of determining iron in the
coagulant, consider in more detail the networks types.</p>
      <p>The input for the neural network is the hue (one of the three main color characteristics along with
saturation and brightness) parameter from the HSL color model. The initial result of the neural
network is the concentration of iron in the coagulant.</p>
      <p>To generate a training and test dataset, a laboratory research of various samples of coagulant was
performed, where the concentration of iron in the coagulant and RBG parameters for each of these
samples were determined (see Fig 4).</p>
      <p>On the table 1 shows the results of the process experimental research, namely: determining the
concentration of trivalent iron and the color of the substance at different times.
the concentration of iron in the coagulant over time. Based on the obtained expressions, 3600 HUE
points and iron concentrations were generated (see Fig 5 a, b).</p>
      <p>1
2
3
5
6
7
8
9
10
+ 120°,   
+ 240°,</p>
      <p>1−|1−(
1
2
(
−</p>
      <p>+
+ 
),
=  ,
= 
=</p>
      <p>To teach the neural network, optimizer features from TensorFlow library that improve learning by
updating knowledge in the network are used. In order to choose the best optimizer for a neural
network, several neural networks with different optimizers were developed and analyzed. Next, each
neural network was trained using a generated dataset.</p>
      <p>In particular, 8 optimizers available in the TensorFlow library were investigated. As can be seen
from table 3, where the error is calculated as the standard deviation of the results obtained from the
neural network and the approximate data, some optimizers, such as Ftrl, Adadelta, do not follow the
neural network training, while others, such as SGD and RMSprop, teach the developed neural
network well. The SGD optimizer performed the best results with an error of 6.91% on the test
dataset.</p>
      <p>As can be seen from the figure 6 of the SGD optimizer has achieved this result in 20 epochs of
learning.</p>
      <p>After analyzing the learning speed of the neural network, the SGD optimizer was selected for in
software to determine the concentration of iron in the coagulant.</p>
      <p>Table 3
Optimizers mistake (standard deviation)</p>
      <sec id="sec-3-1">
        <title>Optimizer</title>
      </sec>
      <sec id="sec-3-2">
        <title>Mistake %</title>
        <p>SGD
6.91</p>
        <sec id="sec-3-2-1">
          <title>RMSprop 8.28</title>
        </sec>
        <sec id="sec-3-2-2">
          <title>Adam</title>
          <p>9.33</p>
        </sec>
        <sec id="sec-3-2-3">
          <title>Adadelta</title>
          <p>373.22</p>
        </sec>
        <sec id="sec-3-2-4">
          <title>Adagrad</title>
          <p>183.92</p>
        </sec>
        <sec id="sec-3-2-5">
          <title>Adamax 9.05</title>
        </sec>
        <sec id="sec-3-2-6">
          <title>Nadam</title>
          <p>10.84</p>
        </sec>
        <sec id="sec-3-2-7">
          <title>Ftrl 370.43</title>
          <p>For easy access to the measurement results of the sensor and the concentration determined by the
neural network, a web application which uses a Raspberry Pi 4 microcomputer as a server was
developed. The access to control panel (see Fig. 7) of this device can be established after connecting
this computer to the network at the network address of this device.</p>
          <p>a. Adadelta</p>
          <p>b. Adagrad
c. Adam</p>
          <p>d. Adamax
e. Ftrl
f. SGD
h. RMSprop</p>
          <p>Using the web interface, you can start the measurement process and see the history as well as the
current measurement values.</p>
          <p>
            The Vue.js [
            <xref ref-type="bibr" rid="ref10">10</xref>
            ] JavaScript framework was used to develop the web interface. The main selection
criteria were ease of use and much smaller size compared to similar React.js and Angular. Vue.js uses
a state manager to display data to the user.
          </p>
          <p>Vuex was used as such a state manager. States in such a manager are replaced by mutations that
require sharing in their network. This mechanism allows you to split the code that modifies the data
and retrieves it from the server.</p>
          <p>To implement communication with the server (see Fig 8), two libraries are used: the axios library
for executing asynchronous HTTP requests and the socket.io library for working with web-socket.</p>
          <p>The server part of the program is responsible for polling the color sensor, determining the iron
concentration based on the obtained color, processing user commands, recording the received and
calculated data in the database.</p>
          <p>
            The python framework Django was chosen to develop the server part [
            <xref ref-type="bibr" rid="ref11">11</xref>
            ].
          </p>
          <p>With the help of this framework, a service for data definition and storage was developed. It was
also used to create a web-socket server, which allows you to update the data on the web-panel in real
time.</p>
          <p>Consider in more detail the work of the server part of the program. When the user clicks the “Run”
button in the web interface, a request is sent to the web server being processed by Django. During this
process the data received in the request are validated, a check for an existing running process is made,
and in case if all the conditions are met, a record in the database of the newly started process is
created and the background process starts.</p>
          <p>When the background process starts, the connection to the web-socket server channel to transfer
data to the web panel is initialized. On the same communication channel, this process will stop after
the user clicks the "Stop" button on the web panel.</p>
          <p>After initialization (see Fig. 9) the infinite cycle is started. In this cycle at 1 second intervals the
color sensor is interrogated, the color parameters obtained from the RGB sensor are converted into
HSL color space, then the hue parameter is transmitted to the input of the trained neural network,
where it is converted into the concentration of iron in the coagulant. Then the parameters from the
color sensor, the converted color parameters and the determined concentration are stored in the
database and sent to the web-panel using a web-socket server.</p>
          <p>The condition for ending the cycle is that the user stops it and the server processes the
corresponding request with sending a message about the completion of the background process using
web-socket and updating the record in the process history after its completion.</p>
        </sec>
      </sec>
    </sec>
    <sec id="sec-4">
      <title>4. Conclusions</title>
      <p>The development and application of neural networks to determine the concentration of iron in the
coagulant by its color is considered. Software to determine the concentration of iron in the coagulant
in the form of a web application for displaying measurement data in real time and saving the
measurement history was developed. To solve this problem, the software for the Raspberry Pi 4
microcomputer and the connected TCS230 color sensor was developed. The developed software
determines the concentration of iron in the coagulant using a neural network. The color sensor
determines the color parameters: R, G, B, these parameters are translated into the color space HSL for
easier further work with color parameters. Different types of neural networks were considered, among
them the neural network that is best suited to solve the problem of determining the concentration of
iron by the color of the coagulant was chosen. Based on the analysis of the TensorFlow optimizers,
the SGD optimizer was selected with an error of 6.91% on the test dataset. An automated information
system for determining iron-containing coagulant based on photocolorimetric analysis has been
developed. It consists of a flowing opaque cell through which the investigated liquid is passed at a
constant flow rate, and a unit for processing and storing data which allows to reduce human
participation in the measurement process and to ensure the continuity of the measurement process due
to the lack of need for the sampling of the test material, as well as to reduce the cost of the
measurement process.</p>
    </sec>
    <sec id="sec-5">
      <title>5. References</title>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>P.</given-names>
            <surname>Masawat</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Harfield</surname>
          </string-name>
          ,
          <string-name>
            <given-names>N.</given-names>
            <surname>Srihirun</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Namwong</surname>
          </string-name>
          ,
          <article-title>Green Determination of Total Iron in Water by Digital Image Colorimetry, Analytical Letters</article-title>
          , volume
          <volume>50</volume>
          , issue
          <volume>1</volume>
          (
          <year>2017</year>
          )
          <fpage>173</fpage>
          -
          <lpage>185</lpage>
          . doi:
          <volume>10</volume>
          .1080/00032719.
          <year>2016</year>
          .
          <volume>1174869</volume>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>Sreenivasareddy</given-names>
            <surname>Annem</surname>
          </string-name>
          , Determination of Iron Content in Water, OPUS Open Portal to University Scholarship, Governors State University, Summer (
          <year>2017</year>
          )
          <fpage>1</fpage>
          -
          <lpage>19</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <surname>Juan</surname>
            <given-names>A. V. A.</given-names>
          </string-name>
          <string-name>
            <surname>Barros</surname>
            , Fagner Moreira de Oliveira, Guilherme de
            <given-names>O.</given-names>
          </string-name>
          <string-name>
            <surname>Santos</surname>
          </string-name>
          , Célio Wisniewski,
          <article-title>Pedro Orival Luccas, Digital Image Analysis for the Colorimetric Determination of Aluminum, Total Iron, Nitrite and Soluble Phosphorus in Waters, Analytical Letters</article-title>
          , volume
          <volume>50</volume>
          , issue
          <volume>2</volume>
          (
          <year>2017</year>
          )
          <fpage>414</fpage>
          -
          <lpage>430</lpage>
          . doi:
          <volume>10</volume>
          .1080/00032719.
          <year>2016</year>
          .
          <volume>1182542</volume>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>M. L.</given-names>
            <surname>Firdaus</surname>
          </string-name>
          ,
          <string-name>
            <given-names>W.</given-names>
            <surname>Alwi</surname>
          </string-name>
          ,
          <string-name>
            <given-names>F.</given-names>
            <surname>Trinoveldi</surname>
          </string-name>
          ,
          <string-name>
            <surname>I. Rahayu</surname>
          </string-name>
          ,
          <string-name>
            <given-names>L.</given-names>
            <surname>Rahmidar</surname>
          </string-name>
          ,
          <string-name>
            <given-names>K.</given-names>
            <surname>Warsito</surname>
          </string-name>
          ,
          <article-title>Determination of Chromium and Iron Using Digital Image-based Colorimetry</article-title>
          ,
          <source>Procedia Environmental Sciences</source>
          volume
          <volume>20</volume>
          (
          <year>2014</year>
          )
          <fpage>298</fpage>
          -
          <lpage>304</lpage>
          . doi:
          <volume>10</volume>
          .1016/j.proenv.
          <year>2014</year>
          .
          <volume>03</volume>
          .037.
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>G. S.</given-names>
            <surname>Luka</surname>
          </string-name>
          ,
          <string-name>
            <given-names>E.</given-names>
            <surname>Nowak</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Kawchuk</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Hoorfar</surname>
          </string-name>
          ,
          <string-name>
            <given-names>H.</given-names>
            <surname>Najjaran</surname>
          </string-name>
          ,
          <article-title>Portable device for the detection of colorimetric assays</article-title>
          ,
          <source>Royal Society Open Science</source>
          <volume>4</volume>
          <fpage>11</fpage>
          (
          <year>2017</year>
          ). doi: 171025. doi:
          <volume>10</volume>
          .1098/rsos.171025.
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <given-names>G. A.</given-names>
            <surname>Helfer</surname>
          </string-name>
          ,
          <string-name>
            <given-names>V. S.</given-names>
            <surname>Magnus</surname>
          </string-name>
          ,
          <string-name>
            <given-names>F. C.</given-names>
            <surname>Böck</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Teichmann</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M. F.</given-names>
            <surname>Ferrãoc</surname>
          </string-name>
          ,
          <string-name>
            <surname>A. B. da Costa</surname>
          </string-name>
          ,
          <article-title>PhotoMetrix: An Application for Univariate Calibration and Principal Components Analysis Using Colorimetry on Mobile Devices</article-title>
          ,
          <source>Journal of the Brazilian Chemical Society</source>
          ,
          <volume>28 2</volume>
          (
          <year>2017</year>
          )
          <fpage>328</fpage>
          -
          <lpage>335</lpage>
          . doi:
          <volume>10</volume>
          .5935/
          <fpage>0103</fpage>
          -
          <lpage>5053</lpage>
          .
          <fpage>20160182</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7]
          <string-name>
            <surname>Multilayer</surname>
            <given-names>perceptron</given-names>
          </string-name>
          ,
          <year>2020</year>
          . URL: https://en.wikipedia.org/wiki/Multilayer_perceptron.
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          [8]
          <string-name>
            <given-names>J.</given-names>
            <surname>Brownlee</surname>
          </string-name>
          .
          <article-title>When to Use MLP, CNN, and</article-title>
          RNN Neural Networks,
          <year>2019</year>
          . URL: https://machinelearningmastery.com/when-to
          <article-title>-use-mlp-cnn-and-rnn-neural-networks.</article-title>
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          <article-title>[9] Long short-term memory</article-title>
          ,
          <year>2021</year>
          . URL: https://en.wikipedia.
          <article-title>org/wiki/Long_short-term_memory.</article-title>
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          [10]
          <string-name>
            <surname>Vue</surname>
          </string-name>
          .js,
          <year>2021</year>
          . URL: https://en.wikipedia.org/wiki/Vue.js.
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          [11]
          <string-name>
            <surname>Django</surname>
            <given-names>(</given-names>
          </string-name>
          <source>web framework)</source>
          ,
          <year>2021</year>
          URL: https://en.wikipedia.org/wiki/Django_(web_framework).
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>