Approaching to ML algorithms and examples are nice. But code pieces of examples are really bad. So many errors are there and sometimes you are confused which code pieces belong to where. I recommend you to just read the book and not try to implement specified code pieces.