Errata

Hands-On Machine Learning with Scikit-Learn and TensorFlow

Errata for Hands-On Machine Learning with Scikit-Learn and TensorFlow

Submit your own errata for this product.

The errata list is a list of errors and their corrections that were found after the product was released.

The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.

Color Key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted by Date submitted
Printed Page P85
Code at the bottom of the page 85

This comment relates to Second Edition Second Release:

On page 85, the mnist Bunch is constructed with:
mnist = fetch_openml('mnist_784', version=1)

On page 86, the data and target sets are generated with:
X, y = mnist["data"], mnist["target"]

With Scikit v1.2.0, X and y are not ndarrays (like implied by the text), but Pandas DataFrame and Series. This makes the image generation code on page 86 fail. Or one retypes X and y to ndarrays or one changes the mnist construction to:
mnist = fetch_openml('mnist_784', version=1, as_frame=False).

With the latter, X and y are generated as ndarrays.

Roland Leners  Dec 31, 2022 
Printed Page Page 499
Equation 15-2

In this equation, the bias vector is shown as `b`which has size n-neurons. However, this calculation is being made for a mini-batch. The other terms in the summation will have a dimension of m x n-neurons, similar to output Yt. Also, the previous equation implies that b is a column vector. So shouldn't `b` be changed to matrix B of same dimension where each row = b-transposed?

Syamprasad  Mar 18, 2024 
Printed Page 55
Table

It is not clear how Rand % error and Strat % error columns are calculated?
For example, in a 1st row Overall - Random = 0.039826 - 0.040213 = 0.000387, not 0.973236 % as shown in the table

Dmitry Otblesk  Jul 13, 2020 
PDF Page 74
codes

in the test it shows the following code with printed output, while the output needs .toarray() to be shown:

cat_encoder.transform(df_test) should be cat_encoder.transform(df_test).toarray()


cat_encoder.transform(df_test_unknown) should be cat_encoder.transform(df_test_unknown).toarray()

Sadegh Karimi  Feb 26, 2023 
PDF Page 75
code

On the following line, it throw out an error
>> df_output = pd.DataFrame(cat_encoder.transform(df_test_unknown),
... columns=cat_encoder.get_feature_names_out(),
... index=df_test_unknown.index)


changing to the following, problem is fixed.
>> df_output = pd.DataFrame(cat_encoder.transform(df_test_unknown).toarray(),
... columns=cat_encoder.get_feature_names_out(),
... index=df_test_unknown.index)

Sadegh Karimi  Feb 26, 2023 
Printed Page 80
1st paragraph

The question refers to the 2nd edition.
The confidence interval computation in the example uses Student's t-distribution. I understand that this implies that the squared errors are distributed normally (see e.g. Wikipedia page on Student's t-distribution. Is this so, and why?
I would rather expect that the mean_squared_error has a normal distribution (across different test data sets) as by the central limit theorem, but not the squared errors themselves.

Roland Leners  Dec 30, 2022 
Printed Page 93
Second paragraph

In the second paragraph, it says "...and setting max_features to 8." when it should say "...and setting max_features to 6." as it is evident from the code just above.

Dominik Dekleva  Mar 11, 2023 
Printed Page 109
1st paragraph

"(theta)T.x is the dot product of (theta)T and x"

I might be nitpicking, or just plain wrong but:

(theta)T and x have different dimensions: (1 x n) vs (n x1); so this dot product is not defined then.

Should we rather write:  thetaT . x is the matrix product of thetaT and x 
(or equivalently: thetaT . x is the dot product of theta and x )?

Jean-Baptiste Mestelan  Nov 12, 2019 
Printed Page 178
Figure 6-2

Hi, it might very well be that I didn't quite follow but here it goes: Shouldn't the purple and green colours in Figure 6-2 be reversed? The decision tree is meant to classifiy any iris with less than petal width of 1.75 as versicolour. If that is the case, the colour on the chart should be green and not purple and vice versa for virginica so that it matches the colours on the previous page (Decision tree image).

Aksel Bedikyan  Dec 06, 2019 
PDF Page 236
The penultimate line of the second paragraph

A left bracket is missing in front of the '='

yongspeng  Sep 02, 2020 
PDF Page 248
Figure 9-10

In Figure 9-10 the axis of the plots in the upper row seems not to be aligned with the axis of the lower row. I assume the same data as in Figure 9-9 is used: k=4 (upper right) seems to be worse than k=3 (upper left).

Henry Webel  Jul 06, 2020 
PDF Page 320
Fourth sentence code

'x' is not defined, it should be 'a' Considering the context. So the right way is to
change 'x.initializer.run(session=sess)' to 'a.initializer.run(session=sess)'

yongspeng  Sep 02, 2020 
Mobi Page 383
Location 8322 in Kindle version

Ragged tensors are described as:
"Represent lists of lists of tensors, where every tensor has the same shape and data type."

However, this isn't right. They are just lists of tensors, and the key feature of ragged tensors is that the tensor elements can be of variable shape. However, all tensor elements must have the same dtype and rank.

The TensorFlow documentation states:
"Your data comes in many shapes; your tensors should too. Ragged tensors are the TensorFlow equivalent of nested variable-length lists. They make it easy to store and process data with non-uniform shapes [...]"

Reference: https://www.tensorflow.org/guide/ragged_tensor

Christopher Whidden  Feb 16, 2022 
Printed, Mobi Page 513
Equation C-4

I believe the value of the Lagrangian is inverse to the one shown.

Actual:
Lagrangian(w, b, alpha) = 1/2 SuperSum - sum(alpha)

Expected:
Lagrangian(w, b, alpha) = -1/2 SuperSum + sum(alpha)

It probably doesn't matter much, since all we're gonna do with this is (1) calculate the partial derivatives with regards to alpha, and (2) put these equal to zero (not shown), so the sign plays no role.

Sam Ferencik  Jun 18, 2019 
Printed Page 794-795
Both pages are missing

Pages 794 and 795 are missing. Pages 634 and 635 were printed inplace of 794-795.

Mike Mattinson  Aug 18, 2022