If you'd like to explore the data from this book, you can check out the data folder, which has CSV files for all the distance calculations in the book, along with the tf-idf (most distinctive words) values for the books, and the chapter 2 6-gram values. The viz folder has high-resolution version of all the visualizations.
And if you want just the code for using word count and term frequency vectorizers with cosine and Euclidean distance, you can use the just-the-code notebook... but you really should read the book first.
