I once worked in a group where we did this sort of plotting. The way that
we did this was to simply use a Monte Carlo approach. Write a function that
calculates the average distance from the diagonal with your current matrix
arrangement. (If two items are very similar but not close together, their
[i][j] entry will be located far from the diagonal.) Then, pick a random
pair of objects $i1 and $i2. Swap both the rows and columns and repeat the
calculation. Accept with some probability and repeat. The "average distance
from the diagonal" should go down until you reach a steady-state. You could
then use simulated annealing---gradually lowering your acceptance
probability---to minimize the fluctuations once you reach steady-state.

It sounds a little complicated, but it's not too hard to write. I hope that
helps!
David

On Mon, Nov 28, 2016 at 5:21 PM, Boyd Duffee <[email protected]> wrote:

> Hi All,
>
> I have a list of objects and a measure of similarity between each of them
> such that I can define a matrix that holds the similarity between objects
> $i and $j as
>     $similarity->[$i]->[$j]  = sim($i, $j);
>
> I'd like to display that matrix as a heatmap but with the list of objects
> sorted so that when I plot it, objects that are similar are next to each
> other.  I'm getting a lot of heatmap results from TFW and some on CPAN, but
> they all seem to be concerned with overlays on maps rather than the
> ordering of the columns.  I can display the result with gnuplot, but I'm
> getting bogged down in the sorting.
>
> I'm in the middle of some kind of selection sort based on minimizing the
> sum of the differences between the rows, but I thought I should ask if
> anyone has any experience with pretty-ing up heatmaps or if the problem has
> already been solved.
>
> thanks,
> --
> Boyd Duffee
>   Brexit has made Europe the new rock and roll,
>   that thing the older generation just doesn't understand.
>
> ------------------------------------------------------------
> ------------------
>
> _______________________________________________
> pdl-general mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/pdl-general
>
>


-- 
 "Debugging is twice as hard as writing the code in the first place.
  Therefore, if you write the code as cleverly as possible, you are,
  by definition, not smart enough to debug it." -- Brian Kernighan
------------------------------------------------------------------------------
_______________________________________________
pdl-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pdl-general

Reply via email to