Susan Harkins (264) [Avatar] Offline
#1
Please post errors in the published version of Algorithms of the Intelligent Web, Second Edition. We'll publish a comprehensive list for everyone's convenience.

Thank you!
Susan Harkins
Errata Editor
301284 (4) [Avatar] Offline
#2
Hi,
in Listing 2.1. Interrogating the Iris dataset in scikit-learn (interactive shell)

When trying to reproduce (with full up-to-date ipython) the code, the
np.array(zip(iris.data,iris.target))[0:10]
line fails with this message:

IndexError: too many indices for array


The problem is that np.array creates a 1 dimension array with the zipped object instead of iterating through it to create the desired array.

In order to get the desired behaviour, I had to create a list from the zip object first

np.array(list(zip(iris.data,iris.target)))[0:10]


This is my first dip into numpy, so it might be something due to an update in the library since the book was released

301284 (4) [Avatar] Offline
#3
301284 wrote:Hi,
in Listing 2.1. Interrogating the Iris dataset in scikit-learn (interactive shell)

When trying to reproduce (with full up-to-date ipython) the code, the
np.array(zip(iris.data,iris.target))[0:10]
line fails with this message:

IndexError: too many indices for array


The problem is that in python 3 the zip function returns an iterator, not a list as in python2

np.array creates a 1 dimension array with the zipped object instead of iterating through it to create the desired array.

In order to get the desired behaviour, I had to create a list from the zip object first

np.array(list(zip(iris.data,iris.target)))[0:10]


301284 (4) [Avatar] Offline
#4
ok sorry for the double post above, I thought the bottom right icon was for editing. Guess it was for quoting. I also found the line that said the provided code was tested on python 2.7.

Listing 2.5. Visualizing the output of k-means has an indentation problem (at least in the epub version)

On both viewers I tried the following code is indented too much on the left:

        axflat.scatter(iris.data[predictions==target,feature_index_x],
               iris.data[predictions==target,feature_index_y],
               c=color,label=label)

        axflat.set_xlabel(feature_names[feature_index_x])
        axflat.set_ylabel(feature_names[feature_index_y])


which mean this part of the code will not be part of the loop and the resulting graph will only draw the last sub graph.
Douglas McIlwraith (12) [Avatar] Offline
#5
Many thanks for your interest in the book!

301284, can you please confirm that the issue is appropriately captured in the errata.
Susan Harkins (264) [Avatar] Offline
#6
The current errata list is available at http://www.cantab.net/users/douglas.mcilwraith/errata.htm. Thanks!

Susan Harkins
Errata Editor