Kaggle like a King

Kaggle like a King

Fetch Any Data-Set To Google-Colab

Kaggle is been here for quite a while now and we all know its like gold mine when it comes to working with data-science projects and in many cases we prefer to use google drive to access our data sets.

so, today we shall look at how can one access the google drive data from within the notebooks in a few very simple and straight forward steps.

lets get started.

Heads Up

For the sake of this tutorial I will show you how to access kaggle's Data set of "Chest Xray Pneumonia"

Pre-reqs for starting out

  • Basic Knowledge of Linux File System
  • Familiarity with Command Line
  • A Google Account
  • A Kaggle Account
  • Google Colab NoteBook (prefferable)

And last but not the least

  • This tutorial ๐Ÿ˜‰

Buckle In

Kaggle has a high security as there is much valuable data stored on their servers which is accessed by researchers and organizations of massive scale. And for this sole purpose Kaggle works in such a way that it allocated each user a specific ID-Key. Now we as end users on the platform require that key to get pragmatic access to Kaggle's system and complete the tasks at hand.

You can find that key from your profile on Kaggle

Lets Roll !

As the Colab is based on Linux File System, So in order to execute any command that refers to Linux OS we need to run it by adding '!' behind the Keyword.

In order to start we need to first install the Kaggle on our colab notebook environment.

!pip -q install Kaggle

next we need to upload that JSON Key file that you've attained from your account in order to access kaggle system.

from google.colab import files
files.upload()

This will open the file selector from your system and you can point to the file that has the Json-key.

Okay Now What?

  • Now you need to relax !๐Ÿ˜

Now we need to copy the file into the directory, but first we shall make the directory for the file.

To do so, write the following command

!mkdir ~/kaggle

This will make a kaggle folder/ directory in the home Directory of the system (to make things manageable and easy)

next we need to copy the file into the kaggle directory we just made. lets do that quickly!

!cp kaggle.json ~/.kaggle/

But Wait!! how will I know if that was successful?

To check if the file was successfully copied into the directory we will run yet another command!

!ls ~/.kaggle

In case of success you will see the out of the command as "kaggle.json"

OK!! so now that we have done all that, can I now use it?

  • Not really! ๐Ÿคฆโ€โ™‚๏ธ

You see, this is Linux! we can't just go on like that and expect things to work perfectly fine!! Like everything in life, we need permissions here as well.

lets change the permissions to make it work!

!chmod 600 ~/.kaggle/kaggle.json

I'm Tired !!

  • Well we're done!! ๐Ÿ˜Ž

Accessing the Kaggle Space-Ship ๐Ÿ›ธ for Data!

In order to access the list of datasets stored on kaggle, use the following command

!kaggle datasets list

This will list all the data sets on kaggle that are available for your usage!

Lets Download !

To download a particular dataset from kaggle, all we have to do is type

!kaggle datasets download -d DATASET_NAME_HERE

As an Example we will download the chest-Xray-pneumonia dataset

!kaggle datasets download -d paultimothymooney/chest-xray-pneumonia

And BOOM!! there you have it in your drive!! now you can do all the operations and procedures that you want to perform on that data.

A good starting point will be visualize what you received.

Lemme know if that was useful for you.

~ Adios