[Python] Plot heatmap from list

Discussão em 'Python' iniciado por Stack, Maio 23, 2025.

  1. Stack

    Stack Membro Participativo

    I have an list of lists like so:

    my_list = [
    ['scoreA', 'scoreA', None],['scoreA', 'scoreB', 0.5], ['scoreA', 'scoreC', 0.4],
    ['scoreB', 'scoreB', None],['scoreB', 'scoreA', 0.5], ['scoreB', 'scoreC', 0.9]
    ]


    I wish to visualise these in a confusion matrix, to produce a heatmap/confusion matrix. I normally use confusion_matrix from sklearn to produce the matrix & seaborn heatmap to plot it, but in this case I already have a matrix stored in a different way and am uncertain about how to produce it.

    Desired output would be something like this:

    [​IMG]

    From reading the seaborn heatmap doccumentation, I don't understand the expected structure of the input data nor how to transform my data to mirror it.

    Continue reading...

Compartilhe esta Página