{'fraction_non_alphanumeric': 0.028351346991450234, 'fraction_numerical': 0.00883206968865946, 'mean_word_length': 4.567355186349349, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Explainable Global Error Weighted on Feature Importance: The xGEWFI metric to evaluate the error of data imputation and data augmentation

Evaluating the performance of an algorithm is crucial. Evaluating the performance of data imputation and data augmentation can be similar since both generated data can be compared with an original distribution. Although, the typical evaluation metrics have the same flaw: They calculate the feature's error and the global error on the generated data without weighting the error with the feature importance. The result can be good if all of the feature's importance is similar. However, in most cases, the importance of the features is imbalanced, and it can induce an important bias on the features and global errors. This paper proposes a novel metric named"Explainable Global Error Weighted on Feature Importance"(xGEWFI). This new metric is tested in a whole preprocessing method that 1. detects the outliers and replaces them with a null value. 2. imputes the data missing, and 3. augments the data. At the end of the process, the xGEWFI error is calculated. The distribution error between the original and generated data is calculated using a Kolmogorov-Smirnov test (KS test) for each feature. Those results are multiplied by the importance of the respective features, calculated using a Random Forest (RF) algorithm. The metric result is expressed in an explainable format, aiming for an ethical AI.


Introduction
In a context where missing data imputation and data augmentation are evolving rapidly, it is important to develop new tools to evaluate those machine learning algorithms. This novel method weights the error calculated after generating data (missing or augmented data). The weighting is done on the importance of the features, giving an error a weight related to its feature importance. It is also important to create new tools with the ability to explain the results. For the ethical purpose, from now on, efforts have to be made to produce algorithms with explainable results. This novel xGEWFI metric includes itself in this paradigm.
To compare the generated data to the original data, the xGEWFI metric uses a Kolmogorov-Smirnov test [24]. This test has been widely used for decades in mathematics. It compares the properties of the distribution of two series of data. In a data imputation context, the imputed data for a feature are compared with the original data for this same feature. In a data augmentation context, the added data are compared with the original data. Comparing the generated and the original data, two metrics (statistical and value) are returned to describe the covariance between them. It shows the quality of the data generation process. This test is well-known and has been used since decades [20] [22] [6] [12].
At the heart of the xGEWFI metric is the evaluation of the feature's importance. Normally, all measures of feature error are equally weighted. A better representation would take into account the importance of each feature. This is why a Random Forest (RF) algorithm is used in this novel metric. Based on [7] [27] [16], an RF algorithm is used as a regressor, as a classifier, but also as a tool to evaluate the importance of the features. It works in a supervised learning context, based on bayesians networks and on decisions trees. It has been widely used in a variety of applications [23] The next algorithms (SMOTE, KNNImputer, and IQR) are useful to implement the whole method that test the xGEWFI algorithm. This method is a whole preprocessing pipeline that makes detection of outliers, data imputation and data augmentation.
The process of outliers detection is made using the IQR method. Outliers are feature's values that fall outside of the normal distribution. The IQR method defines outliers in a mathematical and formal matter, using the interquartile range rule. It is commonly used as in the papers of [33] [2] [29] [34].
The data imputation process is done using the K-Nearest-Neighbor Imputer (KNNImputer). It finds a missing value using k-Nearest Neighbors algorithm. Each sample's missing values are imputed using the mean value from n nearest neighbors availables for a given feature. It is widely used, like in the works of [13] [30] [31] [10]. There are some more advanced methods to impute some missing data. Some specialized Generative Adversial Networks (GAN), like Generative Adversial Imputation Networks (GAIN) algorithm has been recently created [1] [36] [35] [25] [37].
The data augmentation is implemented using the Synthetic Minority Oversampling Technique (SMOTE) algorithm [8]. This algorithm help to solve the imbalanced datasets problem by oversampling the minority classes. It exists some more recent and state-of-the-art methods to perform data augmentation. The GANs, for instance [5] [18] [28] uses two deep neural networks to create new data. Although, the SMOTE algorithm is still widely used [19] [26] [11] [17] and sufficient for this method that validate the proposed xGEWFI metric.
The datasets used to validate this method has been generated using the Scikit-Learn framework [21]. Especially the datasets.make_regression() [4] and datasets.make_classification() [3] functions using different parameters. Both were used to produce a different datasets based on regression and classification. Both functions are widely used in various paper such as [32] [9] [14] [15]. The generated datasets had the advantage of being fully reproducible when being called with the same parameters.
The main contribution of this paper is to propose a more precise and less biased metric that into account the importance of the feature and, consequently, the importance of the feature's error. It also contributes to AI ethics by proposing an explainable metric, especially for data missing and data augmentation.
The next sections of this paper are organized with the following structure: Section 3 describes the proposed methodology. Section 4 presents the results. Section 5 discusses about the results and their meaning and Section 6 concludes this research.

Preprocessing of dataset
As mention in 2, the datasets are generated by the datasets.make_regression() and the datasets.make_classification() of the Scikit-learn framework. When called, the parameters allow selecting different dataset characteristics according to the test. It is possible to customize the number of rows and features. Here is a description of the parameters that generate the synthetic data. n_sample: The number of rows or generated data. n_features: The number of columns or features. n_target and n_classes: The number of field that targets the regression and the classification data respectively. In all our cases, this one is always equal to 1. shuffle: When equal to True, it randomly changes the order of the data. This parameter is always True in our cases. random_state: It is the seed used to randomly generated the data. If the same seed (an integer number) is used, then the generated data will always be the same. In our case, a value of 1 is always used for better reproducibility. For this study, 5% of outliers and 30% of data missing have been randomly generated. Figure 1 shows the preprocessing method's architecture that includes and validates the xGEWFI metric. Figure 1: Architecture of the preprocessing method that includes and validates the xGEWFI metric This figure shows that the first step consists of sending the raw data to the outliers detection module. This part does the following 1. detects outliers 2. replaces the outliers with a null value. Those null values will be replaced by correct values at the next step, using a KNNImputer Algorithm. The next part does the data generation. The first one imputes the data missing using a KNNImputer algorithm. The second one does the data augmentation process using a SMOTE algorithm. The results are the imputed data and the augmented data generated. Both are returned to the data scientist and sent to the xGEWFI algorithm. The xGEWFI algorithm compares the generated data distribution to the original data's distribution using a KS test. It evaluates the error of the data generation process, both globally and for each feature. An RF algorithm is executed afterward to find the feature importances. Finally, the xGEWFI is calculated based on each feature's error and importance. All the information for the xGEWFI metric (error and explainability) is sent to the data scientist.

xGEWFI metric -Global Error Weighted on Feature Importance
Metrics usually measure errors or performances of a process without considering the feature's importance. The premise of xGEWFI metric is that the feature importance should weigh the error amplitude. A high-value error should represent nothing if the feature importance is null or extremely low. Conversely, the amplitude of an error should be higher with high feature importance. We must first calculate the feature importance using an RF algorithm to calculate the xGEWFI metric. RF algorithms are based on Bayesian networks and multiple decision trees. A single decision tree may lead to some bias, so having tenths of decision trees (as proposed by the RF algorithm) solve this problem, as it pools all the outcomes to return the most frequent answer. It exists two applications of RF algorithms: 1. RF regressors and 2. classifiers. Both are also used to evaluate the importance of the features. The solution can be displayed in a tree graph where the nodes represent the decision. The branches represent the possible outcomes. The leaves represent all the possible answers, combined with their probability. With this ability to compute a tree of bayesian probability, the RF algorithms can also calculate the feature importances in the regression of the classification process. The importance of each feature is given in a normalized form. Then we must calculate the performance of the data generation algorithms (data imputation and data augmentation). The KS test is used to do so. This test is used to compare two distributions. In our case, the original data distribution is compared with the generated (imputed or augmented) data distribution. The formula of the KS test is shown in 1. (1) Similarly, F g,f is the distribution function of the same feature f of g, the generated x data. The case where there is no difference between the two distributions is called the null hypothesis. In 1 the result D (the D-statistic) is the evaluation of the error. A value of D = 0.0 is the null hypothesis.
Without calculating the feature importance, we can conclude that, since the D-statistics indicates the error between two distributions, it can be considered as the error of the generated distribution as in 2. (2) The global error is the sum of all the feature's errors, as in 3 (3) Even though those numbers are not the finality, they are returned by the xGEWFI algorithm as part of the final answer for explainability matters. Those numbers are an important part of the final answer and must be available to the data scientist to help him to have a better comprehension of the process.
Based on both the RF algorithm and the KS test, the xGEWFI metric relies on the D-Statistics and on the importance of the features. 4 and 5 shows the calculations for each feature error and for global error, respectively.

Outliers data
The first part of the process consists of identifying the data outliers. The need is to identify the outliers and replace them with some null values that will be processed later. To do that part, we use the IQR method. It consists of dividing each feature of the dataset into quartiles. Fig. 2 shows a box plot representation of the IQR method. The first quartile point Q1 indicates that 25% of the data points are below that value. The second quartile Q2 is the median point of the feature. The third quartile Q3 is at the point where 75% of the data points are below that value. Eq. 6 defines the IQR, 7 defines the lower limit, and 8 defines the upper limit.
When a value outside the lower and upper is found, it is replaced by a null value. This value will be processed once again in the next step while processing the missing data.

Data imputation
The system trained a KNNImputer to impute the values of the missing data. This algorithm relies on the KNN algorithm aiming to find the k nearest neighbour of the missing data. This algorithm is based on the computation of the distance between the data. In this case, the euclidian distance is used as in 9.
D is the euclidian distance, k is the number of neighbours to find. Finally, x and y are the origin and destination data, respectively.

Data augmentation
A SMOTE architecture is used to oversample data of the original dataset. It helps to solve the imbalanced data problem. It balances class distribution by randomly increasing minority instances. Virtual training records are generated by linear interpolation for the minority class. The algorithm selects the k-nearest neighbours for each data added in the minority class. To compute the distance between the neighbours, the euclidian distance is used as defined in 9.

Results
Let us study two cases to explain the advantages of the xGEWFI metric that weights the error with the feature's importance. In a case where all the features have the same importance, the weighting specific to the xGEWFI process would not affect the result much. Although, in the majority of the cases, the difference is significant. The following subsections present two typical and common cases where the xGEWFI metric changes drastically our evaluation of the data imputation and data augmentation process. Both cases use a different dataset. Both datasets have five features and 25000 data.

Case 1 -Similar features errors and different features importances
This first case evaluates the results of a data imputation on a regression problem. We have a similar feature error as presented in Fig. 3. We can see in this figure that every feature shows an error of near 0.35 on the KS test (axe Y) for each feature on axe X. The sum of the errors is 1.68, representing a final metric on the quality of the imputation process. Without the xGEWFI metric, evaluating the data imputation would stop here. Is this metric alone the best method to represent the quality of this data imputation process? The xGEWFI method proposes a method that considers each feature's weight. The final result (the xGEWFI error) will be more representative of the quality of the augmentation/imputation process, having weighted the KS test error on the feature importance. For this case, Fig. 4 presents the importance of the features. We can see that every feature on axe X has a different level of normalized importance on axe Y.  Since every feature has about the same error as shown in Fig. 3, the result of the xGEWFI error is also about the same as the feature importance. It can be seen clearly by comparing Fig. 4 and Fig. 5. We can conclude for this test that the error using a KS test is very different than the xGEWFI error ( Fig. 3 and Fig. 5). The global error of the KS test was 1.68, and the xGEWFI global error was 33.75. The magnitude of the two metrics cannot be compared. Each one must be compared with other errors of the same kind.

Case 2 -Important differences between features importances and errors
This second case evaluates the results of data augmentation on a classification problem. Fig. 6 shows the result of the KS test representing the error (ax Y) on each feature (ax X). This figure shows an important variation between each feature's error at the opposite of the KS test error presented in case 1. The feature's importance varies significantly, as shown in Fig. 7. Without going further using xGEWFI, we would conclude that the errors on features 1 and 4 are higher. The errors on features 3 and 5 are insignificant compared to the other feature's errors. A better way to evaluate the error would be to consider the features' importance. Fig.  7 presents the importance of the features for case 2. In this figure, the X axe is the dataset's features, and the Y axe is the normalized level of importance of the features. We can conclude, for instance, that feature 3 is by far the most important, and feature 4 is negligible. Let us see the impact of weighting the KS test error with the feature's importance. This is shown in the xGEWFI graphic in Fig.8. We can note that every feature's error has been weighted according to the importance of the features. Let us study specifically feature 3 and feature 4. Feature 3 KS test error (Fig.6) is very low. It is also by far the most important feature (Fig.  7. Ultimately, the relative importance of the feature compared to the other features has been raised. As for feature 4, the KS test error was quite high (Fig.6). Since the importance of this feature is very low (Fig. 7), the xGEWFI error for this feature is lower than its KS test error evaluation. Like in case 1, the second case allows us to conclude that the results are different, whether they are weighted or not using the feature importance using the xGEWFI error ( Fig. 3 and Fig. 5). In this case, the global error of the KS test was 0.60, and the xGEWFI global error was 0.54. As mentioned in 4.1, the magnitude of the two metrics cannot be compared. They must be compared with their respective kind. This case showed that xGEWFI metric as the advantage of being weighted using the feature's importance. Also, the results are explainable, as shown in Section 4.3.

Explainability
The "x" at the beginning of xGEWFI stands for "explainable". This metric has not only been developed to give a quantitative evaluation of a data imputation or a data augmentation. It has also been developed to explain its process. That is why graphics and tables were encapsulated in the xGEWFI method. Fig. 6 7), 8, for instance, are fully part of the method, aiming to give the users a better comprehension of the process. There are also 3 other types of graphics created to help the user better comprehend the data and the process. Fig. 9 is an example (the dataset used for case 1) of a graphic that shows the distribution of each feature using a box plot graphic. Figure 9: Example of a box plot graphic encapsulated in the xGEWFI method for better explainability.
The median marks the mid-point of the feature's val-ues and is shown by the line that divides the box into two parts. Half the scores are greater than or equal to this value, and half are lower. The middle box represents the middle 50% of scores for the feature. The upper and lower whiskers represent scores outside the middle 50%. Dots outside of the whiskers are outliers. Fig.10 is another visual tool used to explain the data and the process. The xGEWFI method generates one graphic of this type by feature. It is a histogram of the original and generated (imputed or augmented) data. Blue bars represent the original data, and yellow bars represent the generated data. X axe is the standard deviation of the feature, and Y axe is the number of occurrences of those standard deviation ranges. Gaussian distribution is visible for both generated and original data. The third type of graphic combines the 3 important parameters used in the xGEWFI equation ((4). It shows the magnitude of the 3 parameters. Ultimately, the method offers the user the numerical data required to calculate the xGEWFI metric. The data are displayed on the screen, and two LaTeX tables are generated and ready to be included in a document. For instance, tables 12 and 13 has been generated by the xGEWFI method in case 1.

Comparison between this novel method and original methods
KS test has been widely used for decades in statistics. It aims to determine the degree to which two samples follow the same distribution. This method is a simple way to compare the original data to the generated (imputed or augmented) data. This eval-uation method has been used in this work since it is known as a reference in statistics to compare two data distributions. This proposed xGEWFI method principle could also apply to any other metric. Some quantified comparisons between the KS test and the xGEWFI method are shown in last section, especially in Fig. 11, Table 12, and 13.
The results show that the evaluation method used (the KS test) will give an evaluation of the similarity between the original data and the generated data for each feature. We must use some strategies to explain why this metric gives those results. The xGEWFI method is designed for explainability.

Discussions
A novel explainable metric for data imputation and data augmentation has been developed in this paper. To validate this metric, a complete method to detect and correct outliers, impute data and augment data has been made. It has been tested on two datasets of 25000 rows and 5 features. One dataset is a classification problem, and the other is a regression problem. Both datasets are fully reproducible using the make_regression() and make_classification() functions available in the scikit-learn framework.
The two significant advantages of the xGEWFI metric are 1. The feature importance weights each feature error (composing the global error). 2. The result is explainable, as mentioned in section 4.3. The results are presented in two different cases. The first case was a data imputation problem for a regression-oriented dataset. The KS test gives the same error to all the features (Fig. 3). The importance of the features is unequally distributed, as shown in Fig. 4. It is obvious that feature 1 is very significant, and feature 4 is insignificant. Since the process gives similar KS test errors for all features, the results of the xGEWFI algorithm (5) will be very similar to the feature importance (Fig. 3). Although, the xGEWFI made a huge improvement, since it is the Fig. 3 and Fig. 5 that must be compared.
The second case was a problem of data augmentation in a classification-oriented dataset. The KS test errors differed for all features (Fig. 6). The importance of the features was also different, as presented in Fig. 7. The results are shown in Fig. 8. It represents the KS test values weighted by the feature importances.
There is only one situation where the xGEWFI method would not significantly improve the metric. That is when the feature importances are equally distributed between them. Nonetheless, this situation is the exception and not the rule. Hence, the improvement of the xGEWFI method is significant in most situations. This novel method helps evaluate the performance of a data imputation or augmentation process. A data scientist could try different meta-parameters on a data imputation algorithm (like KNNImpute or GAIN) or a data augmentation algorithm (like SMOTE or GAN). The xGEWFI metric will give him an explainable evaluation, weighted on the importance of the feature specific to his dataset. In the end, this research succeeds in improving data imputation and data augmentation metrics developed in an explainable manner.

Conclusion
This paper proposed a novel explainable metric to evaluate the performance of any data imputation and data augmentation method. Using a classification-oriented dataset, or a regressionoriented dataset, this research implements a whole process to 1. Detect outliers and replace them with null values. 2. Impute missing data, and 3. Augment the data. At the end of this process, the proposed xGEWFI algorithm computes the error based on the KS test, a well-known statistical reference aiming to compare two feature's distribution (the original one and the generated one). The results of this KS Test are then multiplied by the importance of the respective features generated by an RF algorithm, resulting in a weighted error more representative than the non-weighted error. This result, the xGEWFI metric, allows the data scientist to evaluate better the impact of the meta-parameters used in the imputation and augmentation process and on his datasets. This method can be improved in the future by replacing the classic KS test with another metric. KS test is a well-known classic method to compare the distribution of two variables. In this context, it has been utilized to test de validity of the imputation and the augmentation process. A more practical test may be found for xGEWFI in the future. In machine learning, the concept of explainability is relatively recent. This new field is proliferating and will keep growing in the following years. New concepts and methods will flourish, and it is very likely that xGEWFI explainability could be improved shortly.

Acknowledment
This work has been supported by the "Cellule d'expertise en robotique et intelligence artificielle" of the Cégep de Trois-Rivières.