min_fnorm: Minimize Frobenius norm for between two matrices
Description
Finds a permutation of a matrix such that its Frobenius norm with another
matrix is minimized.
Usage
min_fnorm(A, B = diag(nrow(A)))
Value
Permuted matrix such that it is the permutation of A closest to B
Arguments
A
data matrix we want to permute
B
matrix whose distance with the permuted A we want to minimize. By
default, B <- diag(nrow(A)), so the permutation maximizes the trace of A.
Author
Ravi Varadhan:
https://stat.ethz.ch/pipermail/r-help/2010-April/236664.html
Details
Finds the permutation P of A such that ||PA - B|| is minimum in Frobenius
norm. Uses the linear-sum assignment problem (LSAP) solver in the package
clue. The default B is the identity matrix of same dimension, so that the
permutation of A maximizes its trace. This procedure is useful for
constructing a confusion matrix when we don't know the true class labels of a
predicted class and want to compare to a reference class.