Introduction

Suitability of water for each of its various uses depends on the type and concentration of the dissolved minerals. In general, standards of water quality have been established for almost every water use. Several criteria in water quality requirements were developed throughout the years, which serve as the guidelines in determining suitability of water for various uses. Issues addressed by the guidelines are bacterial content, physical characteristics including: color, taste, odor, turbidity, temperature, and the chemical constituents.

Researchers at the United States Salinity Laboratory (USSL) (1954) and Wilcox (1955) established the standards for irrigation water. Also in 1962, the U.S. Public Health Service (1962) established standards for the drinking water. Water quality classification methods evaluate water’s applicability to its various uses. The water quality could be classified after hydro-chemical analysis of the water samples, determining the amount of ionic compounds, and computing the required parameters. Presentation of chemical analysis in a graphical form makes evaluation of water quality simpler and quicker. Each of these diagrams is used to determine applicability of the water for a certain purpose. For example, the Schoeller diagram (Schoeller 1962) has been used to evaluate drinking water and the Stiff diagram (Stiff 1951) to determine water hardness. Water quality diagrams are comprised of quality classes defined by crisp sets, and as a consequence the boundaries between classes have an inherent imprecision (Silvert 2000). For this reason, water quality evaluation based only on diagrammatic classification may lead to imprecise and indefinite results; as in the proposed approach, equal importance is given to regions near and far from the boundaries in evaluation of a concentration parameter (Icaga 2007).

When a water sample qualifies near a class border, uncertainties in water sampling and experimental errors may lead to incorrect water quality evaluation. In order to overcome these limitations and rate various water quality samples as compared to other samples, adaptive network-based fuzzy inference system (ANFIS) can be used. It provides a mathematical framework that can convert a complicated set of variables into an automatic evaluation strategy (Mazloumzadeh et al. 2008, 2009).

ANFIS is a fuzzy based system that uses artificial neural networks (ANNs) theory in order to determine the properties (fuzzy membership functions and fuzzy rules) of data samples. ANFIS combines fuzzy logic and ANNs, by utilizing the mathematical properties of ANNs in tuning rule-based fuzzy inference systems (FIS) that approximates the way man processes information. ANFIS which is a specific approach in neuro-fuzzy developments has shown significant promise in modeling nonlinear functions. It learns features of the data set and adjusts the system characteristics according to a given error criterion (Jang 1993). Fuzzy set theory has been applied to a wide range of problems in control, image processing, filter design, data clustering, pattern recognition, and event classification.

In recent years, many researchers have reported using fuzzy logic in the field of water quality evaluation. Ocampo-Duque et al. (2006) used FIS to evaluate water quality of rivers and developed a water quality index. Jacquin and Shamseldin (2006) developed rainfall–runoff models using Takagi–Sugeno fuzzy inference systems to describe the nonlinear relationship between rainfall as input and runoff as output of the real system. Muhammetoglu and Yardimci (2006) developed a fuzzy logic approach to assess the groundwater pollution levels below agricultural fields for Kumluca Plain in Turkey. Water pollution index (WPI) values were calculated using fuzzy logic. Nasiri et al. (2007) proposed a fuzzy multiple-attribute decision support expert system to compute water quality index and to provide a prioritization outline of alternative plans based on the amount of improvements in WPI. Mirabbasi et al. (2008) used Mamdani fuzzy inference system (MFIS) as a decision support system to classify irrigation water quality.

In the previous studies which have used fuzzy logic for evaluation and classification of different water samples, optimal membership functions are selected by trial and error based on expert’s knowledge. Furthermore, the rule base and the main structure of the model are predetermined by the expert. In practice, these models may not perform satisfactorily due to limited knowledge of the experts. Among these methods, ANFIS has its own properties which make it as a unique tool for modeling. The modeling of the USSL-diagram has not performed yet by the ANFIS, which is the novelty of the current paper.

The main objective of present study is to develop a new method based on fuzzy logic instead of the conventional crisp classification method (USSL-diagram) in order to remove the ambiguities in irrigation water quality evaluation. Advantages of ANFIS over traditional methodology are discussed herein.

Materials and methods

USSL-diagram for irrigation water quality evaluation

USSL-diagram (Fig. 1) is one well-known diagram to classify irrigation waters. This diagram is used in interpreting the hydro-chemical analysis of irrigation water. It uses sodium adsorption ratio (SAR) on the vertical axis and electrical conductivity (EC) on the horizontal axis. The EC is plotted by default in a logarithm scale. Based on the EC, irrigation water can be classified into four categories as:

Fig. 1
figure 1

USSL-diagram for classification of irrigation waters (After United States Salinity Laboratory Staff, 1954)

  • C1: Low-salinity water (EC < 250 micromho/cm), it can be used for each type soil and plant.

  • C2: Medium-salinity water (250 < EC < 750 micromho/cm), it can be used for all plants if a moderate amount of leaching occurs.

  • C3: High-salinity water (750 < EC < 2250 micromho/cm), it cannot be used on soils with restricted drainage, some plants tolerate.

  • C4: Very high salinity water (EC > 2250 micromho/cm), soil must be permeable and drainage must be adequate. In addition to this, plants tolerating salinity should be chosen.

The USSL-diagram based on SAR can be divided into four categories as:

  • S1: Low sodium content water. It can be used in each type soil.

  • S2, S3: Medium and high sodium content water, respectively. It may produce harmful levels of exchangeable sodium in most soils and will require special soil management such as adding gypsum and organic matters to soil.

  • S4: Very high sodium content water. It is generally unsuitable for irrigation.

The classification of irrigation waters with respect to SAR is based primarily on the effect of exchangeable sodium on the physical condition of the soil.

In this research, the concentration values of EC and SAR in the USSL-diagram combined together by an ANFIS model to develop a new method in irrigation water quality evaluation.

Fuzzy inference system (FIS)

Fuzzy logic provides a methodology to model uncertainty, the human way of thinking, reasoning, and the perception process (Abraham 2005). Fuzzy set was first introduced by Zadeh (1965), establishes a soft boundary between different levels of subjects where membership is defined by degree. In Boolean logic, we have only two concepts of “True” and “False”, which is represented by 1 and 0, respectively. In the fuzzy approach, the classical theory of binary membership in a set is extended to incorporate the memberships between “0” and “1”. This means each proposition can be true by a degree and false by a degree, simultaneously.

The fuzzy systems are means of capturing humans’ expert knowledge about the process, in terms of fuzzy (IF–THEN) rules (Eqs. 1, 2). Basically, A FIS is composed by a Knowledge-Base, that includes the information given by the expert in the form of linguistic fuzzy rules, a fuzzifier, which transforms the crisp inputs into degree of match with linguistic values, an inference system (Engine), that uses them together with the Knowledge-Base to make inference by means of a reasoning method, and a Defuzzifier, which transforms the fuzzy results of the inference into a crisp output using a defuzzification method (Herrera and Lozano 2003).

The Knowledge-Base is composed of two components: a Data-Base, which defines the membership functions of the fuzzy sets used in the fuzzy rules. A Rule-Base, comprised of a collection of linguistic rules that are joined by a specific operator. The generic structure of a FIS is shown in Fig. 2.

Fig. 2
figure 2

Block diagram of fuzzy inference system (FIS)

There are two most common types of FIS, which vary due to difference between the specifications of the consequent part. The first fuzzy system employs the inference method proposed by Mamdani, in which the rule consequence is defined by fuzzy sets and has the following structure (Mamdani and Assilian 1975).

$$ {\text{IF}}\,x\,{\text{is}}\,A\,{\text{and}}\,y\,{\text{is}}\,B\;{\text{THEN}}\;f\,{\text{is}}\,C $$
(1)

The second fuzzy system proposed by Takagi, Sugeno and Kang (TSK) contains an inference engine in which the conclusion of a fuzzy rule is constituted by a weighted linear combination of the crisp inputs rather than a fuzzy set and has the following structure (Takagi and Sugeno 1985):

$$ {\text{IF}}\,x\,{\text{is}}\,A\,{\text{and}}\,y\,{\text{is}}\,B\;{\text{THEN}}\;f = px + qy + r $$
(2)

where p, q, and r are constant parameter. TSK models are suitable for approximation of a large class of nonlinear systems. In this paper, we use TSK fuzzy inference model based on neural network to model nonlinearity along with the evaluation of irrigation water quality.

FIS can be constructed based on knowledge of expert. For this, the expert selects the membership functions and rules. In other words, the Knowledge-Base containing Data-Base and Rule-Base is made by expert. In this way, fuzzy models can help in extracting expert knowledge on an appropriate level.

Fuzzy systems can also be constructed from data, which alleviates the knowledge acquisition problem. Various techniques have been used to fit the data with the best possible accuracy. There are two common approaches for constructing an FIS based on available data. In the first way, often the rules of the fuzzy system are designated a priori and the parameters of the membership functions are adapted in the learning process from input–output data sets using an evolutionary algorithm such as genetic algorithm. In the second approach, fuzzy system can be generated from data by hybrid neural nets. The neural net defines the shape of the membership functions of the premises. This architecture and learning procedure is called adaptive network-based fuzzy inference system (Jang 1993). It is noted that ANFIS uses the TSK model and the constant parameter of the consequence part are tuned by least mean square (LMS) approach.

Adaptive network-based fuzzy inference system (ANFIS)

ANFIS is an adaptive network-based fuzzy inference system. ANFIS is used for developing TSK type of FIS. It can be trained by a back-propagation (BP) algorithm to model some collection of input/output data for the prediction of output according to the input. Functionally, it is equivalent to the combination of neural network and FIS.

ANFIS was first introduced by Jang (1993) which is suitable for TSK type of FIS proposed by Takagi and Sugeno (1985) and Sugeno and Kang (1988). In this paper, to state the general framework of ANFIS a system containing two inputs x and y and one output f are considered.

As mentioned above, for better explaining of the model we suppose there are two input variables x and y. We assume that each input has two membership functions A 1 and A 2 and B 1 and B 2, respectively. Then, a first-order TSK type of fuzzy if–then rule could be set up as:

$$ {\text{Rule}}\,{\text{i}}:\;{\text{IF}}\,x\,{\text{is}}\,A_{i}\; {\text{and}}\;y\,{\text{is}}\,B_{i} \;{\text{THEN}}\;f_{i} = p_{i} x + q_{i} y + r_{i} \quad {\text{i}} = 1,2, \ldots, n $$
(3)

where f i are the outputs within the fuzzy region specified by the fuzzy rule, n is the number of rules and p i , q i and r i are the design parameters that are determined during the training process. The architecture of the ANFIS is shown in Fig. 3. The ANFIS consists of five layers including, the fuzzy layer, product layer, normalized layer, de-fuzzy layer, and total output layer.

Fig. 3
figure 3

ANFIS architecture

In the first layer (fuzzy layer), x and y are the inputs of adaptive nodes A i and B i , respectively. A i andB i are the linguistic labels used in the fuzzy theory for describing the membership functions. The outputs of layer 1 are the fuzzy membership degree of the inputs which can be expressed as below

$$ O_{i}^{1} = \mu_{{A_{i} }} (x),\quad i = 1,2, \ldots ,n $$
(4)
$$ O_{i}^{1} = \mu_{{B_{i} }} (y),\quad i = 1,2, \ldots ,n $$
(5)

where \( \mu_{{A_{i} }} (x) \) and \( \mu_{{B_{i} }} (y) \) denote the membership functions degree.

Second layer is the product layer that consists of two fixed nodes labeled with Π. The output w 1 and w 2 are the weight functions of the next layer. The outputs of this layer can be represented as

$$ O_{i}^{2} = w_{i} = \mu_{{A_{i} }} (x)\mu_{{B_{i} }} (y),\quad i = 1,2, \ldots ,n $$
(6)

where O 2 i is the output of layer 2.

The third layer is the normalized layer, whose nodes are also fixed and labeled with N. The outputs of this layer can be represented as

$$ O_{i}^{3} = \bar{w}_{i} = {{w_{i} } \mathord{\left/ {\vphantom {{w_{i} } {\sum\limits_{i = 1}^{n} {w_{i} } }}} \right. \kern-\nulldelimiterspace} {\sum\limits_{i = 1}^{n} {w_{i} } }},\quad i = 1,2, \ldots ,n $$
(7)

where O 3 i is the output of layer 3.

The fourth layer is the defuzzification layer. In this layer, the nodes are adaptive nodes. The relationship between the inputs and output of this layer can be expressed as below

$$ O_{i}^{4} = \bar{w}_{i} \left( {p_{i} x + q_{i} y + r_{i} } \right)\quad i = 1,2, \ldots ,n $$
(8)

where O 4 i is the output of layer 4 and p i , q i , and r i are the constant parameters of the node.

The fifth layer is the output layer, whose node is labeled with S. This node performs the summation of all incoming signals, which represents the results of cleaning rates. The overall output of the model is given by

$$ O_{i}^{5} = \sum\limits_{i = 1}^{n} {\bar{w}_{i} f_{i} } \quad i = 1,2, \ldots ,n $$
(9)

where O 5 i is the output of layer 5 and the output of the system.

Development of a fuzzy system for evaluation of irrigation water quality

In this study, we have two sets of input data: SAR and EC, and each data set divided into four segments; hence, we have 16 classes. To determine the ANFIS input/output data, approximately 250 points were selected from each USSL-diagram class in order to cover the entire area of that class. A five terms rating system of Very good, Good, Medium, Bad, and Very bad was established and applied to all 16 classes (Table 1). For example, in Fig. 1, C1S1 is a class with very good value; therefore, all 250 selected points of the class have very good value. A numerical value was then assigned to each of the above mentioned terms: i.e., Very good = 1, Good = 2, Medium = 3, bad = 4 and Very bad = 5. Moreover, four soft classes with numerical values of 1.5, 2.5, 3.5, and 4.5 were also assigned for 500 boundaries points and boundaries stick points in order to cover the entire of the boundaries. For instance, the value of 1.5 is considered for points situated close to the boundary between classes of Very good (1) and Good (2). All together, 4,500 points were incorporated from the USSL-diagram.

Table 1 Five terms for 16 classes of the USSL-diagram

The set of terms using expert knowledge for 16 classes of USSL-diagram are given in Table 1. For example:

  • IF SAR is “Low” and EC is “Medium”

  • THEN quality of irrigation water is “Good”

  • Also

  • IF SAR is “High” and EC is “Low”

  • THEN quality of irrigation water is “Medium”

The ANFIS model was implemented in Matlab software system. Matlab supports first-order ANFIS that has a single output and unitary weights for each rule (MathWorks 2004).

In the ANFIS procedure, utilizing USSL-diagram a score between 1 and 5 to each water sample was assigned. The data set was divided into two smaller sets namely: the training data set (3600 samples) and the testing data set (900 samples). Purpose of the training process is to minimize the error between actual target and ANFIS output through training. This allows ANFIS to learn features from the training data that it observes, and implement them in the system rules. In the performance phase, a new data set (test data) that is not present in the training set is introduced to the learned system for evaluation. If the test error is adequately small, it indicates that the system has a good generalized capability.

The training data set was used to train the ANFIS, while the testing data set was used to verify the accuracy and the effectiveness of the trained ANFIS model for the computation of the water quality evaluation.

Fuzzy system is implemented using the FIS properties provided in Table 2.

Table 2 Specifications of the fuzzy inference system

The main structure of the proposed method is given by Fig. 4. Here, we use SAR and EC as the inputs (correspond to x and y in the above section) and the output is considered to be the quality of irrigation water (correspond to f).

Fig. 4
figure 4

The fuzzy rule architecture of the ANFIS using Gaussian membership function, 2 inputs, 1 output and 43 rules

The FIS parameters with minimum validation set error are selected as optimal. Using the training data set, Matlab simulator found the best performance by ANFIS in modeling the problem at hand with 43 fuzzy rules and 43 Gaussian membership functions for each input. Figure 4 also shows the fuzzy rule architecture of the ANFIS model using Gaussian shaped membership functions.

Results and discussion

In this study, the concentration values of EC and SAR in USSL-diagram are combined together by an ANFIS model to generate a new evaluation system that can be applied instead of the USSL-diagram to evaluate irrigation water quality. We use the proposed method to learn the input–output relation according to training data set. In the learning phase, the ANFIS first makes the suitable membership functions for each input. In the sequel, the membership functions are tuned according to error correction training method by using BP algorithm. Also, the constant parameter of the linear output functions is adapted during the learning phase based on LMS algorithm. ANFIS model utilizes 3600 training data over the 170 training periods. At the end of training phase, the network error convergence curve (mean square error) of ANFIS was derived as shown in Fig. 5.

Fig. 5
figure 5

The curve of network error convergence of ANFIS

ANFIS test results (predicted data) are compared with results obtained from USSL-diagram (measured data) in Fig. 6. Horizontal access shows 900 testing data (20% of 4500 data) and vertical access shows water quality classes from Very good to Very bad. From this figure, one can see that the results obtained by ANFIS are in good agreement (96%) with the results of the USSL-diagram.

Fig. 6
figure 6

Comparison of measured and predicted data for irrigation water quality evaluation

The relationship between input variables and their contribution to the output variable can be visualized with fuzzy surface (Fig. 7). It is a graphical user interface (GUI) tool that lets us examining the output surface of a FIS model. It provides a visual impression of the possible combinations of the two input variables and the output in a three-dimensional view. If for example, for EC = 200 and SAR = 5 the water quality index is 1 on the scale of 1–5 (“very good” to “very bad”). It is a fast and visual method of showing the irrigation water quality classes to the researcher. In the other words, total knowledge extracted by fuzzy inference system (the input–output mapping) is presented in this figure. The FIS uses a mathematical solution that can be used to classify the water samples based on inputs such as EC and SAR in the absence of the USSL-diagram for decisions.

Fig. 7
figure 7

Fuzzy surface: SAR and EC versus irrigation water quality evaluation

In a previous study (Mirabbasi et al. 2008), MFIS was used to evaluate ground water quality of Sirjan plain aquifer with an 84% accuracy. However, the ANFIS classifier presented in this study was found to be of higher accuracy than the MFIS model. In that system, in order to achieve the best results, optimal membership functions were selected through trial and error for that specific area; which was the main deficiency of that system. However, the proposed approach can be used in a general way for every data set. It is denoted that in the previous study (Mirabbasi et al. 2008), the boundary values were not used to evaluate results, hence total accuracy of the system decreased when border values were considered.

In commonly used fuzzy inference systems in water quality evaluation, optimal membership functions are selected by trial and error. Furthermore, the rule structure is predetermined by an expert person for the model. In practice, these models may not perform satisfactorily due to limited knowledge of the experts, and improper selection of membership parameters (Jang et al. 1997). In the proposed ANFIS-based methodology, the parameters are tuned automatically during the learning stage; hence the membership functions can properly represent the nonlinear behavior of the system being studied with optimal performance.

In contrast with application of diagrams under the same conditions, the proposed methodology significantly decreases calculation time. For example, to evaluate 1,000 data points using USSL-diagram an expert with measurement tools spent up to 3 h on this graph, whereas, the proposed system decreased this evaluation time to only 2 min.

ANFIS method improves greatly on the effects of inherent imprecision due to crisp separation of classes in USSL-diagram. Also this method could modify the effect of hydro-chemical analysis errors, especially when water quality samples lie near the boundaries.

Fuzzy logic based systems are able to handle numerous evaluation classes for USSL-diagram, but increasing of classes may lead to difficulties for readers and researchers, therefore in this study we limited many classes into only nine evaluation classes and it is most important limitation of the preset study.

Conclusions

A new application of ANFIS to evaluate and classify water quality for irrigation uses was presented. In this study, the concentration values of EC and SAR in USSL-diagram are combined together through an ANFIS model to generate a new method that can be used instead of the USSL-diagram. ANFIS models are powerful tools for building complex nonlinear relationships between inputs and outputs by learning from a data set.

The comparison between results of ANFIS and USSL-diagram shows that the overall classification accuracy of the ANFIS model was 96%. It shows that the ANFIS model has much better predicting capability than the MFIS of 84% accuracy that was created by an expert. ANFIS model demonstrated that water quality evaluation based on this method is more exact than USSL-diagram classification approach, and provides a better representation of water quality condition. Results indicate that ANFIS modeling is a promising alternative to the traditional approach and it significantly decreases calculation time in determining irrigation water quality. The proposed methodology can also be used to reduce the effects of probable errors and uncertainties in field data and hydro-chemical analyses.