Preparation#
Here we introduce a series of setting up tools including Google Colab and Google Drive that are needed before undertaking the tasks.
Google Colab#
Google Colab, short for Google Colaboratory, is a cloud-based service provided by Google that allows users to write, execute, and share Python code through a web browser. It offers free access to a machine equipped with a GPU, making it a popular choice for machine learning and data science projects. This is an user-freindly way to test, excecute machine learning tasks, without any environment set-up on your device. Below are the steps to get started with Google Colab:
Steps to Use Google Colab#
Google Account: Make sure you have a Google account. If not, create one.
Access Colab: Open your web browser and go to Google Colab.
New Notebook: Click on
File
->New notebook
to create a new Python notebook.Run Code: Write your Python code in the cells and click the play button to execute.
Upload Data: You can upload data files by clicking on the folder icon in the sidebar and then clicking on the upload button.
Save Notebook: You can save your notebook to Google Drive by clicking
File
->Save
.Share Notebook: Click on the
Share
button to share your notebook with others.GPU Access: To enable GPU, go to
Runtime
->Change runtime type
-> SelectGPU
from the Hardware accelerator dropdown.
It is important to note that you can mount your drive to your google colab file and you will have access to the data stored in your google drive in your colab notebook.
Google Drive#
For chapter 1, all the necessary code and data can be accessed from this folder on Google Drive The steps of accessing the drive and ways of copying the shared folder to your own Google Drive is listed below:
Steps to Use Google Drive#
Access Google Drive:
Log in to your Google account.
Navigate to Google Drive by typing the URL in your web browser or accessing it through the Google apps menu.
Locate the Shared Folder:
Find the shared folder link provided by the course instructor (the link should be a URL pointing to the Google Drive folder).
Click on the link to access the shared folder.
Copy the Folder to Your Drive:
Right-click on the folder name in Google Drive.
Select “Make a copy” from the context menu. This will create a copy of the folder in your drive. The copied folder will be named “Copy of [original folder name].”
Alternatively, if you have “Add to My Drive” option, you can use this to add the shared folder directly to your Drive for easy access.
Organize the Copied Folder (Optional):
Navigate to “My Drive” where you’ll find the copied folder.
You can click and drag to move the folder, or right-click and select “Move to…” to organise it within your drive’s directory structure.
You are not expected to change the general structure of the folder. You are welcomed to add data files of your own that could be used for analysis.
Access the Files within the Copied Folder:
Double-click on the copied folder to open it.
Here you can access all the files, including Jupyter notebooks and data files, as provided by us.
Open Jupyter notebooks with Google Colab:
For Jupyter notebooks, right-click on the file and choose “Open with” followed by “Google Colab” to open and run the notebook in Colab.
Connect Colab to your Google Drive
In your Colab notebook, you can access files stored in Google Drive by mounting your drive.
Use the following code snippet in a Colab cell to mount your drive:
from google.colab import drive drive.mount('/content/drive')
Follow the authentication steps provided by Colab, which will involve copying an authentication code from a Google login flow.
Work with Files:
You can view and edit files directly in Google Drive. For editing Jupyter notebooks, use Google Colab as described above.
If you’re working with non-code files, you can use Google Drive’s integrated apps like Google Docs, Sheets, or Slides to edit documents.