def generate_similarity_matrix(matrix, faces, output_file):
    methods, rows, cols = matrix.shape
    output = []

    # Iterate each method
    for i in range(methods):
        if cols > 0:
            table = []
            table.append("<h1>Method %d</h1><table><tr><td></td>%s</tr>" % (i, "\n".join([ "<td>%s</td>" % faces[j][1] for j in range(cols) ])))

            for j in range(rows):
                table.append("<tr><td>%s</td>%s</tr>" % (faces[j][1], "\n".join([ "<td>%s</td>" % (("%.2f" % matrix[(i, j, k)]) if not numpy.isnan(matrix[(i, j, k)]) else "&mdash;") for k in range(cols) ])))

            table.append("</table>")
            output.append("\n".join(table))

    # Write table to file
    with open(output_file, "w") as f:
        f.write("""
            <html>
                <head>
                    <title>Similarity Matrix</title>
                </head>
                <body>
                    %s
                </body>
            </html>
        """ % "\n".join(output))
dataset/ETHPy150Open basilfx/Course-Face3D/face3d/utils.py/generate_similarity_matrix/original