Pair confusion matrix for more than two cluster algorithms How would one code the following issue:
The columns represent the k groupings from the k cluster algorithms. The rows are the N(N-1)/2 pairs of data points. If an algorithm groups a pair together (i,j) = 1 and 0 otherwise. This results in a binary matrix of size N(N-1)/2 x k. Agreement occurs if algorithms both group a pair of data points together.
How would I calculate, i.e. program, this number for all k combinations of algorithms?
https://link.springer.com/article/10.1007/BF01908075
a in this case represents the pairs of data points grouped together by algorithms 1, 2, 3, ..., k or any other combination of algorithms, for example, 2, 3 and k or 1, 2, 3 and 4. This will allow us to make an UpSet plot:
https://en.wikipedia.org/wiki/UpSet_Plot#:~:text=UpSet%20plots%20are%20a%20data,sets%20(or%20vice%20versa)
and
https://kieranhealy.org/blog/archives/2020/04/16/upset-plots/

cluster=c(2,1,2,0,0,3)                 # kmedioids
cluster=cbind(cluster,c(0,0,0,0,0,1))  # spectral
n=nrow(cluster)
N=n*(n-1)/2                            # aantal paren 
A=matrix(NA,N,2)
for (k in 1:ncol(cluster)){
  rowcounter=1
  for (i in 1:(n-1)){
    for (j in (i+1):n){
      A[rowcounter,k]=cluster[i,k]==cluster[j,k]
      rowcounter=rowcounter+1
    }
  }
}

But unfeasible for Python! Re-write appreciated
