|
20 | 20 | },
|
21 | 21 | {
|
22 | 22 | "cell_type": "code",
|
23 |
| -<<<<<<< HEAD |
24 |
| - "execution_count": 10, |
25 |
| -======= |
26 | 23 | "execution_count": 27,
|
27 |
| ->>>>>>> origin/master |
28 | 24 | "metadata": {
|
29 |
| - "collapsed": false |
| 25 | + "collapsed": true |
30 | 26 | },
|
31 |
| - "outputs": [ |
32 |
| - { |
33 |
| - "ename": "ImportError", |
34 |
| - "evalue": "No module named 'scipy'", |
35 |
| - "output_type": "error", |
36 |
| - "traceback": [ |
37 |
| - "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", |
38 |
| - "\u001b[1;31mImportError\u001b[0m Traceback (most recent call last)", |
39 |
| - "\u001b[1;32m<ipython-input-10-93ad81cdfd38>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[0;32m 4\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mmatplotlib\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mpyplot\u001b[0m \u001b[1;32mas\u001b[0m \u001b[0mplt\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 5\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mmatplotlib\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mimage\u001b[0m \u001b[1;32mas\u001b[0m \u001b[0mmpimg\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 6\u001b[1;33m \u001b[1;32mfrom\u001b[0m \u001b[0msklearn\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mcluster\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mKMeans\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 7\u001b[0m \u001b[1;32mfrom\u001b[0m \u001b[0msklearn\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mutils\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mshuffle\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 8\u001b[0m \u001b[1;32mfrom\u001b[0m \u001b[0mtime\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mtime\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", |
40 |
| - "\u001b[1;32mc:\\users\\piyali\\python3\\lib\\site-packages\\sklearn\\__init__.py\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[0;32m 55\u001b[0m \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 56\u001b[0m \u001b[1;32mfrom\u001b[0m \u001b[1;33m.\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0m__check_build\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 57\u001b[1;33m \u001b[1;32mfrom\u001b[0m \u001b[1;33m.\u001b[0m\u001b[0mbase\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mclone\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 58\u001b[0m \u001b[0m__check_build\u001b[0m \u001b[1;31m# avoid flakes unused variable error\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 59\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n", |
41 |
| - "\u001b[1;32mc:\\users\\piyali\\python3\\lib\\site-packages\\sklearn\\base.py\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[0;32m 7\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 8\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mnumpy\u001b[0m \u001b[1;32mas\u001b[0m \u001b[0mnp\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 9\u001b[1;33m \u001b[1;32mfrom\u001b[0m \u001b[0mscipy\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0msparse\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 10\u001b[0m \u001b[1;32mfrom\u001b[0m \u001b[1;33m.\u001b[0m\u001b[0mexternals\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0msix\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 11\u001b[0m \u001b[1;32mfrom\u001b[0m \u001b[1;33m.\u001b[0m\u001b[0mutils\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mfixes\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0msignature\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", |
42 |
| - "\u001b[1;31mImportError\u001b[0m: No module named 'scipy'" |
43 |
| - ] |
44 |
| - } |
45 |
| - ], |
| 27 | + "outputs": [], |
46 | 28 | "source": [
|
47 | 29 | "# useful packages\n",
|
48 | 30 | "import os\n",
|
|
136 | 118 | },
|
137 | 119 | {
|
138 | 120 | "cell_type": "code",
|
139 |
| -<<<<<<< HEAD |
140 |
| - "execution_count": 3, |
141 |
| -======= |
142 | 121 | "execution_count": 28,
|
143 |
| ->>>>>>> origin/master |
144 | 122 | "metadata": {
|
145 | 123 | "collapsed": false
|
146 | 124 | },
|
|
149 | 127 | "name": "stdout",
|
150 | 128 | "output_type": "stream",
|
151 | 129 | "text": [
|
152 |
| - "['columbia.jpg', 'leo_bb.png', 'mario.png']\n" |
| 130 | + "['leo_bb.png', 'mario.png']\n" |
153 | 131 | ]
|
154 | 132 | }
|
155 | 133 | ],
|
|
179 | 157 | "text": [
|
180 | 158 | "Using image 0: path datasets/kmeans/imgs/leo_bb.png\n"
|
181 | 159 | ]
|
182 |
| -<<<<<<< HEAD |
183 |
| -======= |
184 | 160 | },
|
185 | 161 | {
|
186 | 162 | "data": {
|
|
191 | 167 | },
|
192 | 168 | "metadata": {},
|
193 | 169 | "output_type": "display_data"
|
194 |
| ->>>>>>> origin/master |
195 | 170 | }
|
196 | 171 | ],
|
197 | 172 | "source": [
|
198 |
| - "img_path = os.path.join('datasets/kmeans/imgs/', imgs[1])\n", |
| 173 | + "img_path = os.path.join('datasets/kmeans/imgs/', imgs[0])\n", |
199 | 174 | "print('Using image 0: path {}'.format(img_path))\n",
|
200 | 175 | "\n",
|
201 | 176 | "img = mpimg.imread(img_path)\n",
|
|
217 | 192 | },
|
218 | 193 | {
|
219 | 194 | "cell_type": "code",
|
220 |
| -<<<<<<< HEAD |
221 |
| - "execution_count": 6, |
222 |
| -======= |
223 | 195 | "execution_count": 30,
|
224 |
| ->>>>>>> origin/master |
225 | 196 | "metadata": {
|
226 | 197 | "collapsed": false
|
227 | 198 | },
|
|
253 | 224 | },
|
254 | 225 | {
|
255 | 226 | "cell_type": "code",
|
256 |
| -<<<<<<< HEAD |
257 |
| - "execution_count": 8, |
258 |
| -======= |
259 | 227 | "execution_count": 31,
|
260 |
| ->>>>>>> origin/master |
261 | 228 | "metadata": {
|
262 |
| - "collapsed": false |
| 229 | + "collapsed": true |
263 | 230 | },
|
264 |
| - "outputs": [ |
265 |
| - { |
266 |
| - "ename": "NameError", |
267 |
| - "evalue": "name 'shuffle' is not defined", |
268 |
| - "output_type": "error", |
269 |
| - "traceback": [ |
270 |
| - "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", |
271 |
| - "\u001b[1;31mNameError\u001b[0m Traceback (most recent call last)", |
272 |
| - "\u001b[1;32m<ipython-input-8-6ac900e80476>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[0mimg_reshaped\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mreshape\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mimg\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m(\u001b[0m\u001b[0mnum_pixels\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mnum_channels\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 2\u001b[1;33m \u001b[0mimg_sample\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mshuffle\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mimg_reshaped\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mrandom_state\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m", |
273 |
| - "\u001b[1;31mNameError\u001b[0m: name 'shuffle' is not defined" |
274 |
| - ] |
275 |
| - } |
276 |
| - ], |
| 231 | + "outputs": [], |
277 | 232 | "source": [
|
278 | 233 | "img_reshaped = np.reshape(img, (num_pixels, num_channels))\n",
|
279 | 234 | "img_sample = shuffle(img_reshaped, random_state=0)"
|
|
484 | 439 | "We can also use **penalization approaches**, where we use different criterion such as AIC (Akaike Information Criterion) or BIC (Bayesian Information Criterion) to keep the value of k under control. \n",
|
485 | 440 | "\n",
|
486 | 441 | "#### I. (d) What if we can’t cluster the data?\n",
|
487 |
| - "In the tutorial above, we try to classify each of our points into one of K clusters. But sometimes, maybe you are clustering based on a feature that is not so exclusive. For example, people usually enjoy more than one genre of music, or food. It would be pretty difficult to form a clustering system such that a person can be a fan of ice-cream or a fan of tiramisu but not both. Hence when we need to \"share\" members of clusters, we are doing something called **probabilistic clustering** or **fuzzy clustering**. " |
| 442 | + "* In the tutorial above, we try to classify each of our points into one of K clusters. But sometimes, maybe you are clustering based on a feature that is not so exclusive. For example, people usually enjoy more than one genre of music, or food. It would be pretty difficult to form a clustering system such that a person can be a fan of ice-cream or a fan of tiramisu but not both. Hence when we need to \"share\" members of clusters, we are doing something called **probabilistic clustering** or **fuzzy clustering**. " |
488 | 443 | ]
|
489 | 444 | },
|
490 | 445 | {
|
|
0 commit comments