2
3 Comments

How to Install and Use Google Colab

The best way to save time and resources is to use Google Colab instead of Jupyter Notebooks directly. This is true when you want to work with multiple data science projects, do EDAs and modeling and even to work collaboratively. In Jupyter Notebook you have to create virtual environments and install every Python package from scratch per each project.

Full article here: https://www.dataendpoint.co/machine-learning-api-tutorials/how-to-install-and-use-google-colab

Colab also helps us to have better computing resources, we can buy a subscription to have GPUs and run notebooks and code faster.

We also will be talking about how to take advantage of the Google Drive ecosystem, saving datasets and files in Drive and importing and exporting data from there.

Note: if you don’t know what is Colab, please refer to this link: https://research.google.com/colaboratory/faq.html

Content

What is Colab?
Connecting Google Colab with our Drive
Creating our first Notebook
Connecting Google Colab with our CSV file in Drive
Reading CSV data using Pandas
Changing theme to Dark Mode

Step #1 - What is Colab?

Colaboratory, or “Colab” for short, is a product from Google Research. Colab allows anybody to write and execute arbitrary python code through the browser, and is especially well suited to machine learning, data analysis and education. More technically, Colab is a hosted Jupyter notebook service that requires no setup to use, while providing access free of charge to computing resources including GPUs.

Is it really free of charge to use?
Yes. Colab is free of charge to use.

Seems too good to be true. What are the limitations?
Colab resources are not guaranteed and not unlimited, and the usage limits sometimes fluctuate. This is necessary for Colab to be able to provide resources free of charge. For more details, see Resource Limits

Users who are interested in more reliable access to better resources may be interested in Colab Pro.

Resources in Colab are prioritized for interactive use cases. We prohibit actions associated with bulk computation, actions that negatively impact others, as well as actions associated with bypassing our policies. The following are disallowed from Colab runtimes:

file hosting, media serving, or other web service offerings not related to interactive compute with Colab
downloading torrents or engaging in peer-to-peer file-sharing
using a remote desktop or SSH
connecting to remote proxies
mining cryptocurrency
running denial-of-service attacks
password cracking
using multiple accounts to work around access or resource usage restrictions
creating deepfakes

Additional restrictions exist for paid users.

What is the difference between Jupyter and Colab?
Jupyter is the open source project on which Colab is based. Colab allows you to use and share Jupyter notebooks with others without having to download, install, or run anything.

Step #2- Connecting Google Colab with our Drive

So to your Google Drive and follow the steps.

After you click on Connect More Apps, type “Colaboratory”

Click on Individual Install

Click Continue

Step #3 - Creating our first Notebook

You are ready. Now let’s create our first Notebook

This will open the next window

Rename the project

Step #4 - Connecting Google Colab with our CSV file in Drive

Now let’s create data samples. Go to the following link and download the CSV. Upload that file into your Google Drive inside the same folder you created the Google Collab file

Now we have to connect the CSV file with Google Colab. To do this follow the next tutorial. It's quite simple and a necessary step to read the data. I followed the simple steps

Once everything is done you should see this folder tree (with your own files)

Copy that path, it will help us to import that data. Copy the following commands into your Google Colab to check everything is working well.

Step #5 - Reading CSV data using Pandas

import pandas as pd

csv_in_drive = "/content/drive/MyDrive/your_path/salary.csv"

df = pd.read_csv(csv_in_drive)
df.head()

My result

We can now see the table with the csv data. It works!

Step #6 - Changing theme to Dark Mode

Let’s tune our Google Colab to dark mode!

Result

Much better!

Hope you learned a lot with this post. Se you on the next one!

posted to Icon for group Data Science
Data Science
on February 10, 2023
  1. 1

    Wow, what a comprehensive guide to installing and leveraging Google Colab for machine learning projects! The step-by-step instructions coupled with clear explanations made the process seem less daunting, even for someone relatively new to the field. I particularly appreciated the insights into the collaborative features of Google Colab, which opens up exciting possibilities for team projects and knowledge sharing. Keep us updated!

  2. 1

    you can use Google Colab, simply open the website in your web browser and sign in with your Google account. Once signed in, you can create a new notebook or open an existing one. You can then write and run Python code in the notebook, which is backed by a powerful cloud-based infrastructure.

    To install additional libraries or packages, you can use the built-in terminal or run shell commands in a code cell. You can also upload and download files to and from your Google Drive.

Trending on Indie Hackers
Your SaaS Isn’t Failing — Your Copy Is. User Avatar 58 comments Solo SaaS Founders Don’t Need More Hours....They Need This User Avatar 45 comments Planning to raise User Avatar 18 comments The Future of Automation: Why Agents + Frontend Matter More Than Workflow Automation User Avatar 13 comments AI Turned My $0 Idea into $10K/Month in 45 Days – No Code, Just This One Trick User Avatar 13 comments From side script → early users → real feedback (update on my SaaS journey) User Avatar 11 comments