rasbt / python-machine-learning-book-3rd-edition

The "Python Machine Learning (3rd edition)" book code repository
https://www.amazon.com/Python-Machine-Learning-scikit-learn-TensorFlow/dp/1789955750/
MIT License
4.6k stars 1.98k forks source link

run on google Colab #153

Open g-i-o-r-g-i-o opened 3 years ago

g-i-o-r-g-i-o commented 3 years ago

Hello, can you please help to run the code on google colab?

How to view images on the colab without doing much work? For each file? Probably creating a directory on the notebook colab folder, where I put all the images?

Right now I get this error:

Image(filename='images/03_01.png', width=400) 
---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
<ipython-input-149-4c8da45e0c5c> in <module>()
----> 1 Image(filename='images/04_01.png', width=400)

Then there's the watermark problem, which is easy, I've just added pip install to your files:

# add this to run in colab:
!pip install -q -U watermark
# this is the same
%load_ext watermark
%watermark -a "Sebastian Raschka" -u -d -p numpy,pandas,matplotlib,sklearn
rasbt commented 3 years ago

Hi there.

Like you said, the errors are due to the missing images. There are multiple options you can try.

  1. You could download the image folder from https://github.com/rasbt/python-machine-learning-book-3rd-edition/tree/master/ch03/images and then upload it to Google Colab. It should be relatively easy now with their drag and drop interface.

  2. You could comment out or disable those cells because they are not really needed. I just have them in the notebooks so it is easier to find the respective code when looking at the notebooks

  3. You could replace the relative links by links to the images on github, but this would probably be tedious.