scmamp : Statistical Comparison of Multiple Algorithms in Multiple Problems

Comparing the results obtained by two or more algorithms in a set of problems is a central task in areas such as machine learning or optimization. Drawing conclusions from these comparisons may require the use of statistical tools such as hypothesis testing. There are some interesting papers that cover this topic. In this manuscript we present scmamp, an R package aimed at being a tool that simplifies the whole process of analyzing the results obtained when comparing algorithms, from loading the data to the production of plots and tables. Comparing the performance of different algorithms is an essential step in many research and practical computational works. When new algorithms are proposed, they have to be compared with the state of the art. Similarly, when an algorithm is used for a particular problem, its performance with different sets of parameters has to be compared, in order to tune them for the best results. When the differences are very clear (e.g., when an algorithm is the best in all the problems used in the comparison), the direct comparison of the results may be enough. However, this is an unusual situation and, thus, in most situations a direct comparison may be misleading and not enough to draw sound conclusions; in those cases, the statistical assessment of the results is advisable. The statistical comparison of algorithms in the context of machine learning has been covered in several papers. In particular, the tools implemented in this package are those presented in Demšar (2006); García and Herrera (2008); García et al. (2010). Another good review that covers, among other aspects, the statistical assessment of the results in the context of supervised classification can be found in Santafé et al. (2015).

Comparing the performance of different algorithms is an essential step in many research and practical computational works.When new algorithms are proposed, they have to be compared with the state of the art.Similarly, when an algorithm is used for a particular problem, its performance with different sets of parameters has to be compared, in order to tune them for the best results.
When the differences are very clear (e.g., when an algorithm is the best in all the problems used in the comparison), the direct comparison of the results may be enough.However, this is an unusual situation and, thus, in most situations a direct comparison may be misleading and not enough to draw sound conclusions; in those cases, the statistical assessment of the results is advisable.
The statistical comparison of algorithms in the context of machine learning has been covered in several papers.In particular, the tools implemented in this package are those presented in Demšar (2006); García and Herrera (2008); García et al. (2010).Another good review that covers, among other aspects, the statistical assessment of the results in the context of supervised classification can be found in Santafé et al. (2015).

Existing tools
Some of the methods presented in the referred papers are well known procedures that are included in classical statistics tools.As an example, p-value correction methods such as Holm (Holm, 1979) or omnibus tests such as Friedman's (Friedman, 1937) are implemented in R's base package.However, other methods are neither so well known nor trivial to implement.Worth of highlighting is Bergmann and Hommel's procedure (Bergmann and Hommel, 1988) to correct the p-values when all the algorithms are compared pair-wise (see García andHerrera, 2008, page 2681).
There are some tools that implement some of the methods included in this package.The first one is KEEL (Alcalá-Fdez et al., 2008), a Java toolbox that includes a module for the statistical assessment of the results obtained in a given experimentation.However, although it can be used independently from the rest of the toolbox, from the GUI it offers a limited combination of methods and any other analysis requires programming it in Java.
As an alternative to the KEEL GUI, STATService 2.0 (Parejo et al., 2012) provides a web service to perform statistical analysis of multiple algorithms using KEEL's code.In the same line we have STAC (Rodríguez-Fdez et al., 2015), a python web service that allows running different types of parametric and non-parametric tests using a simple interface and its own implementation of the methods.
The goal of scmamp is to provide a simple pipeline that allow any researcher to load the complete set of results, analyze them and produce the material needed for publication (tables and plots).
Under some circumstances we may be interested in analyzing the results in different groups of problems.An example of such a situation are the results presented in Blum et al. (2015), where the behavior of a set of algorithm was tested in problems of different size and complexity1 .In order to deal with these kinds of problems, conversely to other existing tools, the package offers the possibility of subsetting the results, which can be handy when the problems can be subdivided in different groups (e.g. based on their size).
Another advantage of the scmamp package over other existing implementations is that the functions that perform the analyses accept additional user-defined test and correction functions, increasing the flexibility of the analysis.Moreover, all the correction methods included in the stats package through the p.adjust function can be directly used in the scmamp package.Finally, worth of mention is that, although KEEL and STATService generate tables to be directly used in publications, they do not generate plots.In our package we have included two functions to graphically represent the results of the comparison.Moreover, performing the analysis in R (instead of using Java) allows the user to easily create his/her own plots.

Brief overview of the statistical tests and general recommendations
Several publications (Demšar, 2006;García and Herrera, 2008;García et al., 2010;Santafé et al., 2015) have stated a basic classification of general machine learning scenarios and the associated statistical tests which are appropriate for each situation.This package is mainly focused in the comparison of multiple algorithms in multiple datasets.However, due to the flexibility of the implemented functions can also be adapted to other situations.Figure 1 summarizes the most common situations when evaluating machine learning algorithms.
Comparisons of two algorithms among a set of different problems are common in the literature in order to decide between two competitors.The estimated scores for each algorithm on each problem are independent.However, as they may be obtained from different application domains (or problems with different characteristics), it is highly debatable whether they can be averaged over in order to obtain a meaningful overall estimation of the algorithm's performance.Consequently, non-parametric methods such as Wilcoxon signed-rank are usually recommended (Demšar, 2006).
On the other hand, in order to compare multiple algorithms in multiple problems, the general recommended methodology is as follows.First, we apply an omnibus test to detect if at least one of the algorithms performs different than the others.Second, if we find such a significant difference, then we apply a pair-wise test with the corresponding post-hoc correction for multiple comparisons.Friedman test with Iman and Davemport extension is probably the most popular omnibus test, and it is usually a good choice when comparing more than five different algorithms.By contrast, when comparing five or less different algorithms, Friedman aligned ranks and Quade test are more powerful alternatives (García et al., 2010).
Regarding post-hoc tests, the choice depends on the pair-wise comparisons: comparison with a control or all pair-wise comparisons.When comparing all the algorithms with a control, Bonferroni is the most simple but the least powerful procedure and, thus, as it is not recomended in practice.By contrast, Hommel and Rom are the two most powerful procedures but they are also more complex than other methods.Alternatively, Finner is a simple procedure and it is the next with the highest power (see García et al., 2010).Nevertheless, except for Bonferroni, in practice there are not very big differences in the power of the post-hoc tests.Therefore, Finner's method is a good choice in general due to its simplicity and power.
Similarly, when an all pair-wise comparison is conducted, those procedures to perform comparisons with a control can be used.In this case, the Nemenyi's test is the most simple but less powerful alternative and it is not usually recommended in practice.Alternatively, specific methods for all pair-wise comparison have a higher power.The one with highest power is Bergmann and Hommel, but it is a complex and computational expensive method.The scmamp package optimizes this method up to nine algorithms by having some pre-computed operations.Therefore, comparing more than nine algorithms with the Bergmann and Hommel procedure is unfeasible in practice.In those situations, Shaffer's static method or even other more simple procedures such as Finer and Holm are recommended.

Brief examples
In this section we will illustrate the use of the package in three different situations.For a more elaborated discussion on the use of the different functions the reader is referred to the package's vignettes.To access them, just type browseVignettes( scmamp ).
The first example of use is the one shown in García and Herrera (2008).Actually, we will use the set of results presented in that paper, which are included in the package in the variable data.gh.2008.These results collect the performance of a number of supervised classification algorithms in a set of 30 datasets.The goal of the study is comparing the different algorithms and determining which outperforms which.For more details, the reader is referred to García and Herrera (2008) The goal is analyzing all the pair-wise comparisons.Therefore, the first hypothesis to test is whether all the algorithms perform equally or, in contrast, some of them have a significantly different behavior.
Then, all the differences are tested for every pair of algorithms and the resulting p-values are corrected.
There are different ways to report the results, depending on the post-hoc analysis.A very intuitive tool is Demsar's critical difference plots.However, although easy to interpret, this plots are based on Nemenyi test, which is a very conservative one.There are other alternatives that can be used with more powerful methods (such as Bergmann and Hommel's correction).In this example we will use drawAlgorithmGraph, a function that creates a graph based on the p-values corrected by any method.
First, we check the differences using Iman and Davenport omnibus test.The p-value shown above denotes that there is at least one algorithm that performs differently than the rest and, therefore, we can proceed with the post-hoc analysis of the results.There are several alternatives to perform this analysis, but we will focus in two.The first alternative is Nemenyi test.
Although, this test is not a recommended choice in practice since it is very conservative and has a low power, it is shown in this example because its associated plot is quite illustrative.above, the differences between every pair of algorithms is stored in the diff.matrixelement of the result.Nemenyi test has the advantage of having an associated plot to represent the results of the comparison.This plot can be obtained as follows.
> plotCD(results.matrix= data.gh.2008,alpha = 0.05) The result can be seen in Figure 2. In this plot each algorithm is placed in an axis according to its average ranking.Then, those algorithms that show no significant differences are grouped together using a horizontal line.The plot also shows the size of the critical difference required for considering two algorithm as significantly different.
The second alternative shown in this example is The above code runs the post-hoc test, computing the raw p-value for each pair of algorithms.These p-values are also corrected for multiple testing using Bergman and Hommel's correction.Additionally, a summary with the average values of each algorithm over all the dataset is obtained.
The package offers two ways of presenting the results obtained in the analysis.On the one hand, we can create a L A T E X table using the function writeTabular.This function includes parameters to control several aspects of the table.For more details on its use the reader is referred to the vignette covering the data loading and manipulation.The table generated can be seen in Table 1.
> # LaTeX formated: Significances highlighted in bold > bold <-test.res$corrected.pval< 0.05 > bold[is.na(bold)]<-FALSE > writeTabular(table = test.res$corrected.pval,format = f , bold = bold, 2 These steps can be carried out independently using the functions implemented in the package.For more information the reader is referred to the package documentation.On the other hand, the results can be graphically shown in a graph that represents the algorithms that show no significant differences as connected nodes. > average.ranking<-colMeans(rankMatrix(data.gh.2008)) > drawAlgorithmGraph(pvalue.matrix = test.res$corrected.pval,+ mean.value= average.ranking) In the graph, shown in Figure 3, we can see that, according to the test, there is no significant differences within the pairs C4.5/NaiveBayes and kNN/CN2.Compared with the critical difference plot, this method is able to detect more differences (for example, Nemenyi test does not detect significant differences between kNN and kernel).
For the second example we will use a dataset where the problems can be subdivided into groups.The dataset shows the results obtained by eight different algorithms used to find large independent sets in graphs.The performance of the algorithms is evaluated in a number of randomly generated graphs of different size and density.Thus the results matrix we will use contains, in each row, the result obtained by each algorithms in a given problem.This dataset is part of the results in Blum et al. (2015), and it is also included in the package.Finally, for the third example we will use the same dataset from Blum et al. (2015).In this example we want to compare the algorithms separately for every value of Radius given a fixed Size.The functions in scmamp can be also used for these kinds of comparisons.In this case we will use the Wilcoxon test and the p-values will be corrected using Finner's method and, then, a L A T E X table will be generated.In this table the best results will be highlighted in bold font and those without significant differences will be identified with a superscript.All these steps can be carried out with this code.
First, filter the data.

Conclusions
The scmamp package has been designed with the goal of simplifying the statistical analysis of the results obtained in comparisons of algorithms in multiple problems.With a few lines of code, the users can load and analyse the data and format the result for publication.This document is a brief introduction to the package.For further details on the use of the functions the reader is referred to the documentation and, particularly, to the vignettes of the package.

Figure 1 :
Figure 1: Recommended statistical test for different scenarios.

Figure 2 :
Figure 2: Example of critical difference plot.

Comparisons among several datasets Wilcoxon signed-ranks 2 algorithms OMNIBUS TESTS Several algorithms +
.
Friedman post-hoc test with Bergmann and Hommel's correction.Both steps can be carried out in a single line of code. 2

Table 1 :
Example of table generated by the package.

Table 2 :
Rendering of a L A T E X table generated with the writeTabular function.