Skip to content

Commit d0e23c0

Browse files
committed
Added Machine Learning for PCA specifically for PCA blog
1 parent 80ef752 commit d0e23c0

File tree

3 files changed

+1209
-30
lines changed

3 files changed

+1209
-30
lines changed

Sklearn/PCA/PCA_MNIST_Logistic_Regression.ipynb

Lines changed: 47 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
},
5959
{
6060
"cell_type": "code",
61-
"execution_count": 6,
61+
"execution_count": 1,
6262
"metadata": {
6363
"collapsed": true
6464
},
@@ -94,7 +94,7 @@
9494
},
9595
{
9696
"cell_type": "code",
97-
"execution_count": 7,
97+
"execution_count": 2,
9898
"metadata": {
9999
"collapsed": true
100100
},
@@ -114,7 +114,7 @@
114114
},
115115
{
116116
"cell_type": "code",
117-
"execution_count": 8,
117+
"execution_count": 3,
118118
"metadata": {
119119
"collapsed": true
120120
},
@@ -158,9 +158,22 @@
158158
},
159159
{
160160
"cell_type": "code",
161-
"execution_count": 9,
161+
"execution_count": 4,
162162
"metadata": {},
163-
"outputs": [],
163+
"outputs": [
164+
{
165+
"ename": "IOError",
166+
"evalue": "[Errno 2] No such file or directory: 'data/train-images-idx3-ubyte'",
167+
"output_type": "error",
168+
"traceback": [
169+
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
170+
"\u001b[0;31mIOError\u001b[0m Traceback (most recent call last)",
171+
"\u001b[0;32m<ipython-input-4-3016031659c9>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 1\u001b[0m train_img, train_lbl = loadmnist('data/train-images-idx3-ubyte'\n\u001b[0;32m----> 2\u001b[0;31m , 'data/train-labels-idx1-ubyte')\n\u001b[0m\u001b[1;32m 3\u001b[0m test_img, test_lbl = loadmnist('data/t10k-images-idx3-ubyte'\n\u001b[1;32m 4\u001b[0m , 'data/t10k-labels-idx1-ubyte')\n",
172+
"\u001b[0;32m<ipython-input-3-d872c2c49a73>\u001b[0m in \u001b[0;36mloadmnist\u001b[0;34m(imagefile, labelfile)\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0;31m# Open the images with gzip in read binary mode\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 4\u001b[0;31m \u001b[0mimages\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mopen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mimagefile\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'rb'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 5\u001b[0m \u001b[0mlabels\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mopen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mlabelfile\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'rb'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 6\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
173+
"\u001b[0;31mIOError\u001b[0m: [Errno 2] No such file or directory: 'data/train-images-idx3-ubyte'"
174+
]
175+
}
176+
],
164177
"source": [
165178
"train_img, train_lbl = loadmnist('data/train-images-idx3-ubyte'\n",
166179
" , 'data/train-labels-idx1-ubyte')\n",
@@ -170,31 +183,27 @@
170183
},
171184
{
172185
"cell_type": "code",
173-
"execution_count": 10,
186+
"execution_count": null,
174187
"metadata": {},
175-
"outputs": [
176-
{
177-
"name": "stdout",
178-
"output_type": "stream",
179-
"text": [
180-
"(60000, 784)\n"
181-
]
182-
}
183-
],
188+
"outputs": [],
184189
"source": [
185190
"print(train_img.shape)"
186191
]
187192
},
188193
{
189194
"cell_type": "code",
190-
"execution_count": 11,
195+
"execution_count": 5,
191196
"metadata": {},
192197
"outputs": [
193198
{
194-
"name": "stdout",
195-
"output_type": "stream",
196-
"text": [
197-
"(60000,)\n"
199+
"ename": "NameError",
200+
"evalue": "name 'train_lbl' is not defined",
201+
"output_type": "error",
202+
"traceback": [
203+
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
204+
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
205+
"\u001b[0;32m<ipython-input-5-b14c321fab44>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0;32mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtrain_lbl\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mshape\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
206+
"\u001b[0;31mNameError\u001b[0m: name 'train_lbl' is not defined"
198207
]
199208
}
200209
],
@@ -204,14 +213,18 @@
204213
},
205214
{
206215
"cell_type": "code",
207-
"execution_count": 12,
216+
"execution_count": 6,
208217
"metadata": {},
209218
"outputs": [
210219
{
211-
"name": "stdout",
212-
"output_type": "stream",
213-
"text": [
214-
"(10000, 784)\n"
220+
"ename": "NameError",
221+
"evalue": "name 'test_img' is not defined",
222+
"output_type": "error",
223+
"traceback": [
224+
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
225+
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
226+
"\u001b[0;32m<ipython-input-6-dfe1f893088e>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0;32mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtest_img\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mshape\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
227+
"\u001b[0;31mNameError\u001b[0m: name 'test_img' is not defined"
215228
]
216229
}
217230
],
@@ -221,14 +234,18 @@
221234
},
222235
{
223236
"cell_type": "code",
224-
"execution_count": 13,
237+
"execution_count": 7,
225238
"metadata": {},
226239
"outputs": [
227240
{
228-
"name": "stdout",
229-
"output_type": "stream",
230-
"text": [
231-
"(10000,)\n"
241+
"ename": "NameError",
242+
"evalue": "name 'test_lbl' is not defined",
243+
"output_type": "error",
244+
"traceback": [
245+
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
246+
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
247+
"\u001b[0;32m<ipython-input-7-9666b7c1db35>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0;32mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtest_lbl\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mshape\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
248+
"\u001b[0;31mNameError\u001b[0m: name 'test_lbl' is not defined"
232249
]
233250
}
234251
],

0 commit comments

Comments
 (0)