Skip to content

Commit 4052010

Browse files
committed
small cosmetic changes
1 parent e0e87da commit 4052010

27 files changed

Lines changed: 143 additions & 113 deletions

ch01/ch01.ipynb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
{
44
"cell_type": "markdown",
55
"metadata": {
6-
"jp-MarkdownHeadingCollapsed": true,
76
"tags": []
87
},
98
"source": [

ch02/ch02.ipynb

Lines changed: 37 additions & 37 deletions
Large diffs are not rendered by default.

ch02/ch02.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989

9090

9191

92-
class Perceptron():
92+
class Perceptron:
9393
"""Perceptron classifier.
9494
9595
Parameters
@@ -304,7 +304,7 @@ def plot_decision_regions(X, y, classifier, resolution=0.02):
304304

305305

306306

307-
class AdalineGD():
307+
class AdalineGD:
308308
"""ADAptive LInear NEuron classifier.
309309
310310
Parameters
@@ -320,6 +320,8 @@ class AdalineGD():
320320
321321
Attributes
322322
-----------
323+
w_ : 1d-array
324+
Weights after fitting.
323325
b_ : Scalar
324326
Bias unit after fitting.
325327
losses_ : list
@@ -454,7 +456,7 @@ def predict(self, X):
454456

455457

456458

457-
class AdalineSGD():
459+
class AdalineSGD:
458460
"""ADAptive LInear NEuron classifier.
459461
460462
Parameters
@@ -574,14 +576,14 @@ def predict(self, X):
574576
plt.legend(loc='upper left')
575577

576578
plt.tight_layout()
577-
#plt.savefig('figures/02_15_1.png', dpi=300)
579+
plt.savefig('figures/02_15_1.png', dpi=300)
578580
plt.show()
579581

580582
plt.plot(range(1, len(ada_sgd.losses_) + 1), ada_sgd.losses_, marker='o')
581583
plt.xlabel('Epochs')
582584
plt.ylabel('Average loss')
583585

584-
#plt.savefig('figures/02_15_2.png', dpi=300)
586+
plt.savefig('figures/02_15_2.png', dpi=300)
585587
plt.show()
586588

587589

ch02/figures/02_15_1.png

0 Bytes
Loading

ch02/figures/02_15_2.png

0 Bytes
Loading

ch05/ch05.ipynb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
},
1111
{
1212
"cell_type": "markdown",
13-
"metadata": {},
13+
"metadata": {
14+
"tags": []
15+
},
1416
"source": [
1517
"## Package version checks"
1618
]
@@ -50,7 +52,7 @@
5052
"text": [
5153
"[OK] Your Python version is 3.9.6 | packaged by conda-forge | (default, Jul 11 2021, 03:35:11) \n",
5254
"[Clang 11.1.0 ]\n",
53-
"[OK] numpy 1.21.4\n",
55+
"[OK] numpy 1.21.5\n",
5456
"[OK] matplotlib 3.5.1\n",
5557
"[OK] sklearn 1.0.1\n",
5658
"[OK] pandas 1.3.5\n"
@@ -1793,7 +1795,7 @@
17931795
"text": [
17941796
"[NbConvertApp] WARNING | Config option `kernel_spec_manager_class` not recognized by `NbConvertApp`.\n",
17951797
"[NbConvertApp] Converting notebook ch05.ipynb to script\n",
1796-
"[NbConvertApp] Writing 20297 bytes to ch05.py\n"
1798+
"[NbConvertApp] Writing 20329 bytes to ch05.py\n"
17971799
]
17981800
}
17991801
],

ch05/ch05.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@
209209
plt.xlabel('Principal component index')
210210
plt.legend(loc='best')
211211
plt.tight_layout()
212-
# plt.savefig('images/05_02.png', dpi=300)
212+
# plt.savefig('figures/05_02.png', dpi=300)
213213
plt.show()
214214

215215

@@ -264,7 +264,7 @@
264264
plt.ylabel('PC 2')
265265
plt.legend(loc='lower left')
266266
plt.tight_layout()
267-
# plt.savefig('images/05_03.png', dpi=300)
267+
# plt.savefig('figures/05_03.png', dpi=300)
268268
plt.show()
269269

270270

@@ -360,7 +360,7 @@ def plot_decision_regions(X, y, classifier, test_idx=None, resolution=0.02):
360360
plt.ylabel('PC 2')
361361
plt.legend(loc='lower left')
362362
plt.tight_layout()
363-
# plt.savefig('images/05_04.png', dpi=300)
363+
# plt.savefig('figures/05_04.png', dpi=300)
364364
plt.show()
365365

366366

@@ -371,7 +371,7 @@ def plot_decision_regions(X, y, classifier, test_idx=None, resolution=0.02):
371371
plt.ylabel('PC 2')
372372
plt.legend(loc='lower left')
373373
plt.tight_layout()
374-
# plt.savefig('images/05_05.png', dpi=300)
374+
# plt.savefig('figures/05_05.png', dpi=300)
375375
plt.show()
376376

377377

@@ -397,7 +397,7 @@ def plot_decision_regions(X, y, classifier, test_idx=None, resolution=0.02):
397397

398398
plt.ylim([-1, 1])
399399
plt.tight_layout()
400-
plt.savefig('images/05_05_02.png', dpi=300)
400+
plt.savefig('figures/05_05_02.png', dpi=300)
401401
plt.show()
402402

403403

@@ -419,7 +419,7 @@ def plot_decision_regions(X, y, classifier, test_idx=None, resolution=0.02):
419419

420420
plt.ylim([-1, 1])
421421
plt.tight_layout()
422-
plt.savefig('images/05_05_03.png', dpi=300)
422+
plt.savefig('figures/05_05_03.png', dpi=300)
423423
plt.show()
424424

425425

@@ -555,7 +555,7 @@ def plot_decision_regions(X, y, classifier, test_idx=None, resolution=0.02):
555555
plt.ylim([-0.1, 1.1])
556556
plt.legend(loc='best')
557557
plt.tight_layout()
558-
#plt.savefig('images/05_07.png', dpi=300)
558+
#plt.savefig('figures/05_07.png', dpi=300)
559559
plt.show()
560560

561561

@@ -584,7 +584,7 @@ def plot_decision_regions(X, y, classifier, test_idx=None, resolution=0.02):
584584
plt.ylabel('LD 2')
585585
plt.legend(loc='lower right')
586586
plt.tight_layout()
587-
plt.savefig('images/05_08.png', dpi=300)
587+
plt.savefig('figures/05_08.png', dpi=300)
588588
plt.show()
589589

590590

@@ -609,7 +609,7 @@ def plot_decision_regions(X, y, classifier, test_idx=None, resolution=0.02):
609609
plt.ylabel('LD 2')
610610
plt.legend(loc='lower left')
611611
plt.tight_layout()
612-
# plt.savefig('images/05_09.png', dpi=300)
612+
# plt.savefig('figures/05_09.png', dpi=300)
613613
plt.show()
614614

615615

@@ -622,7 +622,7 @@ def plot_decision_regions(X, y, classifier, test_idx=None, resolution=0.02):
622622
plt.ylabel('LD 2')
623623
plt.legend(loc='lower left')
624624
plt.tight_layout()
625-
# plt.savefig('images/05_10.png', dpi=300)
625+
# plt.savefig('figures/05_10.png', dpi=300)
626626
plt.show()
627627

628628

@@ -645,7 +645,7 @@ def plot_decision_regions(X, y, classifier, test_idx=None, resolution=0.02):
645645
for i in range(4):
646646
ax[i].imshow(digits.images[i], cmap='Greys')
647647

648-
# plt.savefig('images/05_12.png', dpi=300)
648+
# plt.savefig('figures/05_12.png', dpi=300)
649649
plt.show()
650650

651651

@@ -691,7 +691,7 @@ def plot_projection(x, colors):
691691
PathEffects.Normal()])
692692

693693
plot_projection(X_digits_tsne, y_digits)
694-
# plt.savefig('images/05_13.png', dpi=300)
694+
# plt.savefig('figures/05_13.png', dpi=300)
695695
plt.show()
696696

697697

ch06/ch06.ipynb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
"cells": [
33
{
44
"cell_type": "markdown",
5-
"metadata": {},
5+
"metadata": {
6+
"tags": []
7+
},
68
"source": [
79
"# Machine Learning with PyTorch and Scikit-Learn \n",
810
"# -- Code Examples"
@@ -42,7 +44,9 @@
4244
{
4345
"cell_type": "code",
4446
"execution_count": 2,
45-
"metadata": {},
47+
"metadata": {
48+
"tags": []
49+
},
4650
"outputs": [
4751
{
4852
"name": "stdout",

ch07/ch07.ipynb

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@
4545
"cell_type": "code",
4646
"execution_count": 2,
4747
"metadata": {
48+
"collapsed": true,
49+
"jupyter": {
50+
"outputs_hidden": true
51+
},
4852
"tags": []
4953
},
5054
"outputs": [
@@ -516,7 +520,7 @@
516520
" def get_params(self, deep=True):\n",
517521
" \"\"\" Get classifier parameter names for GridSearch\"\"\"\n",
518522
" if not deep:\n",
519-
" return super(MajorityVoteClassifier, self).get_params(deep=False)\n",
523+
" return super().get_params(deep=False)\n",
520524
" else:\n",
521525
" out = self.named_classifiers.copy()\n",
522526
" for name, step in self.named_classifiers.items():\n",
@@ -1877,7 +1881,7 @@
18771881
},
18781882
{
18791883
"cell_type": "code",
1880-
"execution_count": 53,
1884+
"execution_count": 1,
18811885
"metadata": {},
18821886
"outputs": [
18831887
{
@@ -1886,13 +1890,20 @@
18861890
"text": [
18871891
"[NbConvertApp] WARNING | Config option `kernel_spec_manager_class` not recognized by `NbConvertApp`.\n",
18881892
"[NbConvertApp] Converting notebook ch07.ipynb to script\n",
1889-
"[NbConvertApp] Writing 24238 bytes to ch07.py\n"
1893+
"[NbConvertApp] Writing 24252 bytes to ch07.py\n"
18901894
]
18911895
}
18921896
],
18931897
"source": [
18941898
"! python ../.convert_notebook_to_script.py --input ch07.ipynb --output ch07.py"
18951899
]
1900+
},
1901+
{
1902+
"cell_type": "code",
1903+
"execution_count": null,
1904+
"metadata": {},
1905+
"outputs": [],
1906+
"source": []
18961907
}
18971908
],
18981909
"metadata": {

ch07/ch07.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@
5454
'scipy': '1.7.0',
5555
'matplotlib': '3.4.3',
5656
'sklearn': '1.0',
57-
'pandas': '1.3.2'
57+
'pandas': '1.3.2',
58+
'xgboost': '1.5.0',
5859
}
5960
check_packages(d)
6061

@@ -142,7 +143,7 @@ def ensemble_error(n_classifier, error):
142143
plt.ylabel('Base/Ensemble error')
143144
plt.legend(loc='upper left')
144145
plt.grid(alpha=0.5)
145-
#plt.savefig('images/07_03.png', dpi=300)
146+
#plt.savefig('figures/07_03.png', dpi=300)
146147
plt.show()
147148

148149

@@ -297,7 +298,7 @@ def predict_proba(self, X):
297298
def get_params(self, deep=True):
298299
""" Get classifier parameter names for GridSearch"""
299300
if not deep:
300-
return super(MajorityVoteClassifier, self).get_params(deep=False)
301+
return super().get_params(deep=False)
301302
else:
302303
out = self.named_classifiers.copy()
303304
for name, step in self.named_classifiers.items():
@@ -414,7 +415,7 @@ def get_params(self, deep=True):
414415
plt.ylabel('True positive rate (TPR)')
415416

416417

417-
#plt.savefig('images/07_04', dpi=300)
418+
#plt.savefig('figures/07_04', dpi=300)
418419
plt.show()
419420

420421

@@ -474,7 +475,7 @@ def get_params(self, deep=True):
474475
ha='center', va='center',
475476
fontsize=12, rotation=90)
476477

477-
#plt.savefig('images/07_05', dpi=300)
478+
#plt.savefig('figures/07_05', dpi=300)
478479
plt.show()
479480

480481

@@ -683,7 +684,7 @@ def get_params(self, deep=True):
683684
fontsize=12,
684685
transform=axarr[1].transAxes)
685686

686-
#plt.savefig('images/07_08.png', dpi=300, bbox_inches='tight')
687+
#plt.savefig('figures/07_08.png', dpi=300, bbox_inches='tight')
687688
plt.show()
688689

689690

@@ -816,7 +817,7 @@ def get_params(self, deep=True):
816817
fontsize=12,
817818
transform=axarr[1].transAxes)
818819

819-
#plt.savefig('images/07_11.png', dpi=300, bbox_inches='tight')
820+
#plt.savefig('figures/07_11.png', dpi=300, bbox_inches='tight')
820821
plt.show()
821822

822823

0 commit comments

Comments
 (0)