Water cut/salt content forecasting in oil wells using a novel data-driven approach

Water cut is an important parameter in reservoir management and surveillance. Unlike traditional approaches, including numerical simulation and analytical techniques, which were developed for predicting water production in oil wells based on some assumptions and limitations, a new data-driven approach is proposed for forecasting water cut in two different types of oil wells in this article. First, a classification approach is presented for water cut prediction in sweet oil wells with discontinuous salt production patterns. Different classification algorithms including Support Vector Machine (SVM), Classification Tree (CT), Random Forest (RF), Multi-Layer Perceptron (MLP), Linear Discriminant Analysis (LDA) and Naïve Bayes (NB) are investigated in this regard. According to the results of a case study on a real Iranian sweet oil well, RF, CT, MLP and SVM can provide the best performance measures, respectively. Next, a Vector Autoregressive (VAR) model is proposed for forecasting water cut in salty oil wells with continuous water production during the life of the well. The proposed VAR model is verified using data of two real salty oil wells. The results confirm that the well-tuned proposed VAR model could provide reliable and acceptable results with very good accuracy in forecasting water production for the near future days.


Introduction
The extraction of oil and gas from underground reservoirs is often accompanied by water or brine, which is referred to as produced water. As the reservoirs mature, especially if secondary or tertiary recovery methods are used, the quantity of produced water climbs and often exceeds the volume of the hydrocarbons before the reservoir is depleted. Produced water is by far the largest volume byproduct stream of oil and gas exploration and production. The cost of producing, handling, and disposal of the produced water often defines the economic lifetime of a field and the actual hydrocarbon reserves; therefore, understanding and predicting the aspects, behavior, and problems induced by the producedwater flow is important (Petrowiki, 2018).
The major constituents of concern in produced water are Salt Content (SCT), oil and grease, inorganic and organic compounds, and naturally occurring radioactive material (Clark and Veil, 2009). Due to the increasing volume of waste all over the world in the current decade, the outcome and effect of discharging produced water on the environment has lately become a significant issue of environmental concern (Nasiri et al., 2017).
The cost of managing produced water is a significant factor in the profitability of oil and gas production. In addition, the cost-effective techniques for managing oilfield water require a comprehensive understanding of reservoir characteristics, production volumes, hydrogeology, engineering design, and environmental considerations (SLB, 2018). Therefore evaluating and predicting the volume of produced water in oil/ gas production wells could be considered as a major first step in planning for the future requirements of salty oil treatment in desalting facilities and the management of underground water resources as well.
Generally, the oil producing wells could be categorized into two different groups based on the entrained volume and patterns of producing water along with the oil, as listed in the following statements: 1. Sweet Oil Well (SWOW): This type of well produces (sweet) oil with no excess salt or basic sedimentary; so the well flows to a production unit without needing any desalting processes. Some SWOWs are however encountered irregularly by sudden increases in salt production during their production life due to water coning phenomenon. To remediate this situation, the well may be shut-in or its production rate may be decreased for some days so that the cone of water rose in the formation around the wellbore recedes back to its original level in the aquifer. Figure 1 represents the abnormal behavior of salt production with rare and sudden peaks (defined as anomalies) over time in a daily scale for a real SWOW in Southwest Iran.

Salty Oil Well (SAOW):
This kind of well produces brine continuously with different volumes along with the oil. Therefore, the produced oil should always be treated in desalting facilities after processing in the production unit. Figure 2 illustrates the daily BSW production trends of two real oil wells, located in Southwest Iran, producing with varying WCs. Regarding the plots, the wells show a continuous production of brine with varying production rates along with the oil. No specific attentions have been made to WC prediction in SWOWs in the literature and no model is developed by other researches for predicting the WC or anomalous conditions in this type of well. This is, however, quite different for SAOWs where there are currently two main approaches for predicting Water Cut (WC) in them. The first is numerical simulation technique and another is analytical or empirical methods (Ershaghi and Omorigie, 1978;Lawal et al., 2007;Li et al., 2011;Liu et al., 2017;Lo et al., 1990;Sitorus et al., 2006). The numerical simulation is time consuming and expensive to reach and requires information that is not readily accessible. Most of the analytical models, however, represent WC as a function of cumulative oil production instead of production times and are based on simplifying assumptions causing unacceptable results in complex reservoirs.
Only monotonic trends of production could be handled effectively by the empirical models as they are based on some predefined equations like exponential functions that are not capable of presenting multiple increasing or decreasing trends. Some wells may encounter cyclic, unstable or changing production patterns over time. These situations could not be captured very well using the traditional models as well. These methods also utilize a fixed set of input variables in their structure and are not flexible in using more or less variables, if needed.
Recent developments in computational intelligence, in the area of machine learning in particular, have greatly expanded the capabilities of empirical modeling in all areas of science and industry. The field which encompasses these new approaches is called Data-Driven Modeling (DDM). DDM is based on analyzing data about a system, in particular finding connections between the system state variables (input, internal and output variables) without explicit knowledge of the physical behavior of the system (Solomatine et al., 2008). Therefore, the models carefully generated by data mining tools reflect the real behavior of the system of study, as they are based on the real performance of the system, no matter how complex it is.
There are many significant research studies and experimental works carried-out using various data mining techniques which prove the importance and need of these technologies for oil field applications and water resource management as well (Ahmadi et al., 2017a, b;Li and Li, 2013;Mohan and Ramsundram, 2016;Nourani et al., 2017;Wachowicz, 2002).
A new methodology based on data mining techniques is thus proposed in this research for prediction of WC/SCT in two different types of oil wells discussed previously. The main objective is to provide DDMs for prediction and forecasting of WC/SCT to deal with different water production patterns in oil wells. Therefore no assumptions about the conditions of salt production of the investigated wells need to be made by the proposed DDM approach. This research does not consider a modification and/or improvement to the existing methods; rather, it attempts to propose a novel and different approach using the datadriven algorithms for predicting SCT or WC in different conditions of water productions in oil wells.
In the following sections, some required theoretical backgrounds are primarily introduced in Section 2 before proceeding to the proposed approach. After that, Section 3 introduces the proposed data-driven methodologies for predicting and forecasting SCT/WC values in different types of oil wells including SWOWs and SAOWs. The proposed approach will be verified and discussed in Section 4 using data of three real case studies of Iranian oil wells, including one SWOW and two SAOWs. Finally, the significant findings and important remarks that are inferred from this research are listed in Section 5.

Theoretical background
Since part of the methodology proposed in this article utilizes special time series data mining techniques including vectorized AR model to forecast the amount of SCT in some kinds of oil wells, the relevant aspects of AR modeling and a brief description of the mentioned algorithm is introduced in the following subsections, before the main body of the proposed approach is introduced.

Autocorrelation and partial autocorrelation
Autocorrelation and Partial Autocorrelation Functions (ACF and PACF) are the two well-known identification methods of AR models (McLeod and Li, 1983). ACF is defined as the coefficient of correlation between two values in a time series. Sometimes we may wish to only measure the association between the current value of a time series, y t and a previous value located at a lag k, y tÀk , and filter out the linear influence of the random variables that lie in between (i.e., y tÀ1 ,y tÀ2 ,. . ., y tÀ(kÀ1) ), which requires a transformation on the time series. Then PACF is obtained by calculating the correlation of the transformed time series.
The PACF is most useful for identifying the order of an AR model (Hamilton and Watts, 1978). Specifically, sample partial autocorrelations that are significantly different from 0 indicate lagged terms of y that are useful predictors of y t . Graphical approaches to assessing the lag of an AR model include looking at the ACF and PACF values versus the lag. In a plot of ACF versus the lag, if we see large ACF values and a non-random pattern, then likely the values are serially correlated. In a plot of PACF versus the lag, the pattern will usually appear random, but large PACF values at a given lag indicate this value as a possible choice for the order of an AR model.

Vector AR model
The Vector AR (VAR) model is one of the most successful, flexible, and easy to use models for the analysis of multivariate time series. It is a natural extension of the univariate AR model to dynamic multivariate time series (Lütkepohl, 2006).
A VAR model applies when each variable in the system does not only depend on its own lags, but also the lags of other variables. A general VAR(s) process with white noise can be written as equation (1): where the error terms follow a vector white noise, i.e., E( t ) = 0 and y t is a k Â 1 vector of endogeneous variables. Based on the same sample size, the following information criteria and the final prediction error are computed  (Akaike, 1974;Hamilton, 1994;Hannan and Quinn, 1979;Lütkepohl, 2006;Quinn, 1980;Schwarz, 1978): with P $ n ð Þ ¼ T À1 P T t¼1 t 0 t and n* is the total number of parameters in each equation and n assigns the lag order. The lag order minimizing each of the above criteria could be the selected lag size for VAR(p) model. While creating VAR model of the best-determined lag order, it should be noted that not all the coefficients included in the model may have a significant effect on the fitting process. Some of them are negligible and might be removed from the fitted model as they do not provide further improvement in model generation. The t-statistic provides a measure of how extreme a statistical estimate is (Runkel, 2016). The P-value approach involves determining "likely" or "unlikely" by determining the probability of observing a more extreme test statistic in the direction of the alternative hypothesis than the one observed. If the P-value is less than (or equal to) a predefined significance level, a, then the null hypothesis is rejected in favor of the alternative hypothesis, and vice versa. In many applications, a P-value less than a = 0.05 indicates that the corresponding variable should be considered as significant.

Proposed methodology
Two different types of oil wells with variable salt production patterns, including SWOWs and SAOWs, will be studied and modeled in this article, as described in the following statements: (1) SWOW: An innovative methodology for predicting excessive water (salt) production in SWOWs where no specific methods have not been established by other researchers previously is developed in this section. Predicting the amount of water that will be produced aberrantly in substantial volume at future times is considered as the main target for this type of well.
If some thresholds are defined for WC/SCT, the water production data could be easily transformed into some limited number of bins or classes. As negligible water is normally produced during the life of the well, the conditions of increasing water volume (defined as anomalies) could be effectively predicted using a classification method where two or more class labels are assigned to the input data points. In the simplest case a binary classifier would be used to predict the abnormal conditions versus the normal conditions as two different classes. Classification is a method for partitioning data into classes and then attributing data vectors to these classes. The output of a classification model is a class label, rather than a real number like in regression models. Each category of SCT in the classification problem denotes a predefined SCT range or cut-off rather than a single number.
(2) SAOW: The aim is, here, to forecast the continuous amount of WC/SCT of the produced fluid over future times for SAOWs. The continuous production of water (or salt concentration) in different volumes provide a suitable framework for using the time series regression analysis methods in order to forecast the WC/SCT of the produced oil. Autoregressive (ARs) models are one of the most powerful and common methods used for forecasting univariate time series (Pandit and Wu, 1983). They use a limited number of past values of the original time series to forecast the variable of interest in the future. It is, therefore, a suitable technique for forecasting the continuous changes in variables over time as in the present case for SAOWs. Due to multiple time series variables that may be involved in the modeling process, a multivariate modification of the AR models, known as Vector AR, is recommended for this purpose in this research. AR methods could be easily found out in McLeod and Zhang (2006).
The complete flowchart of the proposed data-driven methodology for predicting the WC/SCT values in both situations is illustrated in Figure 3. As it is clear from the flowchart, the proposed methodology consists of different parts and processes for each type of well that should be carefully followed by the user. Each part of the presented flowchart is described briefly in the following sections.

WC/SCT forecasting in SWOWs
In line with the flowchart depicted in Figure 3, the proposed methodology for prediction of SCT/WC in SWOWs using the classification approach is described in the following sections.

Proposed methodology for forecasting WC/SCT in SWOWs: A classification approach
A classification approach is employed to predict the class label of each data point when predicting SCT/WC in SWOWs since they are transformed into several categories or bins prior to creating the model. The required steps proposed to achieve the best classification performance and the most accurate classifier for this purpose are listed below: (a) Constructing initial dataset The SCT/WC is considered as the output time series data for the classification problem, while any other available data recorded over time could be regarded as input data. In a daily time scale, the Oil Production Rate (OPR), Cumulative Oil Production (CUMPROD) between two successive days of shutting in the well due to rises in salt production, and the distance from bottom of production interval of the well to the water-oil-contact (DW) are among the most common variables that are used as input time series data in this article. To be more clarified about the meaning of CUMPROD, the reader should note that this is not the accumulated volume of produced oil from the starting day of production until the end date; however, it is the cumulative oil volume started to measure from the day when the well is put on production until the day when the well is closed due to significant water production. After closing the well, this parameter is immediately set to zero, until the well is again opened to produce after some days of shut-in. In other words, CUMPROD is equal to zero at time periods when the well is shut-in due to excessive water production and significant flowing pressure drop. As the well is started to flow, the CUMPROD begins to build up again.

(b) Data preprocessing
Handling missing data and replacing them with known or regressed values, removing outliers and vague values from the data, converting SCT data to different numbers of bins/classes, and normalization of individual time series data are among the most important preprocessing techniques in this regard.

(c) Changing data representation
The time series datasets are converted to the conventional non-temporal datasets using the sliding window approach. By this technique, k numbers of successive data points are extracted from each time series using the sliding windows of size k, and then the extracted data points from different time series are arranged in different columns. The m time series of order n will be transformed to a dataset of nÀk rows and m*(k + 1) columns using the sliding windows of length k. The columns in the new feature space correspond to the lagged variables in the original space.
A grid search approach using repeated Cross Validation (CV) technique is recommended to select the best window size for this purpose. Modeling is performed using different training datasets generated by multiple window sizes and the window length that causes the best classification performance is finally selected as the best window size. CV is employed to avoid over-fitting and also ensure that every example from the original dataset has the same chance of appearing in the training and testing dataset (Kohavi, 1995). The basic form of CV known as k-fold CV will be employed in the present application.

(d) Optimizing classifiers
Different classification algorithms are considered for prediction problem in SWOWs. Each classifier has its own tuning parameters that needs to be optimized. Finding out the best set of tuning parameters for each classifier is reached throughout the grid search technique and repeated CV for resampling training data.

(d1) Partitioning dataset
Prior to modeling, the initial dataset should be partitioned into training and test set to evaluate the model performance by making predictions against the test set.

(d2) Balancing dataset
The training dataset is highly imbalanced because of large differences between the class frequencies. The majority class in the present application belongs to the conditions where nil amounts of salt is produced along with oil in SWOWs. The production of higher amounts of salt occurs very rarely during the production period of the well that will constitute the minority classes. A dataset is said to be imbalanced when the class of interest (minority class) is much fewer than the normal behavior (majority class). The cost of missing a minority class is typically much higher than missing a majority class. Most learning systems are not prepared to cope with imbalanced data and several techniques have been proposed by different authors.
The main objective of balancing classes is to either increasing the frequency of the minority class or decreasing the frequency of the majority class. There are a few resampling techniques for this purpose including random undersampling, oversampling and Synthetic Minority Oversampling Technique (SMOTE) (Mostafizur and Davis, 2013). SMOTE has the merit of avoiding overfitting which occurs when exact replicas of minority instances are added to the main dataset as in the case of oversampling. In addition, loss of useful information which is a disadvantage of random undersampling techniques does not occur with SMOTE. The SMOTE algorithm is therefore recommended as a proper technique for balancing data in this article. The reader is referred to Chawla et al. (2002) for studying the procedure of SMOTE algorithm.

(d3) Averaging classification performance
For each grid point on the dimensional grid search space, estimate the mean performance criterion of the classifier by averaging over all repetitions.

(d4) Finding out best set of tuning parameters
Iterating on all grid points on the search space and evaluating the mean performance measure for each possible hyperparameter, the best set of tuning parameters corresponding to the best performance measure is determined (Ben-Hur and Weston, 2010).

(e) Predicting with test data
Use the well-tuned classifier to predict SCT/WC using the test data and estimate the prediction accuracy of the classifier based on the specific metrics. This is the best classification performance obtained for the given size of sliding window discussed in step c.

(f) Selecting best window size
Iterate on all window sizes so that the most accurate classifier with the best performance criterion is selected at each window size. The optimal window length is estimated by finding out the best classification performance over the window size search grid.

Classification algorithms for prediction of SCT/WC in SWOWs
There are a variety of well-developed algorithms that could be employed for classification problems. Artificial neural networks and Multi-Layer Perceptron, MLP (Rosenblatt, 1961), Linear Discriminant Analysis, LDA (Raschka, 2014), Classification Tree, CT (Breiman et al., 1984), Random Forest, RF (Breiman, 2001), Support Vector Machine, SVM (Vapnik, 1995) and Naïve Bayes, NB (McCallum and Nigam, 1998) are the common classifiers in this regard. These classification methods that are among the most influential data mining algorithms in the research community (Wu et al., 2008) are to be investigated for predicting WC/SCT of SWOWs using the proposed methodology in this article. The list of tuning parameters of these classifiers are tabulated in Table 1.

Performance measures of classification
The correctness of a classification can be evaluated by computing the number of correctly recognized class examples (true positives), the number of correctly recognized examples that do not belong to the class (true negatives), and examples that either were incorrectly assigned to the class (false positives) or that were not recognized as class examples (false negatives). These four counts constitute a table known as confusion matrix that is often used to describe the performance of a classification model (Sokolova and Lapalme, 2009). In addition, Cohen's Kappa statistic is a very good measure that can handle very well both multiclass and imbalanced class problems (Cohen, 1960). Cohen's Kappa is always less than or equal to 1. Values of 1 indicate perfect agreement, while a value of zero would indicate a lack of agreement (Landis and Koch, 1977).

WC/SCT forecasting in SAOWs
According to the flowchart illustrated in Figure 3, the proposed methodology for forecasting SCT/WC in SAOWs using the regression approach is designated in the subsequent sections. The proposed approach uses a vectorized AR model to conduct the forecasting process for the current problem. The related aspects of AR modeling and a brief description of the above-mentioned algorithm was described previously in Section 2.

Proposed methodology for forecasting WC/SCT in SAOWs: a regression approach
The steps that are recommended in this article for forecasting SCT/WC values over time in SAOWs using VAR modeling is as follows:

a) Dataset preparation
The whole dataset including different time series variables related to SCT/WC production in oil wells is constructed.

b) Data preprocessing
Handling missing data and replacing them with known or regressed values, and data normalization are the most required preprocessing techniques for this purpose.

c) Data partitioning
Split the dataset into training and testing datasets initially.

d) VAR selection
Select the best lag size, p, based on the highest values of SC or AIC measures, preferably. The best lag order may be also found using a grid search approach by running VAR models of different lag orders from 1 to the maximum value determined by different VAR selection criteria. The lag order that yields the lowest forecasting error for the test data will be used as the best lag size in creating the VAR model. The Mean Absolute Error (MAE), defined as the mean of the absolute values of the individual prediction errors over all instances in the test set, can be used as the forecasting performance criterion in this regard.

e) Evaluating VAR model against test data
Forecast the SCT/WC for some future days using the best VAR model. Compare the forecasted values with the target data and estimate the forecasting performance (MAE, RMSE, etc.) as the final measure of regression accuracy.

Results and discussion
To validate the approaches proposed in this research for predicting the amount of SCT in different kinds of oil wells, three real case studies including one SWOW (Well A) and two SAOWs (Wells B and C) from two different oil reservoirs both located in Southwest Iran are implemented in the following sections using the methodologies proposed in Section 3. The modeling procedures are performed using MATLAB and R statistical languages in this article.
The study variables used in this article include WC/ SCT as the target data and some other related parameters

Number of predictors (m try ), number of tress (n tree )
-Hidden layer size -like OPR, CUMPROD and DW (if available) as the input data for several consecutive days of production. Some entries in the gathered BSW tables are missing for either the amount of SCT or WC percentage. A suitable preprocessing technique is therefore needed to handle the missing data values prior to modeling. One of the common methodologies used for this purpose is the replacement of missing data with some interpolated values. A simple mathematical correlation, if accessible, could be found to relate the fraction of water produced along with the oil (i.e. surface WC) to the amount of salt concentration in the produced fluid (i.e. the SCT). It's possible to use such a fitted correlation to convert the SCT and WC values to each other. Therefore a scatter plot of WC percentage versus SCT values is generated for the rows with complete WC and SCT entries to extract the correlation between them, as illustrated in Figure 4a. This figure also displays the best fitted line passing through the data points. The calculated residuals between the actual and predicted WC values while considering the whole dataset in the fitting process are plotted in Figure 4b as well. Some points shown in small red crosses on the plots seem to be outliers, as they locate relatively far distances from the mean of data. One of the most common ways of visually identifying outliers is the box-plot tool (Seo, 2006) that is used in this article. To improve performance of the fitting process, the outliers have to be excluded from the training dataset prior to regression. The plots of fitting WC versus SCT values and their corresponding residuals while disregarding the outliers from data are displayed in Figures 5a and 5b, respectively. The equation of the best-fitted line and its corresponding regression measures are provided in Table 2. Using this equation, one can handle missing values of SCT or WC data in the data set. The linear equation fitted in this article is based on the data gathered from a number of oil fields, with near equal total formation water salinity, including the two reservoirs where the three real case studies Wells A, B and C are located in.

Forecasting SCT in SWOW using different classifiers
The methodology proposed in Section 3.1.1 is verified using the real data of a SWOW (labeled as Well A) produced from an oil reservoir connected to a weak aquifer in Southwest Iran. The endogenous variables for this well include WC/SCT as the input data and OPR, CUMPROD and DW as the output data for 3349 successive days. The plots of study variables including SCT (in mg/L), DW (in m), OPR (in STB/day) and CUMPROD (in STB) for Well A are shown in Figures 6a through 6d, respectively. As shown in Figure 6a, the SCT values are below the permissible threshold for very large portions of the data; it rises above the threshold, however, only for a few days as shown by limited peaks on the graph. The methodology presented in Section 3.1.1 for prediction of SCT/WC in SWOWs is thoroughly examined for the present case study.
According to the regulatory bases, the cut-offs displayed in Table 3 were chosen for discretization of SCT values in this article.
Next, the class imbalance problem as depicted from the plot of Figure 6a is alleviated using the SMOTE algorithm before proceeding to the modeling phase. The number of instances of different classes both before and after balancing data is shown in Table 4.
Six different classifiers, as discussed in Section 3.1.2, are investigated using the proposed methodology. The validation method and its related parameters used in modeling classifiers are displayed in Table 5.
The results achieved for the present case study including the smallest, the mean and the largest Kappa coefficients as well as the best size of sliding window and the best tuning   Table 6. The plots of Kappa coefficient and classification accuracy versus the size of sliding window is also illustrated in Figures 7a through 7f for RF, CT, MLP, Radial SVM, LDA and NB classifiers, respectively. To make a better comparison between all classifiers, the plots of maximum Kappa coefficients and the best sizes of sliding windows are depicted in Figure 8 for all classification algorithms at the same time. The left vertical axis of the plot shows the best size of sliding window of different classifiers marked by small triangles, while the right axis displays the largest Kappa coefficients marked by circles. According to these plots, the ranking of classifiers in terms of descending Kappa coefficient is as follows: RF, CT, MLP, Radial SVM, NB and LDA. In other words, the largest and the most plausible Kappa coefficients are achieved by RF, CT, MLP and Radial SVM algorithms, respectively. The  Among the best classifiers, the shortest size of sliding window belongs to CT which is equal to 1. This means that CT uses the input variables at the current time step and those recorded at the most recent time step (i.e. 6 input variables totally). In addition, RF uses only seven input variables at best condition for predicting SCT according to the entries of best tuning parameter (m try ) of Table 6, although the best sliding window size for this algorithm is relatively large (k = 12). Based on the smallest Kappa coefficient values provided in Table 6, the RF classifier also achieves a very good performance using the shorter sliding windows. For windows of sizes 0 and 1, for example, the Kappa coefficients of the best model instances of RF classifier are both equal to about 0.996 which is a little bit larger than that of the best model instance of CT (i.e., 0.992). Alternatively, CT and RF have the lowest complexity in terms of the number of input variables compared to MLP and Radial SVM as they utilize more numbers of previous values for providing the best Kappa coefficients. The NB algorithm, however, has the shortest size of sliding window (equal to 0) meaning that it exploits only the input variables at the current time step regardless of the previous time steps. Therefore, NB performance using the window size of 0 is comparatively lower than the best performances provided by the above classifiers and increasing the length of sliding window just degrades the Kappa coefficient of NB. For LDA, we encounter a lazy classifier as it could not predict the classes correctly even with the best window size of 15. Trivially, the prediction performance of LDA is very low using the windows of small sizes.
The confusion matrix plots of the predicted values versus the targets using the best model of each classifier (RF, CT, MLP, SVM, LDA and NB, respectively) are illustrated in Figures 9 and 10 for the whole dataset and the test set respectively. According to Figures 9a through 9d, for the first four classification algorithms, the classes C 2 through C 4 corresponding to the SCT values greater than the maximum allowable content for SWOWs are predicted with 100% accuracy compared to the real targets. If binary classification with two class labels including "underthreshold" and "over-threshold" SCT is expected, then the NB algorithm also provides a perfect performance in predicting the real classes of data points belonging to the over-threshold SCT. Acceptable results are, however, not obtained using the LDA classifier for the training and test datasets for the present case study. Similar conclusions could be inferred from Figures 10a through 10f about the performance of different classifiers when predicting the test dataset only.

Forecasting SCT in SAOWS using VAR models
The methodology proposed in Section 3.2.1 is now verified using the real data of two SAOWs (named as Wells B and C) produced from a water-drive oil reservoir in Southwest Iran. The two wells have nearly the same production conditions and are completed with similar downhole structures in the same formation. The endogenous variables available for the two wells include SCT, OPR and CUMPROD data for 395 successive days while DW data was not available for them.  Figures 11 and 12 illustrate the input and output time series data (each including SCT, OPR and CUMPROD, respectively) plotted in a daily time scale for Wells B and C, individually. Looking at the history plots of SCT in Figures 11a and 12a, the cyclic and periodic patterns with non-monotonic trends are easily observed during the time of study.
Normalization is first applied to the whole dataset so that the values in each time series are transformed between 0 and 1. Prior to forecasting, a limited number of time data points (here the last 30 points) is considered as test data and are excluded from the training phase.
For each well, VAR is conducted on multiple time series based on the proposed methodology to forecast the SCT over future times. This is implemented using the VARS package in the R environment (Pfaff, 2008). The values of different criteria including AIC, HQ, SC and FPE for different lag orders from 1 to 30 are plotted in Figures 13  and 14 for Wells B and C, respectively. The lag orders that minimize each criterion is chosen as the selected lag size for the corresponding criteria as displayed in Table 7 for both Wells B and C. The best lag size is selected using the grid search approach by running a variety of VAR models of different lag orders from 1 to the maximum value selected by the four criteria individually for each well. The plots of MAE measures of test data for a number of VAR models with different lag orders for Wells B and C are illustrated in Figures 15 and 16, respectively. For Well B, the lowest possible MAE measure of 0.062 happens for a lag order of p = 4. Considering Well C, on the other hand, the lowest possible MAE measure of 0.0975 happens for the lag order of p = 1. The final VAR(4) and VAR(1) models are created using the normalized training time series data without any special transformations for Wells B and C, respectively. The corresponding equations of VAR(4) and VAR(1) models are given by equations (6) and (7): where A i , B i and C i are the coefficients for SCT, OPR and CUMPROD variables in the model, respectively. In addition, li indices of each variable indicate the i most previous time steps of the corresponding variable at time tÀi. As discussed in Section 2.2, the importance of coefficients in the created VAR model should be evaluated using the t-statistic and the corresponding P-values. In the present application, a P-value less than a = 0.05 indicates that the corresponding variable should be considered as significant. The coefficient estimates and their standard errors of VAR models along with their corresponding t-statistic and P-values for SCT data are therefore summarized in Tables 8 and 9 for Wells B and C, respectively. The significant variables having a relatively small P-value are indicated by a star sign in the last column of Tables 8 and 9. Other variables not indicated as significant in the Table will not be included in the final model. The residual standard error and coefficient of determination (R-squared) on the whole training data set is also shown in the lowest part of Tables 8 and 9. Diagrams of fit and residuals for SCT data over time for Wells B and C are shown in Figures 17a and 17b and Figures 18a and 18b, respectively. The plots demonstrate very good accuracy in forecasting the SCT data of the training dataset. In addition, the ACF and PACF plots of residuals versus lag orders are displayed in Figures 17c and 17d and Figures 18c and 18d, respectively, for Wells B and C. The autocorrelation plots also verify that the fitting residuals are not correlated in any lag order for both wells.
The forecasted normalized SCT data with 95% confidence intervals for 30 days ahead of the training dataset (i.e. for the test dataset) using the generated VAR models is depicted in Figure 19, for Well B. To make a better comparison, the true and forecasted normalized salt concentration data for Well B are plotted on the same graph as displayed in Figure 20. Figure 20a shows this comparison only for 30 test data points, while the entire dataset comparison is displayed in Figure 20b. For each graph, the relative errors between the target and forecasted data points are also displayed on the corresponding plot. Such graphs, as created for Well B, are illustrated in Figures 21     The asterisk symbol in the last column shows the significance of the corresponding model parameter. The asterisk symbol in the last column shows the significance of the corresponding model parameter.    Investigating through the forecasting performance of VAR model for Well B, a) normalized original and forecasted test data points along with their relative errors plotted on the same graph, b) normalized original and forecasted data points for the entire data set including both training and testing data along with their relative errors plotted on the same graph. On both plots, the vertical and horizontal axes show the normalized SCT data and time order (in days), respectively. The original and forecasted data points are shown by small blue circles and orange triangles, respectively, while the relative errors are depicted by small gray diamonds.  Investigating through the forecasting performance of VAR model for Well C, a) normalized original and forecasted test data points along with their relative errors plotted on the same graph, b) normalized original and forecasted data points for the entire data set including both training and testing data along with their relative errors plotted on the same graph. On both plots, the vertical and horizontal axes show the normalized SCT data and time order (in days), respectively. The original and forecasted data points are shown by small blue circles and orange triangles, respectively, while the relative errors are depicted by small gray diamonds.
Wells B and C, as well. The VAR models are able to forecast the real patterns of salt production for the test data with estimated MAE values equal to 0.062 for Well B and 0.0975 for Well C. These values show quite good accordance between the real and forecasted SCT data for 30 last data points using the well-tuned VAR models.

Conclusion
The main contribution of this article is to propose a novel data-driven approach for forecasting the salt content (or equivalently the water-cut) of producing oil wells at different conditions. These conditions are divided into two different categories including continuous water production (for salty oil wells) and discontinuous water production (for sweet oil wells). The approaches presented in this article for the prediction of SCT/WC in these two conditions are different in methodology and algorithms. A classification approach is proposed for predicting the conditions of excessive salt content production (larger than a pre-specified threshold) for sweet oil wells, while a regression-based methodology is presented for forecasting the amount of SCT over near future times for salty oil wells. The conclusions inferred from the present study are summarized in the following statements.
1. Prediction of irregular and continuous production of SCT/WC over times in SWOWs and SAOWs is investigated using DDM in this article. 2. This article provides a new methodology for forecasting WC/SCT production using multiple variables recorded in time including OPR, CUMPROD and DW. Any other related temporal variables that become available could be easily incorporated into the model just by adding new dimensions to the feature space to improve the model accuracy. 3. A classification approach is proposed in this article for SCT prediction in SWOWs where significant salt production occurs rarely during well production period. 4. Six different classification algorithms including RF, CT, MLP, Radial SVM, NB and LDA are examined using the proposed methodology for SCT production in SWOWs. According to the results of a real case study, the RF, CT, MLP and Radial SVM can provide the best performance measures (the largest Kappa coefficients), respectively. 5. The well-tuned CT and RF classification algorithms created for the present case study utilize relatively lower numbers of input variables compared to MLP and Radial SVM. 6. A VAR model approach is employed in this article to forecast SCT/WC in SAOWs where the well continuously produces brine throughout its production period. The proposed VAR modeling approach is verified using data of two real SAOWs. The wells show cyclic and periodic patterns of varying trends for water production. A VAR(4) and a VAR(1) model are created for the two case studies based on the lowest values of MAE measures achieved for forecasting SCT data for 30 days ahead of the training data. As the results of the present case studies show, the well-tuned VAR models generated using the proposed methodology in this research could provide reliable and acceptable results with reasonable accuracy in forecasting the SCT values for the near future days. 7. The DDM approach proposed in this article overcomes the main limitation of the empirical methods of WC prediction in using the simplifying assumptions and handling a limited number of independent variables in the prediction models. Besides, the VAR modeling approach proposed in this study could effectively deal with and forecast the cyclic patterns and nonmonotonic trends of SCT data.