(confusionMat)
| 49 | * actual class `r` were predicted as class `c`. |
| 50 | */ |
| 51 | export function drawConfusionMatrix(confusionMat) { |
| 52 | const w = confusionMatrixCanvas.width; |
| 53 | const h = confusionMatrixCanvas.height; |
| 54 | const ctx = confusionMatrixCanvas.getContext('2d'); |
| 55 | ctx.clearRect(0, 0, w, h); |
| 56 | const n = confusionMat.shape[0]; |
| 57 | const rawConfusion = confusionMat.dataSync(); |
| 58 | const normalizedConfusion = |
| 59 | confusionMat.div(confusionMat.sum(-1).expandDims(0)).dataSync(); |
| 60 | for (let i = 0; i < n; ++i) { |
| 61 | for (let j = 0; j < n; ++j) { |
| 62 | const rgbValue = Math.round(255 * (1 - normalizedConfusion[i * n + j])); |
| 63 | ctx.fillStyle = `rgb(${rgbValue}, ${rgbValue}, ${rgbValue})`; |
| 64 | ctx.fillRect(w / n * j, h / n * i, w / n, h / n); |
| 65 | ctx.stroke(); |
| 66 | ctx.strokeStyle = '#808080'; |
| 67 | ctx.rect(w / n * j, h / n * i, w / n, h / n); |
| 68 | ctx.stroke(); |
| 69 | ctx.font = '18px Arial'; |
| 70 | ctx.fillStyle = '#ff00ff'; |
| 71 | ctx.fillText( |
| 72 | `${rawConfusion[i * n + j]}`, w / n * (j + 0.45), h / n * (i + 0.66)); |
| 73 | ctx.stroke(); |
| 74 | } |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | export function setManualInputWinnerMessage(message) { |
| 79 | const winnerElement = document.getElementById('winner'); |
nothing calls this directly
no outgoing calls
no test coverage detected