<!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>Water Potability Classification using Neural Networks</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Patryk Rozynek</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Michal Rozynek</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Faculty of Applied Mathematics, Silesian University of Technology</institution>
          ,
          <addr-line>Kaszubska 23, 44100 Gliwice</addr-line>
          ,
          <country country="PL">POLAND</country>
        </aff>
      </contrib-group>
      <fpage>34</fpage>
      <lpage>39</lpage>
      <abstract>
        <p>Nowadays, the Internet of Things, intelligent systems are becoming very popular and wanted. These tools can be used for smart and fast analysis of diferent data. In this paper, we focused on the automatic analysis of water quality by the use of artificial intelligence methods. As the main tool for this analysis, k-nearest neighbor and artificial neural network were used. Both methods were tested, and the results were discussed in terms of selecting the best tool in the topic of water potability.</p>
      </abstract>
      <kwd-group>
        <kwd>eol&gt;water potability</kwd>
        <kwd>artificial neural network</kwd>
        <kwd>kNN algorithm</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1. Introduction</title>
      <p>in our project. The project was implemented using the
database available on the website https://www.kaggle.com/.</p>
      <p>
        Today, the Internet of Things (IoT) is one of the most The algorithm is based on counting the distance between
important areas of developing and practical implement- the given sample and each object in the training set. We
ing smart solutions. Especially, the last years show that used the Minkowsky algorithm to calculate the distance:
smart things can be used everything for diferent
management and systems. One such area is water management 
and automatic evaluation/analysis. In [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ], a system for (, ) = (∑︁ | − |)1/ (1)
water management was shown where sustainable net- =1
works were analyzed. Moreover, similar solutions were In this way, we obtain a table of distances from our
shown in [
        <xref ref-type="bibr" rid="ref11 ref2">2, 11</xref>
        ]. The authors of this research use deep sample. We just need to sort it so that the shortest
dismachine learning like a convolutional neural network for tances are at the front. The classification decision is then
the analysis of water pollination for agricultural irriga- made by voting ’k’ neighbors or ’k’ of the first objects in
tion resources. Not only in water management, machine the distance table. The result will be the value of the class
learning solutions are used, but also to detect and classify that was voted more times. If there are the same number
diferent objects on water. One such task is to analyze of votes for both variants of the class, then the algorithm
the ship passing some areas. In [
        <xref ref-type="bibr" rid="ref3 ref4 ref9">3, 4, 9</xref>
        ], two solutions chooses the first of them and votes for it. Therefore, it is
for taking an image on a river and used for classification recommended that the number of neighbors is odd.
purposes were presented. Both solutions show practical
potential in implementation based on performed real case 3. Artificial neural network
studies. All machine learning solutions in IoT solutions
uses a whole data [
        <xref ref-type="bibr" rid="ref10 ref5 ref6 ref7 ref8">5, 6, 7, 8, 10</xref>
        ] to analysis or extracted A neural network is a software modeled after the
operfeatures [
        <xref ref-type="bibr" rid="ref12 ref13 ref14 ref15">12, 13, 14, 15</xref>
        ]. In both cases, the results show ation of neurons in the human brain. They consist of
great accuracy in using these approaches. In this paper, three types of layers: input (it collects data and passes it
we propose a solution for analyzing the water by the use on), hidden (here the connections between neurons are
of two tools like K-nn and an artificial neural network. looked for, here the learning process takes place), and
output (collects conclusions, analysis results). Typically,
2. Methodology the neural network is made up of many layers. The first
layer - as in the case of images recorded, for example,
The algorithm classifies whether the water with the given by the optic nerves of a human - goes to raw input data.
properties is safe to drink. We used two classification Each subsequent layer receives data as a result of data
methods: the KNN algorithm. The code of the algorithms processing in the previous layer. What the last layer
prowere written in Python. Most of the article compares duces is the so-called System output. A neural network
these algorithms to see which one is more suitable for use functions like the human brain: each neuron carries out
its simple calculations, and the network made up of all
ICYRIME 2021 @ International Conference of Yearly Reports on neurons multiplies the potential of that calculation.
NeuInformatics Mathematics and Engineering, online, July 9, 2021 ral networks used in artificial intelligence are organized
p"atprraotzrr5o9z95@99s@tudsteundte.pnot.lpslo. plsll.(pMl .(PR.oRzoyznyenke)k); on the same principle - but with one exception: to
perCPWrEooUrckReshdoinpgs IhStpN:/c1e6u1r3-w-0s.o7r3g ©CCo2Em02mU1oCRnospLWyicreiognhsrtekfAostrthrtihboiusptpioanpPe4rr.0obIynctietesrenaaduttiihononragsl.s(CUCs(eCBpYEer4mU.0i)tR.te-d WundSe.roCrregat)ive fcoarnmbea asdpjeucsitficetdasakcc,othrdeincognlyn.eScetaiornchsibnegtwfoereinnfnoerumraotniosn
is the process of searching a specific set of documents
relating to the subject or object indicated in the query
or containing facts necessary for the user. However, this
process has not been precisely and finitely defined by
patterns, standards, or algorithms and is largely based
on heuristics, in this case, defined as a set of rules and
guidelines that may or may not lead to the right solution.
      </p>
      <p>For each neuron, the sum of the products of previous
neurons and associated synapses (weights) is calculated.</p>
      <p>The result is then passed on to the activation function.</p>
      <p>The formula for calculating the value of a neuron:
where o - output, w - weights, x - neurons The
activation function can be any function. It is often taken as
a hyperbolic tangent. After all the values for the
neurons in the hidden layer have been calculated, the output
layer is recalculated in the same way. This layer has
as many neurons as there are classes. Then the global
error is calculated based on the values from this layer.</p>
      <p>If the error is smaller, the weights that were used are
saved and the previous ones are forgotten. Heuristics
is a method of finding solutions for which there is no
guarantee of finding the optimal, or often even correct,
solution. These solutions are used, for example, when
the full algorithm is too expensive for technical reasons
or when it is unknown. The method is also used to find
approximate solutions, based on which the final result is
calculated using the full algorithm. The latter application
primarily applies to cases where heuristics are used to
direct the full algorithm to the optimal solution to reduce
the program runtime in a typical case without sacrificing
the quality of the solution.</p>
    </sec>
    <sec id="sec-2">
      <title>4. Description</title>
      <p>Pseudocode: Part of code in Python: (1)
• 2 - 3 (1) After getting the input data, the training
set is copied to the new facility
• 4 (1) A distance table is created for the training
set
• 5 - 6 (1) Minkowsky is called for each sample in
the training set. The first argument is an example
set of water parameters, and the second is another
sample from the training set.
• 3 - 5 (2) The distance is counted.
• 6 (2) The distance between the sample sample
and the comparison object to the distance table
is returned.
• 7 (1) The algorithm sorts the list of distances so
that the most similar cases are at the top of the list.
The same changes are performed on the training
set
• 7 8 - 9 (1) Now is the vote. The kof the first records
on the distance list are taken. Each neighbor votes
for the class they own.
• 10 (1) The class with the most votes is returned.</p>
      <p>If they have tied votes, the first class, Potable is</p>
    </sec>
    <sec id="sec-3">
      <title>5. Experiments</title>
      <p>5.1. KNN
The KNN algorithm achieved the following results
presented in Fig. 2. Based on Fig. 2, the accuracy of the
performed method shows very similar results. For analyzed
three diferent numbers of neighbors like k ∈ {1, 2, 3}
the accuracy was on the same level that is 50%. We can
say that the number of neighbors (on a small number
of parameters k is irrelevant for the classification task.
But more importantly, why is the efectiveness so low?
The base we used has drinking and non-drinking water
records with similar parameters. For example, the figure
below shows potable and non-potable water samples in
Fig. 3. As you can see, an example feature has
diferent values for potable and non-potable water. The next
example in the picture in Fig. 4.</p>
      <p>The Hardness trait for drinking water has a wider
range of values, but the average values are very close to
each other. To sum up, the use of knn algorithm seems
to be a tool that for a small number of parameters k the
results are not promising. The accuracy on a level of 50%
cannot be used in practical implementation.
5.2. Neural Network</p>
      <sec id="sec-3-1">
        <title>The set was divided into a training set and a validation set in proportion 1:10. As a result, the program counted</title>
        <p>faster and the results were almost the same. To check
which neural network is the best for our program, we
created 15 architectures of artificial neural networks with
a diferent number of hidden layers and the number of
neurons in these layers. Three of these nets were deep
nets and the rest were shallow. Each network has been
trained 1000 times. Additionally, the adopted parameters
were the same for all networks and amounted to: 1 =
0.1, 2 = 0.9 Ω =  =&lt; 0.2; 0.85 &gt;</p>
        <p>The obtained results and comparison for diferent
architectures were presented in Fig.5,6,7 and 8. Based on
these results artificial neural network shows much better
results then compared knn</p>
      </sec>
    </sec>
    <sec id="sec-4">
      <title>6. Conclusion</title>
      <sec id="sec-4-1">
        <title>After performing the tests and comparing the two clas</title>
        <p>sification methods, it can be easily stated that using an
artificial neural network the results are closer to the truth.</p>
        <p>An obstacle in the KNN classification was that the values
of each of the water properties were too similar. No
matter how many neighbors there were, the efect was the
same. It can be said that the algorithm guesses the result.</p>
        <p>No data manipulation, such as deleting one feature, gave
better results. In fact, it is also dificult to judge whether error, it changed less frequently. This is because the
netthe water is drinkable. With the characteristics listed in work has more neurons and therefore more weight. It is
the database, it is not possible to determine whether the more dificult for the network to change the weights so
water is potable with the KNN algorithm. When compar- that the next calculated global error is better. Some of the
ing the results of the deep network with the shallow one, weights may have changed for the better, but the network
it can be said that they are not very diferent. The two has not caught them because the error was not any less.
deep nets had the best two accuracies, but the third is The addition of the ability to remove some particles from
below average. Unfortunately to train a network with 5 the swarm made it possible to create new particles with
hidden layers and 6 neurons in each of them took almost random weights at startup. This is a good way to improve
an hour. In this type of network, looking at the global results without investing much in time. Especially if the
parameters 1 and 2 are 0.1 and 0.2 the particles tend to
be the best global particle, not to their best position. The
best results are obtained with a network with 5 hidden
layers and 2 neurons in this layer and reached 59,32%
and took almost 20 minutes</p>
      </sec>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>H. M.</given-names>
            <surname>Ramos</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>McNabola</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P. A.</given-names>
            <surname>López-Jiménez</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Pérez-Sánchez</surname>
          </string-name>
          ,
          <article-title>Smart water management towards future water sustainable networks</article-title>
          ,
          <source>Water</source>
          <volume>12</volume>
          (
          <year>2020</year>
          )
          <fpage>58</fpage>
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>H.</given-names>
            <surname>Chen</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Chen</surname>
          </string-name>
          ,
          <string-name>
            <given-names>L.</given-names>
            <surname>Xu</surname>
          </string-name>
          ,
          <string-name>
            <given-names>H.</given-names>
            <surname>Xie</surname>
          </string-name>
          ,
          <string-name>
            <given-names>H.</given-names>
            <surname>Qiao</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Q.</given-names>
            <surname>Lin</surname>
          </string-name>
          ,
          <string-name>
            <given-names>K.</given-names>
            <surname>Cai</surname>
          </string-name>
          ,
          <article-title>A deep learning cnn architecture applied in smart near-infrared analysis of water pollution for agricultural irrigation resources</article-title>
          ,
          <source>Agricultural Water Management</source>
          <volume>240</volume>
          (
          <year>2020</year>
          )
          <fpage>106303</fpage>
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>D.</given-names>
            <surname>Połap</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Włodarczyk-Sielicka</surname>
          </string-name>
          ,
          <string-name>
            <given-names>N.</given-names>
            <surname>Wawrzyniak</surname>
          </string-name>
          ,
          <article-title>Automatic ship classification for a riverside monitoring system using a cascade of artificial intelligence techniques including penalties and rewards</article-title>
          , ISA transactions (
          <year>2021</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>T.</given-names>
            <surname>Hyla</surname>
          </string-name>
          ,
          <string-name>
            <given-names>N.</given-names>
            <surname>Wawrzyniak</surname>
          </string-name>
          ,
          <article-title>Identification of vessels on inland waters using low-quality video streams</article-title>
          ,
          <source>in: Proceedings of the 54th Hawaii International Conference on System Sciences</source>
          ,
          <year>2021</year>
          , p.
          <fpage>7269</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>V.</given-names>
            <surname>Nourani</surname>
          </string-name>
          ,
          <string-name>
            <given-names>E.</given-names>
            <surname>Foroumandi</surname>
          </string-name>
          ,
          <string-name>
            <given-names>E.</given-names>
            <surname>Sharghi</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Dąbrowska</surname>
          </string-name>
          ,
          <article-title>Ecological-environmental quality estimation using remote sensing and combined artificial intelligence techniques</article-title>
          ,
          <source>Journal of Hydroinformatics</source>
          <volume>23</volume>
          (
          <year>2021</year>
          )
          <fpage>47</fpage>
          -
          <lpage>65</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <given-names>M.</given-names>
            <surname>Woźniak</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Wieczorek</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Siłka</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Połap</surname>
          </string-name>
          ,
          <article-title>Body pose prediction based on motion sensor data and recurrent neural network</article-title>
          ,
          <source>IEEE Transactions on Industrial Informatics</source>
          <volume>17</volume>
          (
          <year>2020</year>
          )
          <fpage>2101</fpage>
          -
          <lpage>2111</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7]
          <string-name>
            <given-names>Y.</given-names>
            <surname>Shao</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J. C.-W.</given-names>
            <surname>Lin</surname>
          </string-name>
          ,
          <string-name>
            <given-names>G.</given-names>
            <surname>Srivastava</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Guo</surname>
          </string-name>
          ,
          <string-name>
            <given-names>H.</given-names>
            <surname>Zhang</surname>
          </string-name>
          ,
          <string-name>
            <given-names>H.</given-names>
            <surname>Yi</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Jolfaei</surname>
          </string-name>
          <article-title>, Multi-objective neural evolutionary algorithm for combinatorial optimization problems</article-title>
          ,
          <source>IEEE Transactions on Neural Networks and Learning Systems</source>
          (
          <year>2021</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          [8]
          <string-name>
            <given-names>C.</given-names>
            <surname>Napoli</surname>
          </string-name>
          ,
          <string-name>
            <given-names>F.</given-names>
            <surname>Bonanno</surname>
          </string-name>
          , G. Capizzi,
          <article-title>Exploiting solar wind time series correlation with magnetospheric response by using an hybrid neuro-wavelet approach (2010)</article-title>
          <source>Proceedings of the International Astronomical Union</source>
          ,
          <volume>6</volume>
          (
          <issue>S274</issue>
          ), pp.
          <fpage>156</fpage>
          -
          <lpage>158</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          [9]
          <string-name>
            <surname>Brociek</surname>
            <given-names>R.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Magistris</surname>
            <given-names>G.D.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Cardia</surname>
            <given-names>F.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Coppa</surname>
            <given-names>F.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Russo</surname>
            <given-names>S.</given-names>
          </string-name>
          ,
          <article-title>Contagion Prevention of COVID-19 by means of Touch Detection for Retail Stores (</article-title>
          <year>2021</year>
          ) CEUR Workshop Proceedings,
          <volume>3092</volume>
          , pp.
          <fpage>89</fpage>
          -
          <lpage>94</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          [10]
          <string-name>
            <given-names>G.</given-names>
            <surname>Capizzi</surname>
          </string-name>
          ,
          <string-name>
            <given-names>G. Lo</given-names>
            <surname>Sciuto</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Napoli</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Woźniak</surname>
          </string-name>
          ,
          <string-name>
            <given-names>G.</given-names>
            <surname>Susi</surname>
          </string-name>
          ,
          <article-title>A spiking neural network-based long-term prediction system for biogas production (2020) Neural Networks</article-title>
          ,
          <volume>129</volume>
          , pp.
          <fpage>271</fpage>
          -
          <lpage>279</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          [11]
          <string-name>
            <surname>Brandizzi</surname>
            <given-names>N.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Bianco</surname>
            <given-names>V.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Castro</surname>
            <given-names>G.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Russo</surname>
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Wajda</surname>
            <given-names>A.</given-names>
          </string-name>
          ,
          <source>Automatic RGB Inference Based on Facial Emotion Recognition</source>
          (
          <year>2021</year>
          ) CEUR Workshop Proceedings,
          <volume>3092</volume>
          , pp.
          <fpage>66</fpage>
          -
          <lpage>74</lpage>
          ,
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          [12]
          <string-name>
            <given-names>G.</given-names>
            <surname>Lo Sciuto</surname>
          </string-name>
          , G. Capizzi,
          <string-name>
            <given-names>R.</given-names>
            <surname>Shikler</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Napoli</surname>
          </string-name>
          ,
          <article-title>Organic solar cells defects classification by using a new feature extraction algorithm and an ebnn with an innovative pruning algorithm</article-title>
          ,
          <source>International Journal of Intelligent Systems</source>
          <volume>36</volume>
          (
          <year>2021</year>
          )
          <fpage>2443</fpage>
          -
          <lpage>2464</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref13">
        <mixed-citation>
          [13]
          <string-name>
            <given-names>D.</given-names>
            <surname>Połap</surname>
          </string-name>
          , M. Woźniak,
          <article-title>Meta-heuristic as manager in federated learning approaches for image processing purposes</article-title>
          , Applied Soft Computing (
          <year>2021</year>
          )
          <fpage>107872</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref14">
        <mixed-citation>
          [14]
          <string-name>
            <given-names>D.</given-names>
            <surname>Połap</surname>
          </string-name>
          ,
          <article-title>Analysis of skin marks through the use of intelligent things</article-title>
          ,
          <source>IEEE Access 7</source>
          (
          <year>2019</year>
          )
          <fpage>149355</fpage>
          -
          <lpage>149363</lpage>
        </mixed-citation>
      </ref>
      <ref id="ref15">
        <mixed-citation>
          [15]
          <string-name>
            <surname>Caggiano</surname>
            ,
            <given-names>G.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Napoli</surname>
            ,
            <given-names>C.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Coretti</surname>
            ,
            <given-names>C.</given-names>
          </string-name>
          et al.,
          <article-title>Mold contamination in a controlled hospital environment: a 3-year surveillance in southern Italy</article-title>
          .
          <source>BMC Infect Dis</source>
          <volume>14</volume>
          ,
          <issue>595</issue>
          (
          <year>2014</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref16">
        <mixed-citation>
          [16]
          <string-name>
            <surname>Acciarito</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Cristini</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Di</surname>
            <given-names>Nunzio</given-names>
          </string-name>
          ,
          <string-name>
            <given-names>L.</given-names>
            ,
            <surname>Khanal</surname>
          </string-name>
          ,
          <string-name>
            <given-names>G.M.</given-names>
            ,
            <surname>Susi</surname>
          </string-name>
          ,
          <string-name>
            <surname>G.</surname>
          </string-name>
          <article-title>An a VLSI driving circuit for memristor-based STDP (</article-title>
          <year>2016</year>
          )
          <year>2016</year>
          <source>12th Conference on Ph.D. Research in Microelectronics and Electronics</source>
          ,
          <string-name>
            <surname>PRIME</surname>
          </string-name>
          <year>2016</year>
          ,
          <article-title>art</article-title>
          . no.
          <issue>7519503</issue>
          , .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>