Colaboratory

Colaboratory is a free and open source environment for Python development that requires no setup and runs entirely on the cloud. It contains all the pre-installed packages required for your AI implementations so that they are ready to run with a simple plug and play process. By plug, I just mean to copy and paste the code inside a new Colab file (I'll explain how to open one next), and by play, I just mean to click on the play button (an example of that follows).

Here is the link to the main page of Colaboratory:

https://colab.research.google.com/notebooks/welcome.ipynb

You should get a page like this:

Figure 2: Colaboratory – main page

Click File in the upper left, and then click New Python 3 notebook:

Figure 3: Colaboratory – opening a notebook

Then you will get this view. Paste your Python code inside the cell (red arrow). That's the "plug" part:

Figure 4: Colaboratory – the "plug" part

I recommend using separate Colaboratory notebooks for each model in this book.

Now let's see the "play" part. Open the Thompson Sampling model in the Chapter 06 folder, implemented inside the thompson_sampling.py file:

Figure 5: GitHub – opening Thompson Sampling

Copy the whole code from inside the Python file; don't worry about understanding the code (or the results) for now. It will all be explained, step by step, in Chapter 6, AI for Sales and Advertising – Sell like the Wolf of AI Street:

Figure 6: GitHub – copying Thompson Sampling

Next, paste it into Colaboratory (in the cell highlighted by the arrow in Figure 4). Then we get this:

Figure 7: Pasting Thompson Sampling

And now we are ready for the "play" part! Just click the "play" button below:

Figure 8: The "play" part

And the code will execute. Don't pay attention to the result now, as this will all be explained in Chapter 6, AI for Sales and Advertising – Sell like the Wolf of AI Street.

You are all set! You now have an AI toolkit that will enable you to follow along with every example in the book.

Before you begin your AI journey in earnest, you must make sure that you have the right basic coding knowledge. This is truly important before becoming a master at AI. If you have little or no experience with Python, make sure that you learn Python in Chapter 3, Python Fundamentals – Learn How to Code in Python, as a last preparation phase before you begin exploring the robot world.