{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "34b0345b", "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import pandas as pd\n", "import seaborn as sns\n", "import matplotlib as mpl\n", "from matplotlib import pyplot as plt" ] }, { "cell_type": "markdown", "id": "75b9f701", "metadata": {}, "source": [ "# Render Confusion Matrices\n", "\n", "DIGITs generates confusion matrix tables, need to render as is, not generate using scikit-learn's func" ] }, { "cell_type": "code", "execution_count": 2, "id": "10521209", "metadata": {}, "outputs": [], "source": [ "frame = pd.read_csv('architecture-investigations/fc/3-layers/1024/conf.csv', index_col=0)\n", "accuracy_col = frame.pop('Per-class accuracy')" ] }, { "cell_type": "code", "execution_count": 19, "id": "02c2844f", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "50.0% 0.5\n", "25.0% 0.25\n", "30.0% 0.3\n", "100.0% 1.0\n", "71.43% 0.7142857142857143\n", "44.44% 0.4444444444444444\n", "62.5% 0.625\n", "0.0% 0.0\n", "50.0% 0.5\n", "20.0% 0.2\n", "\n", "MAP = 49.3%\n" ] } ], "source": [ "normalised_array = np.ndarray((196, 196))\n", "for idx, row in enumerate(frame.to_numpy()):\n", " normalised_array[idx, :] = row / np.sum(row)\n", "\n", "# check correct accuracy\n", "for acc, (idx, row) in zip(accuracy_col, enumerate(normalised_array[:10])):\n", " print(acc, row[idx])\n", "\n", "class_acc_counter = 0\n", "for idx, row in enumerate(normalised_array):\n", " class_acc_counter += row[idx]\n", " \n", "print(f\"\\nMAP = {class_acc_counter*100/196:.4}%\")" ] }, { "cell_type": "code", "execution_count": 4, "id": "91132579", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | AM General Hummer SUV 2000 | \n", "Acura RL Sedan 2012 | \n", "Acura TL Sedan 2012 | \n", "Acura TL Type-S 2008 | \n", "Acura TSX Sedan 2012 | \n", "Acura Integra Type R 2001 | \n", "Acura ZDX Hatchback 2012 | \n", "Aston Martin V8 Vantage Convertible 2012 | \n", "Aston Martin V8 Vantage Coupe 2012 | \n", "Aston Martin Virage Convertible 2012 | \n", "... | \n", "Toyota Camry Sedan 2012 | \n", "Toyota Corolla Sedan 2012 | \n", "Toyota 4Runner SUV 2012 | \n", "Volkswagen Golf Hatchback 2012 | \n", "Volkswagen Golf Hatchback 1991 | \n", "Volkswagen Beetle Hatchback 2012 | \n", "Volvo C30 Hatchback 2012 | \n", "Volvo 240 Sedan 1993 | \n", "Volvo XC90 SUV 2007 | \n", "smart fortwo Convertible 2012 | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
AM General Hummer SUV 2000 | \n", "6 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "... | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "1 | \n", "
Acura RL Sedan 2012 | \n", "0 | \n", "2 | \n", "1 | \n", "0 | \n", "2 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "... | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "
Acura TL Sedan 2012 | \n", "0 | \n", "1 | \n", "3 | \n", "0 | \n", "2 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "... | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "
Acura TL Type-S 2008 | \n", "0 | \n", "0 | \n", "0 | \n", "3 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "... | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "
Acura TSX Sedan 2012 | \n", "0 | \n", "1 | \n", "0 | \n", "0 | \n", "5 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "... | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
Volkswagen Beetle Hatchback 2012 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "... | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "5 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "
Volvo C30 Hatchback 2012 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "... | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "1 | \n", "4 | \n", "0 | \n", "0 | \n", "0 | \n", "
Volvo 240 Sedan 1993 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "... | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "10 | \n", "0 | \n", "0 | \n", "
Volvo XC90 SUV 2007 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "... | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "7 | \n", "0 | \n", "
smart fortwo Convertible 2012 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "... | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "10 | \n", "
196 rows × 196 columns
\n", "