# How to measure the correlation of different algorithms

In stacked generalization, several algorithms are trained on the training set (i.e. at layer 1) and their predictions are then stacked using a layer 2 model. In many documentations, it is said that it is better that the layer 1 algorithms should be of low correlation. How can one compute this correlation between algorithms ?

For regression tasks correlation will be simply the correlation between the predicted values, for binary classification it will be correlation between predicted probabilities. In multiclass classification you can find correlation between predicted factor variables using the hetcor package in R