问题描述
是否可以通过 Google Colab 中的 kaggle
API 使用任何可用的数据集?我看到
接下来,向下滚动到 API 访问部分并点击生成下载 API 密钥.这会将名为 kaggle.json
的文件下载到您的计算机.您将在 Colab 中使用此文件来访问 Kaggle 数据集和比赛.
导航到 https://colab.research.google.com/.
使用以下代码段上传您的 kaggle.json
文件一个代码单元:
从 google.colab 导入文件文件.上传()
使用 !pip install -q kaggle
将 kaggle.json
文件移动到 ~/.kaggle
中,这是API 客户端希望您的令牌位于:
!mkdir -p ~/.kaggle!cp kaggle.json ~/.kaggle/
现在您可以使用客户端访问数据集,例如 !kaggle datasets list
.
以下是此过程的 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 generateto 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 andcompetitions.Navigate to https://colab.research.google.com/.
Upload your
kaggle.json
file using the following snippet ina code cell:from google.colab import filesfiles.upload()
Install the kaggle API using
!pip install -q kaggle
Move the
kaggle.json
file into~/.kaggle
, which is where theAPI 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 数据集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!