{ "cells": [ { "cell_type": "markdown", "metadata": { "id": "ctxfpXLwzIFf" }, "source": [ "## HW1 - Basics of ML\n", "Include your code in the relevant cells below.\n", "Subparts labeled as questions (Q1.1, Q1.2, etc.) should have their answers filled in or plots placed prominently, as appropriate." ] }, { "cell_type": "markdown", "metadata": { "id": "Y3JkhtmuzIFh" }, "source": [ "#### Important notes: \n", "\n", "1. On this and future homeworks, depending on the data size and your hardware configuration, experiments may take too long if you use the complete dataset. This may be challenging, as you may need to run multiple experiments. So, if an experiment takes too much time, start first with a smaller sample that will allow you to run your code within a reasonable time. Once you complete all tasks, before the final submission, you can allow longer run times and run your code with the complete set. However, if this is still taking too much time or causing your computer to freeze, it will be OK to submit experiments using a sample size that is feasible for your setting (indicate it clearly in your submission). Grading of the homework will not be affected from this type of variations in the design of your experiments.\n", "\n", "\n", "2. You can switch between 2D image data and 1D vector data using the numpy functions flatten() and resize()" ] }, { "cell_type": "markdown", "metadata": { "id": "DASCSh47zIFi" }, "source": [ "### S1: Understanding the data\n", "- Load MNIST dataset (hint it's available as part of https://keras.io/api/datasets)\n", "\n", "Q1.1: What is the number of features in the training dataset: ___\n", "\n", "Q1.2: What is the number of samples in the training dataset: ___\n", "\n", "Q1.1: What is the number of features in the testing dataset: ___\n", "\n", "Q1.4: What is the number of samples in the testing dataset: ___\n", "\n", "Q1.3: What is the dimensionality of each data sample: ___" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "GtK6dcBdzIFi" }, "outputs": [], "source": [ "import keras\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "import pandas as pd" ] }, { "cell_type": "code", "source": [ "from keras.datasets import mnist" ], "metadata": { "id": "ynjUJ-I9z89o" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "(X_tr, Y_tr), (X_te, Y_te) = mnist.load_data()" ], "metadata": { "id": "lhk5c9VGzXM0" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "print('X_tr: ' + str(X_tr.shape))\n", "print('Y_tr: ' + str(Y_tr.shape))\n", "print('X_te: ' + str(X_te.shape))\n", "print('Y_te: ' + str(Y_te.shape))" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "tolr-fSezaQ0", "outputId": "754cf4d0-c536-4e04-ff73-9443d3c0cb36" }, "execution_count": null, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "X_tr: (60000, 28, 28)\n", "Y_tr: (60000,)\n", "X_te: (10000, 28, 28)\n", "Y_te: (10000,)\n" ] } ] }, { "cell_type": "code", "source": [ "print('Unique labels: ' + str(np.unique(Y_tr, return_counts=True)))" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "Vsxkiek5zxOK", "outputId": "a76fccd2-bdf3-484b-efe7-8ac1d1ffbee0" }, "execution_count": null, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "Unique labels: (array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], dtype=uint8), array([5923, 6742, 5958, 6131, 5842, 5421, 5918, 6265, 5851, 5949]))\n" ] } ] }, { "cell_type": "markdown", "metadata": { "id": "mKCD1xmkzIFj" }, "source": [ "### S2: Viewing the data\n", "- Select one random example from each category from the training set. Display the 2D image with the name of the category\n", "\n", "Q2.1: Visualize the example image: ___" ] }, { "cell_type": "code", "source": [ "## Read categories\n", "labels = np.unique(Y_tr)\n", "\n", "## Create 2x5 subplot\n", "fig, ax = plt.subplots(nrows = 2, ncols = 5)\n", "\n", "## Loop to plot each category\n", "for i, tmpl in enumerate(labels):\n", "\n", " ## Select a random image with the current label\n", " indAll = np.where(Y_tr == tmpl)[0]\n", " indSel = indAll[np.random.randint(indAll.shape)]\n", " selImg = X_tr[indSel,:,:].squeeze()\n", "\n", " ## Convert loop index to 2D index for the 2x5 plot\n", " a1, a2 = np.unravel_index(i, [2,5]) \n", " \n", " ## Plot image\n", " ax[a1, a2].imshow(selImg)\n", " ax[a1, a2].set_title('Label ' + str(tmpl))\n", "\n", "## Show image\n", "plt.show()" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 240 }, "id": "cDnEoqPvzqfA", "outputId": "66ef9396-7141-4924-f3bf-b9517e991b1f" }, "execution_count": null, "outputs": [ { "output_type": "display_data", "data": { "text/plain": [ "
" ], "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXIAAADfCAYAAADr0ViNAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAAgAElEQVR4nOy9eZQkV3Xn/7mx5L7Vvm+9b9rQiiTQgjDCgBksC7PZ4A3sc5jjfcww9s/L4DE/+zeesceDPTBgDF7ACNssAmEkJJCEaLXU6r3Ve1XX3rVlVu6ZEfF+f2R2d3VXdXd1V1ZlZis+5+SpzMiMiPe+9eLGi/vuu0+UUri4uLi41C9atQvg4uLi4rIyXEPu4uLiUue4htzFxcWlznENuYuLi0ud4xpyFxcXlzrHNeQuLi4udc51YchF5BkR+cW13reWcTVZjKvJYlxNlqbedKkpQy4igyLyULXLsRAR+XURmRCReRH5nIh41/j8NaWJiOwQke+IyLSIVGUSQg1q8kERebncRkZE5E9FxFjjMtSaJu8RkSMikhCRMyLydyISqUI5akqXhYjIUyKiKtFWasqQ1xoi8hbgY8CbgD5gHfCHVS1U9SkC/wz8QrULUkMEgF8DmoE7KbWX36pqiarP88A9SqkopevGAD5R3SLVDiLyfsCs1PHqwpCLSIOIfFNEpkRkrvy++6KfrReRF8u9oq+JSOOC/e8SkR+KSFxE9orI/cs89QeBzyqlDiql5oD/CnyoIpVaIdXSRCl1RCn1WeBgBatTEaqoyV8rpZ5VShWUUqPAPwD3VK5m104VNRlWSk0v2GQDG1Zeo8pQRZuCiESB3wf+U2VqUyeGnFI5/5ZSr7gXyAJ/ddFvfhb4eaADsIC/BBCRLuBxSr2BRko9pa+KSMsyzrsd2Lvg816gTUSarrkmlaNamt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WAAMICDwE0rcexl7EM7cNvS3xFgELgJ+F3g396Iuvia+Jqsli6+Jq99rdSI/C7gtJRySEpZB74KPLpCx14WpJTTUsr9S38XgONA5zXudl3r4mtyIb4mF+c66OJrch4rZcg7gfHz3k9w7Sf3qiGE6ANuBV5c2vSrQohDQoi/FEIkrmJXG0YXX5ML8TW5OMuki6/JefiTnVeJECIM/CPwWSllHvgzYBOwB5gG/usqNm9V8DW5EF+Ti+PrciHLoclKGfJJoPu8911L29YVQgidhuB/K6X8BoCUclZK6UopPeBLNB75rpR1r4uvyYX4mlycZdbF1+Q8VsqQ7wW2CCH6hRAG8DHg2yt07GVBCCGALwPHpZR/fN729vO+9kHgyFXsdl3r4mtyIb4mF+c66OJrch4rUiFISukIIX4V+CGN2ea/lFIeXYljLyP3Ax8HDgshXlna9lvAzwsh9gASGAF++Up3uAF08TW5EF+Ti7OsuviavBZ/ib6Pj4/POsef7PTx8fFZ5/iG3MfHx2ed4xtyHx8fn3WOb8h9fHx81jm+Iffx8fFZ5/iG3MfHx2ed4xtyHx8fn3XO/w98qYn2E9pdpwAAAABJRU5ErkJggg==\n" }, "metadata": { "needs_background": "light" } } ] }, { "cell_type": "markdown", "metadata": { "id": "6V9p1no0zIFk" }, "source": [ "### S3: Sub-sampling the data\n", "- Reduce training and testing sample sizes by **randomly selecting** %10 of the initial samples\n", "\n", "Q3.1: What is the distribution of each label in the initial train data (i.e. percentage of each label): ___\n", "\n", "Q3.2: What is the distribution of each label in the reduced train data: ___" ] }, { "cell_type": "code", "source": [ "## Randomly sample data\n", "def sample_data(X, Y, p):\n", " ## Shuffle array indices\n", " num_sample = X.shape[0]\n", " ind_shuf = np.random.permutation(num_sample)\n", "\n", " ## Select p percent of the shuffled indices\n", " num_sel = int(num_sample / 100 * p )\n", " ind_sel = ind_shuf[0:num_sel]\n", " \n", " ## Select data\n", " X_out = X[ind_sel, :]\n", " Y_out = Y[ind_sel]\n", "\n", " return X_out, Y_out\n", "\n", "X_tr_sel1, Y_tr_sel1 = sample_data(X_tr, Y_tr, 1)\n", "X_te_sel1, Y_te_sel1 = sample_data(X_te, Y_te, 1)" ], "metadata": { "id": "MFCK2uoo55rP" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "## Find number of samples for each label\n", "_, c1 = np.unique(Y_tr, return_counts=True)\n", "_, c2 = np.unique(Y_tr_sel1, return_counts=True)\n", "\n", "## Find percentage of samples for each label\n", "p1 = (100*c1 / Y_tr.shape[0]).reshape(1,-1)\n", "p2 = (100*c2 / Y_tr_sel1.shape[0]).reshape(1,-1)\n", "\n", "print(p1)\n", "print(p2)\n", "\n", "## or\n", "p12 = np.concatenate((p1, p2), axis=0)\n", "df = pd.DataFrame(data = p12, columns = labels, index = ['X_tr','X_tr_sel1'])\n", "\n", "df.plot.bar()\n", "plt.show()" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 370 }, "id": "t-fww7GJ8LDg", "outputId": "cf1acfdc-1108-46b5-8f09-473371278edd" }, "execution_count": null, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "[[ 9.87166667 11.23666667 9.93 10.21833333 9.73666667 9.035\n", " 9.86333333 10.44166667 9.75166667 9.915 ]]\n", "[[ 9. 11.33333333 10.66666667 12. 9.66666667 9.83333333\n", " 9. 8.83333333 8. 11.66666667]]\n" ] }, { "output_type": "display_data", "data": { "text/plain": [ "
" ], "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXAAAAEcCAYAAADeL+8eAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAAV80lEQVR4nO3df3BV5Z3H8c/XBBpFKirBHwkYoK2EghtCLNpWRFwoSxldhCqorT/ATDt2C2s7Smd3Vuh0W8ZdVmllW9GKbnHBDmVHBisrBRxQS2mAUNMiqxWUIEKMP4pBDInf/SPRZV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5uVlFRUWaPHlywqmQNkyhAFlat26dBg8erAsuuCDpKEgZChzI0vLlyzV9+vSkYyCFKHAgC42NjVq1apW+8pWvJB0FKUSBA1l46qmnVF5ernPOOSfpKEghChzIwrJly5g+QWJYhYLgxb2MsKMaGhq0du1aPfDAA4lcH6DAgYh69eql+vr6pGMgxZhCAYBARS5wM+tvZhvM7I9m9gczmxVnMABA+7KZQmmS9G1332ZmvSVtNbO17v7HmLIBANoR+Q7c3fe7+7bWnw9J2impKK5gAID2xTIHbmYlkkZI+m0c7wcAyCzrAjez0yX9UtJsd//zcc5XmlmVmVXV1dVlezkAQKuslhGaWQ+1lPdj7r7yeGPcfbGkxZJUUVHh2VwPOJ516wfH+n5Xjv1Th8bde++9euihh2RmGj58uJYsWaKCgoJYswDtyWYVikn6maSd7v5v8UUCur59+/bpRz/6kaqqqlRTU6Pm5mYtX7486VhImWymUL4g6auSxppZdeufiTHlArq8pqYmvf/++2pqatLhw4d1/vnnJx0JKRN5CsXdn5VkMWYBglFUVKTvfOc7GjBggE499VSNHz9e48ePTzoWUoYnMYEI3n77bT3xxBPavXu3Xn/9dTU0NGjp0qVJx0LKUOBABL/+9a81cOBAFRYWqkePHrrmmmv0/PPPJx0LKUOBAxEMGDBAmzdv1uHDh+XuWrdunUpLS5OOhZRhN0IEr6PL/uI0atQoTZ06VeXl5crPz9eIESNUWVmZ8xxINwociGjevHmaN29e0jGQYkyhAECgKHAACBQFDgCBosABIFAUOAAEigIHgECxjBDBO3dDdazv98YVZR0at3DhQj344INyd912222aPXt2rDmATLgDByKoqanRgw8+qC1btmjHjh1avXq1Xn755aRjIWUocCCCnTt3atSoUTrttNOUn5+vyy+/XCtXHvc7TYBOQ4EDEQwbNkybNm1SfX29Dh8+rF/96lfau3dv0rGQMsyBAxGUlpbqrrvu0vjx49WrVy+VlZUpLy8v6VhIGe7AgYhmzJihrVu3auPGjTrzzDP1mc98JulISBnuwIGIDh48qH79+um1117TypUrtXnz5qQjIWUocASvo8v+4jZlyh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nevTTgS8DEz+4KkandvMLMbJZVLWujuryYcrdtiCiUAZtbHzB6QdIukCZJWSHrKzHhAAl3JTyQdNrO/UstviH9Syz4p6CQUeBi2SXpJUoW7P+3us9Uy3/19M1uWbDTgY03e8iv91ZIWufsitWz3gE7Co/RhGN12usTdqyV93sxuSygT0NYhM/uupBsljTazUyT1SDhTt8YcOIBYmNm5atl07Xfuvql1+esYd2capZNQ4ABygr164sccOIBcYa+emFHgAHKFX/djRoEDQKAocAC5wl49MaPAAWTNzPLMbEOGYezVEzMKHEDW3L1Z0odmdkY7Y2pyGCkVeJAHQFzek/SCma2V1PDRQXf/VnKRujcKHEBcVrb+ORYrTzoRBQ4gLn3cfeGxB1p30EQnYQ4cQFxuOs6xm3MdIk24AweQFTObrpY9UAaa2apjTvWW9FYyqdKBAgeQrecl7ZfUV9KCY44fkvT7RBKlBJtZAcgJNrOKH3PgAHKFzaxiRoEDyBV+3Y8ZBQ4AgaLAAWSl9Zt3TnTusmNf5iBOqlDgALL1jJndaWZ5Hx0ws3PMbKmke48Zx2ZWMaPAAWRrpKTBkqrNbGzr05dbJP1G0uc+GsRmVvFjGSGAWLQW972SXpd0ibvXJhyp2+MOHEBWzKyPmT0g6RZJEyStkPSUmY1NNln3xx04gKyY2SuS/l3Sfe7e1HqsrPXYq+4+Pcl83RkFDiArZlZ8oukSM7vN3R/Mdaa0oMABIFDMgQNAoChwAAgUBQ4AgaLAASBQFDgABOp/Aa0QZmS/0GAqAAAAAElFTkSuQmCC\n" }, "metadata": { "needs_background": "light" } } ] }, { "cell_type": "markdown", "metadata": { "id": "ZMS7ZMKwzIFk" }, "source": [ "### S4: Sub-sampling the data (again)\n", "- Reduce training and testing sample sizes by selecting **the first** %10 of the initial samples\n", "\n", "Q4.1: What is the distribution of each label in the initial train data (i.e. percentage of each label): ___\n", "\n", "Q4.2: What is the distribution of each label in the reduced train data: ___\n", "\n", "Q4.3: What are your comments/interpretation on comparison of the results for S3 and S4" ] }, { "cell_type": "markdown", "metadata": { "id": "rF80JiB_zIFk" }, "source": [ "#### ! For the rest of the HW, please discard sub-sampled data from S3 and use subsampled data from S4" ] }, { "cell_type": "code", "source": [ "## Randomly sample data\n", "def sample_data(X, Y, p, is_shuffle = False):\n", " ## Shuffle array indices\n", " num_sample = X.shape[0]\n", "\n", " if is_shuffle == True:\n", " ind_shuf = np.random.permutation(num_sample)\n", " else:\n", " ind_shuf = np.arange(0,num_sample)\n", "\n", " ## Select p percent of the shuffled indices\n", " num_sel = int(num_sample / 100 * p )\n", " ind_sel = ind_shuf[0:num_sel]\n", " \n", " ## Select data\n", " X_out = X[ind_sel, :]\n", " Y_out = Y[ind_sel]\n", "\n", " return X_out, Y_out\n", "\n", "X_tr_sel2, Y_tr_sel2 = sample_data(X_tr, Y_tr, 1)\n", "X_te_sel2, Y_te_sel2 = sample_data(X_te, Y_te, 1)" ], "metadata": { "id": "TOcO5elMBGLE" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "## Find number of samples for each label\n", "_, c1 = np.unique(Y_tr, return_counts=True)\n", "_, c2 = np.unique(Y_tr_sel2, return_counts=True)\n", "\n", "## Find percentage of samples for each label\n", "p1 = (100*c1 / Y_tr.shape[0]).reshape(1,-1)\n", "p2 = (100*c2 / Y_tr_sel2.shape[0]).reshape(1,-1)\n", "\n", "print(p1)\n", "print(p2)\n", "\n", "## or\n", "p12 = np.concatenate((p1, p2), axis=0)\n", "df = pd.DataFrame(data = p12, columns = labels, index = ['X_tr','X_tr_sel1'])\n", "\n", "df.plot.bar()\n", "plt.show()" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 370 }, "id": "VmJT8htKBijj", "outputId": "8f8ecb04-adb2-4602-a4aa-ea353c40fb4d" }, "execution_count": null, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "[[ 9.87166667 11.23666667 9.93 10.21833333 9.73666667 9.035\n", " 9.86333333 10.44166667 9.75166667 9.915 ]]\n", "[[ 9.66666667 13.16666667 10.66666667 9.83333333 9.83333333 8.5\n", " 9. 10.33333333 8.16666667 10.83333333]]\n" ] }, { "output_type": "display_data", "data": { "text/plain": [ "
" ], "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXAAAAEcCAYAAADeL+8eAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAAV8ElEQVR4nO3df3BV5Z3H8c+3CTSKCCpBMQEDtJVQcQPEoq1FxIUiZXQRqqC2/gAz7dgtrO0ond1ZobPTMu6ySivbila0xYXtWHZksLJSwAG1lIZfmhZZraBcRIixWgwgJH73DyKbppAbzj25J0/O+zXDwD3nzD0fZ/DDc5/7nCfm7gIAhOcTSQcAAERDgQNAoChwAAgUBQ4AgaLAASBQFDgABKownzfr1auXl5WV5fOWABC8TZs2vePuxS2P57XAy8rKVF1dnc9bAkDwzOyNEx1nCgUAAkWBA0CgKHAACBQFDgCBosABIFAUOAAEigIHgEBR4AAQqLw+yAMgD2b3yHL+/fzkQLtjBA4AgaLAASBQFDgABIoCB4BAUeAAECgKHAACRYEDQKAocAAIFAUOAIGiwAEgUBQ4AASKAgeAQFHgABAoChwAApW1wM3sUTPbb2Y1zY79q5m9YmYvmdl/m1nP9o0JAGipLSPwxySNa3FslaSL3P1iSf8r6bsx5wIAZJG1wN19naR3Wxx71t0bml5ukFTaDtkAAK2IYw78dknPxPA+AIBTkFOBm9k/SmqQ9EQr11SZWbWZVdfW1uZyOwBAM5EL3MxulTRB0k3u7ie7zt0Xunulu1cWFxdHvR0AoIVIP9TYzMZJulvSFe5+MN5IAIC2aMsywiWSfiPpQjPLmNk0SQ9K6i5plZltNbOftHNOAEALWUfg7j71BId/2g5ZAACngCcxASBQFDgABIoCB4BAUeAAECgKHAACRYEDQKAocAAIVKQnMVNvdo82XPN+++cAkGqMwAEgUBQ4AASKAgeAQFHgABAoCh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/kPSA+7e0HSsounYG+4+Ncl8nRkFDiAnZlZ6sukSM7vD3R/Od6a0oMABIFDMgQNAoChwAAgUBQ4AgaLAASBQFDgABOr/ADHRWN27kNw0AAAAAElFTkSuQmCC\n" }, "metadata": { "needs_background": "light" } } ] }, { "cell_type": "markdown", "metadata": { "id": "-CKsJFe3zIFl" }, "source": [ "### S5: Exploring the dataset\n", "- Select all **train** images in category \"3\". Create and display a single pixel-wise \"average image\" for this category.\n", "- Create and display a single pixel-wise \"standard deviation image\" for this category?\n", "- Repeat the items above for category \"3\" images in the **test** set. Compare the average and standard deviation images.\n", "- Repeat the items above for a different category you select.\n", "\n", "Q5.1: Plot the 2D mean and std images for category 3 in training and testing sets: ___\n", "\n", "Q5.2: Plot the 2D mean and std images for the category you selected in training and testing sets: ___\n", "\n", "Q5.3: Comment on differences between the mean and std images from training and testing datasets? ___" ] }, { "cell_type": "code", "source": [ "## Select images\n", "X = X_tr_sel2\n", "Y = Y_tr_sel2\n", "indAll = np.where(Y == 7)[0]\n", "imgAll = X[indAll, :, :]\n", "print('Num sel: ' + str(indAll.shape))\n", "print('Num img mat: ' + str(imgAll.shape))" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "crbHYaCnBuP4", "outputId": "1bd06eea-f136-4289-b003-464bb5b84382" }, "execution_count": null, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "Num sel: (62,)\n", "Num img mat: (62, 28, 28)\n" ] } ] }, { "cell_type": "code", "source": [ "## Calculate avg img\n", "img_mean = np.mean(imgAll, axis = 0)\n", "img_mean.shape" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "KfVBn77mCTPm", "outputId": "cdf597e0-af56-4862-bdd9-f8f3e57d87b8" }, "execution_count": null, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ "(28, 28)" ] }, "metadata": {}, "execution_count": 209 } ] }, { "cell_type": "code", "source": [ "## Show mean img\n", "plt.imshow(img_mean)\n", "plt.show()" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 265 }, "id": "OTcv9rBZCvLD", "outputId": "54ec0e0f-48bc-405d-aa44-fe8df1454a96" }, "execution_count": null, "outputs": [ { "output_type": "display_data", "data": { "text/plain": [ "
" ], "image/png": "iVBORw0KGgoAAAANSUhEUgAAAPsAAAD4CAYAAAAq5pAIAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAASJUlEQVR4nO3dbWzd5XkG8Os6fsd2iE2ISUyWpFUYzcoKzMpWgRgTWkX5Av2CGk0Vk9BSTUVqpX4YYh/KRzStVJW2VUoHajoxuk4tgmloJY06saoaImEpCaQ0KU1w0iROYhz8Er+eex/8Bxnwcz/OefE5yX39pMj2efw/587JuXJe7v/zPDQziMjVr9ToAkRkdSjsIkEo7CJBKOwiQSjsIkG0ruaNtbPDOtG9mjcpEso0JjFrM1xurKqwk7wXwLcBtAD4ZzN7wvv9TnTjj3lPNTcpIo5XbF9yrOKX8SRbAPwjgM8D2A5gJ8ntlV6fiNRXNe/ZdwA4ZmZvm9ksgB8AuL82ZYlIrVUT9kEAw0t+Pllc9iEkd5HcT3L/HGaquDkRqUbdP403s91mNmRmQ23oqPfNiUhCNWE/BWDTkp9vLC4TkSZUTdhfBbCN5FaS7QC+COCF2pQlIrVWcevNzOZJPgLgJ1hsvT1tZm/UrDIRqamq+uxm9iKAF2tUi4jUkU6XFQlCYRcJQmEXCUJhFwlCYRcJQmEXCUJhFwlCYRcJQmEXCUJhFwlCYRcJQmEXCUJhFwlCYRcJQmEXCUJhFwlCYRcJQmEXCUJhFwlCYRcJQmEXCUJhFwlCYRcJQmEXCUJhFwlCYRcJQmEXCUJhFwlCYRcJoqpdXGWFSi3uMNuq+2ewufmKj2WJuV/wx3PHLywkh2y+8rrl8lX1KCN5HMA4gAUA82Y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kCIVdJAiFXSQIhV0kCIVdJAiFXSSI/wevEZZuNw4GawAAAABJRU5ErkJggg==\n" }, "metadata": { "needs_background": "light" } } ] }, { "cell_type": "markdown", "metadata": { "id": "-I1-bxGZzIFl" }, "source": [ "### S6: Image distances\n", "- In the training set, find the image in category 3 that is most dissimilar to the mean image of category 3. Show it as a 2D image\n", "- In the training set, find the image in category 3 that is most similar to mean image of category 3. Show it as a 2D image\n", "- In the training set, find the image in category 9 that is most similar to mean image of category 3. Show it as a 2D image\n", "\n", "**Hint:** You can use the \"euclidean distance\" as your similarity metric. Given that an image i is represented with a flattened feature vector v_i , and the second image j with v_m, the distance between these two images can be calculated using the vector norm of their differences ( | v_i - v_j | ) \n", "\n", "Q6.1: What is the index of most dissimilar image in category 3: ___\n", "\n", "Q6.2: Plot the most dissimilar category 3 image in 2D: ___\n", "\n", "Q6.3: Plot the most similar category 3 image in 2D: ___" ] }, { "cell_type": "code", "source": [ "## Find pixelwise \"distance\" of each image to the mean image\n", "vec_mean = img_mean.flatten() \n", "arr_d = np.zeros(indAll.shape[0])\n", "for i, ind_sel in enumerate(indAll):\n", " img_sel = X[ind_sel, :, :].flatten()\n", "\n", " d_sel = np.sqrt(np.dot(vec_mean - img_sel, vec_mean - img_sel))\n", " #d_sel = np.linalg.norm(img_sel - vec_mean)\n", " #d_sel = np.sqrt(np.square(img_sel - vec_mean).sum())\n", "\n", " arr_d[i] = d_sel" ], "metadata": { "id": "1q3AwdDOC82X" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "ind_similar = indAll[arr_d.argmin()]\n", "ind_dissimilar = indAll[arr_d.argmax()]" ], "metadata": { "id": "Rhc6Ejx5D5iw" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "## Show similar / dissimilar images\n", "fig, ax = plt.subplots(nrows = 1, ncols = 3)\n", "ax[0].imshow(img_mean)\n", "ax[1].imshow(X[ind_similar,:,:])\n", "ax[2].imshow(X[ind_dissimilar,:,:])\n", "plt.show()" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 149 }, "id": "6inqNhb-EIkt", "outputId": "4248a336-3cdd-4ada-dbb1-929c6e56b7ea" }, "execution_count": null, "outputs": [ { "output_type": "display_data", "data": { "text/plain": [ "
" ], "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXAAAACECAYAAACJbXCEAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAAT60lEQVR4nO3de2xc1Z0H8O/vzvgV20nsPJzEpHEAm8Qtj7AhkIKALiBRqgptq7awLMt2KVEroKlUrYCyy2qlbctKW9AqLW3R8hKibAttgRa0ELJhSzclJBBeIQQHSOKEvJzEwe/HzNk/Mr3n/G4y47E9rzP+fqQo5865c+/x/MbHd35z7jlijAEREfknKHYDiIhoYtiBExF5ih04EZGn2IETEXmKHTgRkafYgRMReWpSHbiIXCki20Vkh4jcnqtGUXExruWLsS0vMtFx4CISA/A+gCsA7AGwCcC1xph3c9c8KjTGtXwxtuUnPonnrgCwwxjzIQCIyH8BuBpA2jdDpVSZatRO4pSUC4Pow7AZkjTVjKunxogrMM7YMq6lowdHu4wxc6KPT6YDbwbQ6WzvAXB+pidUoxbny2WTOCXlwkazLlM14+qpMeIKjDO2jGvpeNE8uetkj0+mA8+KiKwCsAoAqjEt36ejAmFcyxPj6pfJfIm5F8BCZ/uU1GOKMeZ+Y8xyY8zyClRN4nRUIIxr+RoztoyrXybTgW8C0Coii0WkEsA1AJ7JTbOoiBjX8sXYlpkJp1CMMaMicguA5wHEADxojNmas5ZRUTCu5YuxLT+TyoEbY54D8FyO2kIlgnEtX4xteeGdmEREnmIHTkTkKXbgRESeYgdOROQpduBERJ5iB05E5Cl24EREnmIHTkTkKXbgRESeYgdOROQpduBERJ7K+3zgRRXE1KZUpP9xzcho2joJxN2InCOy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0VkdbHakguMq2pL2cSWcVVtKcm4FqwDF5EYgJ8A+DyAdgDXikh7oc6f8jCAKyOP3Q5gnTGmFcC61Ha+jQL4rjGmHcAFAG5OvRbFaMukMK4nKIvYMq4nKM24GmMK8g/ASgDPO9t3ALijUOd3ztsC4B1nezuA+anyfADbi9CmpwFcUQptYVwZW8bVn7gWMoXSDKDT2d6TeqzYmowxf57ScD+ApkKeXERaACwDsLHYbZkgxjUNz2PLuKZRSnHll5gOc/zPaMGG5YhIHYBfA/iOMeaTYralnBXjtWRs849xLWwHvhfAQmf7lNRjxXZAROYDQOr/g4U4qYhU4Pgb4TFjzG+K2ZZJYlwjyiS2jGtEKca1kB34JgCtIrJYRCoBXAPgmQKeP51nANyQKt+A47mtvBIRAfAAgG3GmHuK2ZYcYFwdZRRbxtVRsnEtcOL/KgDvA/gAwJ1F+OLhcQD7AIzgeE7vRgCzcPzb4w4ALwJoLEA7LsLxj1pvAXgj9e+qYrSFcWVsGVd/48o7MYmIPMUvMYmIPMUOnIjIU+zAiYg8xQ6ciMhT7MCJiDzFDpyIyFPswImIPMUOnIjIU/8P5jS2tB2qL/AAAAAASUVORK5CYII=\n" }, "metadata": { "needs_background": "light" } } ] }, { "cell_type": "markdown", "metadata": { "id": "4B63sTNnzIFm" }, "source": [ "### S7: Image distances, part 2\n", "- Repeat questions S5 and S6 after binarizing the images first\n", "\n", "Q7.1: What is the index of most dis-similar category 3 image: ___\n", "\n", "Q7.2: What is the index of most similar category 3 image: ___\n", "\n", "Q7.3: Did the answer change after binarization? How do you interprete this finding?: ___" ] }, { "cell_type": "code", "source": [ "## Select images\n", "X = X_tr_sel2\n", "Y = Y_tr_sel2\n", "\n", "## Binarize images\n", "X = (X>128).astype(int)\n", "\n", "indAll = np.where(Y == 7)[0]\n", "imgAll = X[indAll, :, :]\n", "print('Num sel: ' + str(indAll.shape))\n", "print('Num img mat: ' + str(imgAll.shape))\n", "\n", "## Calculate avg img\n", "img_mean = np.mean(imgAll, axis = 0)\n", "img_mean.shape\n", "\n", "## Find pixelwise \"distance\" of each image to the mean image\n", "vec_mean = img_mean.flatten() \n", "arr_d = np.zeros(indAll.shape[0])\n", "for i, ind_sel in enumerate(indAll):\n", " img_sel = X[ind_sel, :, :].flatten()\n", "\n", " d_sel = np.sqrt(np.dot(vec_mean - img_sel, vec_mean - img_sel))\n", " #d_sel = np.linalg.norm(img_sel - vec_mean)\n", " #d_sel = np.sqrt(np.square(img_sel - vec_mean).sum())\n", "\n", " arr_d[i] = d_sel\n", " \n", "ind_similar = indAll[arr_d.argmin()]\n", "ind_dissimilar = indAll[arr_d.argmax()]\n", "\n", "## Show similar / dissimilar images\n", "fig, ax = plt.subplots(nrows = 1, ncols = 3)\n", "ax[0].imshow(img_mean)\n", "ax[1].imshow(X[ind_similar,:,:])\n", "ax[2].imshow(X[ind_dissimilar,:,:])\n", "plt.show()" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 184 }, "id": "AEhkUFKrGdzJ", "outputId": "61dd7ab0-f176-4d7f-f011-dae62486f13a" }, "execution_count": null, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "Num sel: (62,)\n", "Num img mat: (62, 28, 28)\n" ] }, { "output_type": "display_data", "data": { "text/plain": [ "
" ], "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXAAAACECAYAAACJbXCEAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAAOjElEQVR4nO3d329cZ53H8c93xmM7juMmToLj/GraJk03XEBp2Ha3oGW3VFuQVr1bUQmUi0rhgpVA4oIA/wAXiDtugqiCEGK1okiNtEhViYAVqFSpRNNfaX6QbmhSx4njOrbjxL/m4SLTc85zkhmP7fGZ85x5vyTLz5lnZs5jf0fPnPnO88OccwIAhKfU7gYAAFaGDhwAAkUHDgCBogMHgEDRg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OSR8kji/Vbmu3Iefcx8sNXpE0lOXJzWyPpEclvdbutqwQca0j8NgS1zryFFe+xExwd95GMxuWY2b9kl6U9C3n3GSyLuu2FFk7/pfEdu0R12w78MuSdiWOd9Zua7dRMxuWpNrvq1mc1MwquvNC+IVz7tftbMsqEdeUgsSWuKbkMa5ZduAnJe0zswfMrFvSVyQdz/D89RyXdKhWPqQ7ua01ZWYm6aeSTjvnftTOtrQAcU0oUGyJa0Ju45px4v/Lks5K+quk77fhi4dfShqRNK87Ob3nJW3WnW+Pz0n6raTBDNrxOd35qPWmpDdqP19uR1uIK7ElruHGlZmYABAovsQEgEDRgQNAoOjAASBQdOAAECg6cAAIFB04AASKDhwAAkUHDgCB+jsKqVGKTejgOgAAAABJRU5ErkJggg==\n" }, "metadata": { "needs_background": "light" } } ] }, { "cell_type": "markdown", "metadata": { "id": "mNWILCmDzIFm" }, "source": [ "### S8: Binary classification between category 3 and 9 (split train data)\n", "- Select images from these two categories in the training dataset\n", "- Split them into two sets (Set1, Set2) with a %60 and %40 random split\n", "- Replace category labels as 0 (for 3) and 1 (for 9)\n", "- Use Set1 to train a linear SVM classifier with default parameters and predict the class labels for Set2 \n", "- Use Set2 to train a linear SVM classifier with default parameters and predict the class labels for Set1 \n", "\n", "Q8.1: What is the prediction accuracy using the model trained on Set1: ___\n", "\n", "Q8.2: What is the prediction accuracy using the model trained on Set2: ___" ] }, { "cell_type": "code", "source": [ "from sklearn.model_selection import train_test_split\n", "\n", "## Select data\n", "X = X_tr_sel2\n", "Y = Y_tr_sel2\n", "\n", "indSel = np.where((Y == 3) | (Y == 9))[0]\n", "X = X[indSel, :, :]\n", "Y = Y[indSel]\n", "\n", "## Replace labels\n", "Y[Y == 3] = 0\n", "Y[Y == 9] = 1\n", "\n", "## Flatten images\n", "X = X.reshape(X.shape[0], -1)\n", "\n", "## Create train test data\n", "X_train, X_test, y_train, y_test = train_test_split(X, Y, test_size=0.4, random_state=42)" ], "metadata": { "id": "9nVa2eMaHsYt" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "from sklearn import svm\n", "\n", "# Create the svm classifier\n", "clf = svm.SVC(kernel='linear') # Linear Kernel\n", "\n", "# Train the model\n", "clf.fit(X_train, y_train)\n", "\n", "# Predict the label\n", "y_pred = clf.predict(X_test)" ], "metadata": { "id": "bFKBS872Ipmc" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "from sklearn import metrics\n", "print('Accuracy: ', metrics.accuracy_score(y_test, y_pred))" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "pKJFZmRFKGzI", "outputId": "cb1db9f0-973d-45d8-da85-a16e15575305" }, "execution_count": null, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "Accuracy: 0.86\n" ] } ] }, { "cell_type": "code", "source": [ "# Train the model\n", "clf.fit(X_test, y_test)\n", "\n", "# Predict the label\n", "y_pred = clf.predict(X_train)\n", "\n", "print('Accuracy: ', metrics.accuracy_score(y_train, y_pred))" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "t3lEXRs8MkF4", "outputId": "10cb42f2-8677-4c3a-c4ff-edb4a4814413" }, "execution_count": null, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "Accuracy: 0.9459459459459459\n" ] } ] }, { "cell_type": "markdown", "metadata": { "id": "N_t7LEpezIFn" }, "source": [ "### S9: Binary classification between category 3 and 9 (train + test sets)\n", "- Select images from these two categories in the training and testing datasets\n", "- Replace category labels as 0 (for 3) and 1 (for 9)\n", "- Use training set to train a linear SVM classifier with default parameters and predict the class labels for the testing set\n", "- Use testing set to train a linear SVM classifier with default parameters and predict the class labels for the training set\n", "\n", "Q9.1: What is the prediction accuracy using the model trained on the training set: ___\n", "\n", "Q9.2: What is the prediction accuracy using the model trained on the testing set: ___" ] }, { "cell_type": "markdown", "metadata": { "id": "5cbcdf2_zIFn" }, "source": [ "### S10: k-NN Error Analysis\n", "- In training and testing datasets select the images in categories: 1, 3, 5, 7 or 9\n", "- Train k-NN classifiers using 4 to 40 nearest neighbors with a step size of 4\n", "- Calculate and plot overall testing accuracy for each experiment\n", "\n", "Q10.1: For k=4 what is the label that was predicted with lowest accuracy: ___\n", "\n", "Q10.2: For k=20 what is the label that was predicted with lowest accuracy: ___\n", "\n", "Q10.3: What is the label pair that was confused most often (i.e. class A is labeled as B, and vice versa): ___\n", "\n", "Q10.4: Visualize 5 mislabeled samples with their actual and predicted labels" ] }, { "cell_type": "code", "source": [ "from sklearn.model_selection import train_test_split\n", "\n", "## Select data\n", "X = X_tr_sel2\n", "Y = Y_tr_sel2\n", "\n", "indSel = np.where(np.isin(Y,[1, 3, 5, 7, 9]) == True)[0]\n", "X = X[indSel, :, :]\n", "Y = Y[indSel]\n", "\n", "## Flatten images\n", "X = X.reshape(X.shape[0], -1)\n", "\n", "## Create train test data\n", "X_train, X_test, y_train, y_test = train_test_split(X, Y, test_size=0.4, random_state=42)" ], "metadata": { "id": "2HlrAMwFM1ba" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "from sklearn.neighbors import KNeighborsClassifier\n", "from sklearn.metrics import classification_report, confusion_matrix, accuracy_score\n", "\n", "arr_k = np.arange(4, 40, 4)\n", "mat_pred = np.zeros([arr_k.shape[0], y_test.shape[0]]) ## Matrix to keep predictions from each experiment\n", "acc_pred = np.zeros([arr_k.shape[0], 1]) ## Array to keep accuracy from each experiment\n", "for i, k in enumerate(arr_k):\n", " classifier = KNeighborsClassifier(n_neighbors = k)\n", " classifier.fit(X_train, y_train)\n", " y_pred = classifier.predict(X_test)\n", " mat_pred [i, :] = y_pred\n", " acc_pred[i] = metrics.accuracy_score(y_test, y_pred)\n" ], "metadata": { "id": "jRCTprrENl08" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "print(acc_pred)" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "yee88Y33PtEe", "outputId": "383aae80-2e46-45fe-ea5e-d6b09a118161" }, "execution_count": null, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "[[0.79527559]\n", " [0.77952756]\n", " [0.73228346]\n", " [0.7480315 ]\n", " [0.71653543]\n", " [0.71653543]\n", " [0.70866142]\n", " [0.69291339]\n", " [0.68503937]]\n" ] } ] }, { "cell_type": "code", "source": [ "result = confusion_matrix(y_test, mat_pred[0])\n", "print(\"Confusion Matrix:\")\n", "print(result)" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "cEePL7yiQASf", "outputId": "3e09cd8e-2d92-461d-a8f5-2ddbf7e890fd" }, "execution_count": null, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "Confusion Matrix:\n", "[[30 0 0 1 1]\n", " [ 4 17 0 2 1]\n", " [ 1 5 15 0 0]\n", " [ 5 0 0 14 3]\n", " [ 0 0 0 3 25]]\n" ] } ] }, { "cell_type": "code", "source": [ "mat_pred_bin = mat_pred.copy()\n", "for i in np.arange(0, mat_pred.shape[0]):\n", " mat_pred_bin[i,:] = (mat_pred[i,:] == y_test).astype(int)\n", "mat_pred_sum = mat_pred_bin.sum(axis=0) " ], "metadata": { "id": "9igxjQEFQNok" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "indsel = mat_pred_sum.argmin()" ], "metadata": { "id": "7a0GEnRVQ_lj" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "print('Label / Pred : ' + str(y_test[indsel]) + ' ' + str(mat_pred[:, indsel]))" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "KTabHhbhRY9y", "outputId": "af249cfb-59a5-4086-a2ff-6a51842b8370" }, "execution_count": null, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "Label / Pred : 3 [7. 7. 7. 7. 7. 7. 7. 7. 7.]\n" ] } ] }, { "cell_type": "code", "source": [ "plt.imshow(X_test[indsel,:].reshape([28,28]))\n", "plt.show()" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 265 }, "id": "kM3U_OovR3AU", "outputId": "c363c353-c65b-4478-9bf7-d3716b427ea2" }, "execution_count": null, "outputs": [ { "output_type": "display_data", "data": { "text/plain": [ "
" ], "image/png": "iVBORw0KGgoAAAANSUhEUgAAAPsAAAD4CAYAAAAq5pAIAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAAN7ElEQVR4nO3df6zddX3H8deLctsOWhiXH6UpFdQxuzoHyF1xkU2Q6JDMgVlkNoYVJF6TgcImm4RlwqIxqHOETEdSESkGIUQg9I/G0TUk6GCVW1KgBVkRSmh3aZFOWwb253t/3G/NFe73c2/P+Z4f7fv5SE7OOd/3+Z7vOyd99fs938+5348jQgAOfYf1ugEA3UHYgSQIO5AEYQeSIOxAEod3c2PTPSNm6shubhJI5Vf6P+2KnZ6o1lbYbZ8v6WZJ0yTdGhE3ll4/U0fqLJ/XziYBFKyOVbW1lg/jbU+T9C1JH5G0UNJi2wtbfT8AndXOd/ZFkp6LiOcjYpekuyVd2ExbAJrWTtjnSXpp3PNN1bLfYHvY9ojtkd3a2cbmALSj42fjI2JpRAxFxNCAZnR6cwBqtBP2zZLmj3t+UrUMQB9qJ+yPSTrV9tttT5f0CUnLm2kLQNNaHnqLiD22r5T07xoberstItY31hmARrU1zh4RKyStaKgXAB3Ez2WBJAg7kARhB5Ig7EAShB1IgrADSRB2IAnCDiRB2IEkCDuQBGEHkiDsQBKEHUiCsANJEHYgCcIOJEHYgSQIO5AEYQeSIOxAEoQdSIKwA0kQdiAJwg4kQdiBJAg7kARhB5Ig7EAShB1IgrADSbQ1ZbPtjZJ2SNoraU9EDDXRFIDmtRX2yrkR8fMG3gdAB3EYDyTRbthD0oO219genugFtodtj9ge2a2dbW4OQKvaPYw/OyI22z5B0krbP42Ih8e/ICKWSloqSUd5MNrcHoAWtbVnj4jN1f1WSfdLWtREUwCa13LYbR9pe/b+x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zQ9krbG6r7CefY61FvN9jeXH12a21f0KPe5tt+yPbTttfbvqpa3tPPrtBXVz63rn9ntz1N0n9L+pCkTZIek7Q4Ip7uaiM1bG+UNBQRPf8Bhu0/kfSapDsi4verZV+TtC0ibqz+ozwmIr7QJ73dIOm1Xk/jXc1WNHf8NOOSLpJ0qXr42RX6ulhd+Nx6sWdfJOm5iHg+InZJulvShT3oo+9FxMOStr1p8YWSllWPl2nsH0vX1fTWFyJiNCIerx7vkLR/mvGefnaFvrqiF2GfJ+mlcc83qb/mew9JD9peY3u4181MYE5EjFaPX5Y0p5fNTGDSaby76U3TjPfNZ9fK9Oft4gTdW50dEe+V9BFJV1SHq30pxr6D9dPY6ZSm8e6WCaYZ/7VefnatTn/erl6EfbOk+eOen1Qt6wsRsbm63yrpfvXfVNRb9s+gW91v7XE/v9ZP03hPNM24+uCz6+X0570I+2OSTrX9dtvTJX1C0vIe9PEWto+sTpzI9pGSPqz+m4p6uaQl1eMlkh7oYS+/oV+m8a6bZlw9/ux6Pv15RHT9JukCjZ2R/5mkf+hFDzV9vUPSE9Vtfa97k3SXxg7rdmvs3Mblko6VtErSBkn/IWmwj3r7nqSnJD2psWDN7VFvZ2vsEP1JSWur2wW9/uwKfXXlc+PnskASnKADkiDsQBKEHUiCsANJEHYgCcIOJEHYgST+H4CETNxOR/wmAAAAAElFTkSuQmCC\n" }, "metadata": { "needs_background": "light" } } ] }, { "cell_type": "markdown", "metadata": { "id": "_BMC-ZGLzIFo" }, "source": [ "### S11: Feature extraction\n", "\n", "- We describe each image by using a reduced set of features (compared to n=784 initial features for each pixel value) as follows:\n", " \n", " 1. Binarize the image (background=0, foreground=1)\n", "\n", " 2. For each image row i, find n_i, the sum of 1's in the row (28 features) \n", " \n", " 3. For each image column j, find n_j, the sum of 1's in the column (28 features)\n", " \n", " 4. Concatenate these features into a feature vector of 56 features\n", " \n", "Repeat classification experiments in S9 using this reduced feature set.\n", "\n", "Q11.1: What is the prediction accuracy using the model trained using the train data: ___\n", "\n", "Q11.2: What is the prediction accuracy using the model trained using the test data: ___\n" ] }, { "cell_type": "code", "source": [ "X = X_tr_sel2\n", "X = (X > 0).astype(int)\n", "\n", "X.shape" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "10j5HnL-SdKp", "outputId": "257bd86b-b952-4542-bac7-f663149c22aa" }, "execution_count": null, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ "(600, 28, 28)" ] }, "metadata": {}, "execution_count": 269 } ] }, { "cell_type": "code", "source": [ "X0 = X[0,:,:]\n", "plt.imshow(X0)\n", "plt.show()" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 265 }, "id": "WK-fWUrgSzRE", "outputId": "85199abb-f608-4dd2-b104-77d4b1ff0953" }, "execution_count": null, "outputs": [ { "output_type": "display_data", "data": { "text/plain": [ "
" ], "image/png": "iVBORw0KGgoAAAANSUhEUgAAAPsAAAD4CAYAAAAq5pAIAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAALRUlEQVR4nO3dX+hf9X3H8edrLkaatpDMLWQ2W7vijQyWjh/poDIcss56E3sjzUWxUJZeVGihFxN3US9lrC29GIV0hqajsxRaZy5kbRYK0hsxSqZRt+kkUrOYtORCO1iM9r2L30n5mfz+5fs/eT8f8OV7vuec3++8c8gr58/7e/JJVSHp+vdb8y5A0mwYdqkJwy41YdilJgy71MRvz3JjN2Zr3cS2WW5SauX/+F/ergtZbdlYYU9yF/BN4AbgH6vq4fXWv4ltfDx3jrNJSet4qo6tuWzk0/gkNwD/AHwKuA3Yn+S2UX+fpOka55p9L/BKVb1aVW8D3wf2TaYsSZM2TthvAX6+4vPrw7z3SHIgyfEkxy9yYYzNSRrH1O/GV9XBqlqqqqUtbJ325iStYZywnwZ2r/j8oWGepAU0TtifBm5N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OEJNuAT7J4Q1EfAe4bpu8DHp9jLe+xKMN4rzXMOHPed3Mf/ryqZv4C7mb5jvx/A387jxrWqOuPgH8fXi/MuzbgUZZP6y6yfG/j88DvAMeAl4F/A3YsUG3/BDwPPMdysHbNqbbbWT5Ffw44Mbzunve+W6eumew3vy4rNeENOqkJwy41YdilJgy71IRhl5ow7FIThl1q4v8Bp6GTx2VG0ogAAAAASUVORK5CYII=\n" }, "metadata": { "needs_background": "light" } } ] }, { "cell_type": "code", "source": [ "f1 = X0.sum(axis=0)\n", "print(f1)" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "BzyP4JV2TAsd", "outputId": "bc1d6036-0c01-46e9-c810-9eea4a9187eb" }, "execution_count": null, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "[ 0 0 0 0 2 2 3 5 8 9 10 12 14 15 15 13 13 14 10 8 5 3 3 2\n", " 0 0 0 0]\n" ] } ] }, { "cell_type": "code", "source": [ "f2 = X0.sum(axis=1)\n", "print(f2)" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "U-3jc9-0TWEU", "outputId": "f10f3311-7ba0-49cb-81e8-c19b4eb99eda" }, "execution_count": null, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "[ 0 0 0 0 0 12 16 16 11 9 5 4 4 6 6 6 5 4 7 8 9 10 10 10\n", " 8 0 0 0]\n" ] } ] }, { "cell_type": "code", "source": [ "f12 = np.concatenate((f1,f2))\n", "f12.shape" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "vKR-QyudTcEe", "outputId": "24187687-6034-4e5b-9db8-38431a06ef54" }, "execution_count": null, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ "(56,)" ] }, "metadata": {}, "execution_count": 279 } ] }, { "cell_type": "markdown", "metadata": { "id": "pX1b_DEIzIFo" }, "source": [ "### Bonus:\n", "\n", "- This time we describe each 28 x 28 image by using a different feature set (n = 28 x 4 features). This feature set encodes \"index of the first non-zero pixel in image columns or rows\" from each direction (from left, right, top, bottom)\n", "\n", "Example for a 6 x 6 image:\n", "\n", "Img:\n", " 0 0 0 0 0 0\n", " 0 0 0 1 0 0\n", " 0 0 0 1 0 0\n", " 0 0 0 1 0 0\n", " 0 0 0 1 0 0\n", " 0 0 0 0 0 0\n", " \n", "Extracted features:\n", " 0 3 3 3 3 0 0 2 2 2 2 0 0 0 0 1 0 0 0 0 0 1 0 0 (left, right, top, bottom)\n", " \n", "Repeat classification experiments in S9 using this reduced feature set.\n", "\n", "Q11.1: What is the prediction accuracy using the model trained using the train data: ___\n", "\n", "Q11.2: What is the prediction accuracy using the model trained using the test data: ___\n" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.12" }, "colab": { "provenance": [], "collapsed_sections": [ "Y3JkhtmuzIFh", "N_t7LEpezIFn", "_BMC-ZGLzIFo", "pX1b_DEIzIFo" ] } }, "nbformat": 4, "nbformat_minor": 0 }