Skip to content

Commit e4bbb8f

Browse files
committed
FIG Denser sampling. Tight layout
1 parent 5644a07 commit e4bbb8f

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

‎ch02/figure4_5_sklearn.py‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
from load import load_dataset
1313
import numpy as np
1414
from sklearn.neighbors import KNeighborsClassifier
15-
from knn import fit_model, predict
1615

1716
feature_names = [
1817
'area',
@@ -40,8 +39,8 @@ def plot_decision(features, labels):
4039
'''
4140
y0, y1 = features[:, 2].min() * .9, features[:, 2].max() * 1.1
4241
x0, x1 = features[:, 0].min() * .9, features[:, 0].max() * 1.1
43-
X = np.linspace(x0, x1, 100)
44-
Y = np.linspace(y0, y1, 100)
42+
X = np.linspace(x0, x1, 1000)
43+
Y = np.linspace(y0, y1, 1000)
4544
X, Y = np.meshgrid(X, Y)
4645

4746
model = KNeighborsClassifier(1)
@@ -72,9 +71,11 @@ def plot_decision(features, labels):
7271
labels = np.array([names.index(ell) for ell in labels])
7372

7473
fig,ax = plot_decision(features, labels)
74+
fig.tight_layout()
7575
fig.savefig('figure4sklearn.png')
7676

7777
features -= features.mean(0)
7878
features /= features.std(0)
7979
fig,ax = plot_decision(features, labels)
80+
fig.tight_layout()
8081
fig.savefig('figure5sklearn.png')

0 commit comments

Comments
 (0)