Skip to content

Commit 931a202

Browse files
committed
print number of features in ch04
1 parent 24b74d2 commit 931a202

File tree

3 files changed

+168
-149
lines changed

3 files changed

+168
-149
lines changed

Diff for: code/ch04/ch04.ipynb

+145-145
Large diffs are not rendered by default.

Diff for: code/ch04/ch04.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -613,8 +613,8 @@ def _calc_score(self, X_train, y_train, X_test, y_test, indices):
613613

614614
sfm = SelectFromModel(forest, threshold=0.1, prefit=True)
615615
X_selected = sfm.transform(X_train)
616-
print('Number of samples that meet this criterion:',
617-
X_selected.shape[0])
616+
print('Number of features that meet this threshold criterion:',
617+
X_selected.shape[1])
618618

619619

620620
# Now, let's print the 3 features that met the threshold criterion for feature selection that we set earlier (note that this code snippet does not appear in the actual book but was added to this notebook later for illustrative purposes):

Diff for: docs/errata/README.md

+21-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ To turn those annoyances into something positive, I will donate $5 to [UNICEF US
77
Also below, I added a small leaderboard to keep track of the errata submissions and errors you found. Please let me know if you don't want to be explicitely mentioned in that list!
88

99

10-
- Amount for the next donation: 65$
10+
- Amount for the next donation: 70$
1111
- Amount donated: 0$
1212

1313

@@ -18,11 +18,11 @@ Contributor list:
1818

1919
7. gabramson ($15)
2020
1. Gogy ($10)
21+
6. Oliver Tomic ($10)
2122
2. Christian Geier ($5)
2223
3. Pieter Algra / Carlos Zada ($5)
2324
4. @gabramson ($5)
2425
5. Elias Strehle ($5)
25-
6. Oliver Tomic ($5)
2626
7. Krishna Mohan ($5)
2727
8. Jesse Blocher ($5)
2828

@@ -81,6 +81,25 @@ instead of
8181

8282
It seems that I did it correctly in the notebook. Also, the list of feature importances and the plot seem to be correct in the book. However, somehow the [indices] array index went missing in the print version.
8383

84+
pg. 138
85+
86+
Instead of writing
87+
88+
```
89+
>>> print('Number of samples that meet this criterion:',
90+
... X_selected.shape[0])
91+
Number of samples that meet this criterion: 124
92+
```
93+
94+
it would make more sense to write
95+
96+
```
97+
>>> print('Number of features that meet this threshold criterion:',
98+
... X_selected.shape[1])
99+
Number of features that meet this threshold criterion: 5
100+
```
101+
102+
84103

85104
pg. 155
86105

0 commit comments

Comments
 (0)