在Google Colab中使用Kaggle数据集 [英] Using Kaggle Datasets in Google Colab
问题描述
是否可以使用Google Colab中通过 kaggle
API提供的任何数据集?我看到
下一步,向下滚动到API访问部分,然后点击生成
以下载API密钥。
这会将名为 kaggle.json
的文件下载到您的计算机上。
您将在Colab中使用此文件来访问Kaggle数据集和
竞赛。
导航到https://colab.research .google.com /.
使用$ b中的以下代码段上传 kaggle.json
文件$ ba代码单元格:
来自google.colab导入文件
files.upload()
使用安装kaggle API!pip install -q kaggle
将 kaggle.json
文件移动到〜/ .kaggle
中,
API客户端希望您的令牌位于以下位置:
!mkdir -p〜/ .kaggle
!cp kaggle.json〜/ .kaggle /
现在您可以使用客户端访问数据集,例如!kaggle数据集列表
。
这是Colab部分的完整示例笔记本此过程:
https://colab.research.google.com/drive/1DofKEdQYaXmDWBzuResXWWvxhLgDeVyl
此示例显示了上传 kaggle.json
文件,Kaggle API客户端,并使用Kaggle客户端下载数据集。
Is it possible to use any datasets available via the kaggle
API in Google Colab? I see the Kaggle API is used in this Colab notebook, but it's a bit unclear to me what datasets it provides access to.
Step-by-step --
Create an API key in Kaggle.
To do this, go to kaggle.com/ and open your user settings page.
Next, scroll down to the API access section and click generate to download an API key. This will download a file called
kaggle.json
to your computer. You'll use this file in Colab to access Kaggle datasets and competitions.Navigate to https://colab.research.google.com/.
Upload your
kaggle.json
file using the following snippet in a code cell:from google.colab import files files.upload()
Install the kaggle API using
!pip install -q kaggle
Move the
kaggle.json
file into~/.kaggle
, which is where the API client expects your token to be located:!mkdir -p ~/.kaggle !cp kaggle.json ~/.kaggle/
Now you can access datasets using the client, e.g.,
!kaggle datasets list
.
Here's a complete example notebook of the Colab portion of this process: https://colab.research.google.com/drive/1DofKEdQYaXmDWBzuResXWWvxhLgDeVyl
This example shows uploading the kaggle.json
file, the Kaggle API client, and using the Kaggle client to download a dataset.
这篇关于在Google Colab中使用Kaggle数据集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!