Skip to content

Commit b9f526e

Browse files
committed
reverting
1 parent 142b724 commit b9f526e

File tree

1 file changed

+7
-52
lines changed

1 file changed

+7
-52
lines changed

4. K-means clustering and unsupervised learning.ipynb

+7-52
Original file line numberDiff line numberDiff line change
@@ -20,29 +20,11 @@
2020
},
2121
{
2222
"cell_type": "code",
23-
<<<<<<< HEAD
24-
"execution_count": 10,
25-
=======
2623
"execution_count": 27,
27-
>>>>>>> origin/master
2824
"metadata": {
29-
"collapsed": false
25+
"collapsed": true
3026
},
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": [],
4628
"source": [
4729
"# useful packages\n",
4830
"import os\n",
@@ -136,11 +118,7 @@
136118
},
137119
{
138120
"cell_type": "code",
139-
<<<<<<< HEAD
140-
"execution_count": 3,
141-
=======
142121
"execution_count": 28,
143-
>>>>>>> origin/master
144122
"metadata": {
145123
"collapsed": false
146124
},
@@ -149,7 +127,7 @@
149127
"name": "stdout",
150128
"output_type": "stream",
151129
"text": [
152-
"['columbia.jpg', 'leo_bb.png', 'mario.png']\n"
130+
"['leo_bb.png', 'mario.png']\n"
153131
]
154132
}
155133
],
@@ -179,8 +157,6 @@
179157
"text": [
180158
"Using image 0: path datasets/kmeans/imgs/leo_bb.png\n"
181159
]
182-
<<<<<<< HEAD
183-
=======
184160
},
185161
{
186162
"data": {
@@ -191,11 +167,10 @@
191167
},
192168
"metadata": {},
193169
"output_type": "display_data"
194-
>>>>>>> origin/master
195170
}
196171
],
197172
"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",
199174
"print('Using image 0: path {}'.format(img_path))\n",
200175
"\n",
201176
"img = mpimg.imread(img_path)\n",
@@ -217,11 +192,7 @@
217192
},
218193
{
219194
"cell_type": "code",
220-
<<<<<<< HEAD
221-
"execution_count": 6,
222-
=======
223195
"execution_count": 30,
224-
>>>>>>> origin/master
225196
"metadata": {
226197
"collapsed": false
227198
},
@@ -253,27 +224,11 @@
253224
},
254225
{
255226
"cell_type": "code",
256-
<<<<<<< HEAD
257-
"execution_count": 8,
258-
=======
259227
"execution_count": 31,
260-
>>>>>>> origin/master
261228
"metadata": {
262-
"collapsed": false
229+
"collapsed": true
263230
},
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": [],
277232
"source": [
278233
"img_reshaped = np.reshape(img, (num_pixels, num_channels))\n",
279234
"img_sample = shuffle(img_reshaped, random_state=0)"
@@ -484,7 +439,7 @@
484439
"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",
485440
"\n",
486441
"#### 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**. "
488443
]
489444
},
490445
{

0 commit comments

Comments
 (0)