numerics-2022/Task 1/kmeans.ipynb

214 lines
118 KiB
Plaintext
Raw Normal View History

2022-09-24 11:25:54 +03:00
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np \n",
"import matplotlib.pyplot as plt "
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"def scatter_plot(data, col=None):\n",
" from mpl_toolkits.mplot3d import Axes3D \n",
" %matplotlib inline\n",
" fig = plt.figure()\n",
" ax = fig.add_subplot(111, projection='3d')\n",
" ax.scatter(data[:,0], data[:,1], data[:,2], s = 0.5, color=col)\n",
" plt.show()"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"N = 1000\n",
"K = 3\n",
"d = 3\n",
"L = 10"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"# Generate some data\n",
"np.random.seed(42)\n",
"mu_true = np.random.uniform(-L, L, size = (K, d))\n",
"data = np.random.normal(mu_true, size = (N, K, d))\n",
"data = np.vstack(data)\n",
"np.random.shuffle(data)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAV0AAADnCAYAAAC9roUQAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAAIABJREFUeJzsvXmQZHd17/m5S+5L7fu+dPWm3qrVUgstgEEChJGEkNmRzcMDGPRGtl+E8bP9HLbHAbYHv/CMsTGDMXh4YQQjg4WFhBBoA6mlVndLvarUVZW1r7nvy8177/yRuqmsqqyqzKrsVreUnwhFlzKrfrne7z33/M75HkHXdapUqVKlyuVBfKOfQJUqVaq8laiKbpUqVapcRqqiW6VKlSqXkaroVqlSpcplp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27v6ETcop7oSMcTYbrfjdrtpa2sDVkbGiUSi5DRFIZdCdLPZbMlrrj62wuHwmpP1lUZVdCtEOQ0NpYhuKBTC4/Gg6zr9/f3U1dVdiqcNvD7rbGpqClVVuf766yuWQ73UFQeCIGCxWLBYLNTX1+dv13WddDqdF+Ni0Z2iKMRisZIqAtw2mUaHmUK51XWdUDJLrU2+KuqUV+d0CyPjQgwxNvLtwWCQeDyef+8KK1HKEchSyWazW75SCYfD1NbWVvT5VJqq6G6TrTY0FBNdXdcJBAJ4PB5kWWZgYOCSnrULa3pbWlo4cuQIp06dquim1RtV5mXYQFqt1hUbMoXRnZFCWV0ra2ziFforXNtdy7XdKw/mcV+Cf31+ls/e1E27+8qvuii1ZKxQjFe/d4Unsrm5OaLRKCdPnlwTGTscji2
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"if d == 3:\n",
" scatter_plot(data, None)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"mu = data[np.random.choice(range(data.shape[0]), K, replace=False)]\n",
"c = np.random.randint(low=0, high=K-1, size=data.shape[0])"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"def dist_i(x, mu):\n",
" # x: N datapoints, mu: N cluster centers\n",
" # returns: D_{i}, squared distances from x[i] to mu[i]\n",
" dist = np.zeros(x.shape[0])\n",
" for i in range(x.shape[0]):\n",
" dist[i] = np.sum((x[i] - mu[i])**2)\n",
" return dist\n",
"def dist_ij(x, mu):\n",
" # x: N datapoints, mu: K cluster centers\n",
" # returns: D_{ij}, squared distances from x[i] to mu[j]\n",
" dist = np.zeros((x.shape[0], mu.shape[0]))\n",
" for i in range(x.shape[0]):\n",
" for j in range(mu.shape[0]):\n",
" dist[i, j] += np.sum((x[i] - mu[j])**2)\n",
" return dist"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"ss_list = []\n",
"for n in range(10):\n",
" c = np.argmin(dist_ij(data, mu), axis = 1) \n",
" ss = np.mean(dist_i(data, mu[c]))\n",
" ss_list.append(ss) \n",
" for i in range(K):\n",
" cluster_members = data[c == i]\n",
" cluster_members = cluster_members.mean(axis = 0)\n",
" mu[i] = cluster_members"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[<matplotlib.lines.Line2D at 0x1fa6bf68ba8>]"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAD8CAYAAAB5Pm/hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAAFwZJREFUeJzt3X9w3HWdx/HnO7+atEmzaZOWNrulrVYKtM2GSRkUYeZAzoIe8Id3FD2tiFRHTlG5UdCb8c4ZZ/T0FG7k8CpFqjAohyiMIsog6M2plZSmtNBCS/mR0JRuf6c/0zTv+2O/gbSkSZrdzXf3+309Zjq7+93v7vc93zavfvP5fr7vr7k7IiISXWVhFyAiIoWloBcRiTgFvYhIxCnoRUQiTkEvIhJxCnoRkYhT0IuIRJyCXkQk4hT0IiIRVxF2AQCNjY0+e/bssMsQESkpa9as2enuTSOtVxRBP3v2bNrb28MuQ0SkpJjZq6NZT0M3IiIRp6AXEYk4Bb2ISMQp6EVEIk5BLyIScQp6EZGIU9CLiETciEFvZneb2Q4z2zBo2bfNbJOZPWtmvzCzxKD3bjWzLWb2gpm9v1CFA7ywvYdv/Pp5DvX2FXIzIiIlbTRH9PcAS05a9jiwwN0XAS8CtwKY2TnAUuDc4DP/ZWbleav2JF17DvHD/32Z9V37CrUJEZGSN2LQu/sfgd0nLfuduw8cRv8FSAbPrwJ+6u5H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+uqwyxERGTNdGXsKb3Wy1PCNiJQ2Bf0pnDNjMpXlRkenZt6ISGlT0J9CdWU558yYrCN6ESl5CvphtASdLI/369aCIlK6FPTDSKc
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"plt.plot(ss_list)"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
"colors = np.array([plt.cm.cool(i/(K-1)) for i in range(K)])"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAV0AAADnCAYAAAC9roUQAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAAIABJREFUeJzsvXlwXOd5r/l8Z+kN3VgIgACxkMTCfRM3ibKWeJNjK2PZkp3EiR1nYmdsx9Et5WYmN566tzIpZ8ap1Dh3nFvOOJnc3DiVXEd2ZN84sSXHSiLZiURx0UKKligBaOz7jt7P9s0fjdNqNBpAb6QIqZ8qFslu4PTp031+5z3v976/V0gpqVKlSpUqNwflzd6BKlWqVHk7URXdKlWqVLmJVEW3SpUqVW4iVdGtUqVKlZtIVXSrVKlS5SaibfF8tbShSpUqVYpHbPRENdKtUqVKlZtIVXSrVKlS5SZSFd0qVapUuYlURbdKlSpVbiJV0a1SpUqVm0hVdKtUqVLlJlIV3SpVqlS5iVRFt0qVKlVuIlXRrVKlSpWbSFV0q1SpUuUmUhXdKlWqVLmJVEW3SpUqVW4iVdGtUqVKlZvIVi5jVapsiJQSx3FIpVJYloWmaSiKgqqqKIqCoigIsaHZUpUqb0vEFoMpq9aOVdYhpcS2bSzLWvNv9zlXaG3bJhqN0tTUhKqqVTGu8nZiwy94NdKtUjC5YiuEQFE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ZpV5uTaQPp9vzYJMdnTnplBya2XdRbxsf4WOTpuOzrWf2fy8wvOXde44ZxAK3fqiW2jJWLYY5x677AvZ+Pg4kUiE559/fl1kXFNTU7I
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"if d == 3:\n",
" scatter_plot(data, colors[c])"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}