Use Colab for Kaggle Competition
date
Oct 20, 2024
slug
Colab
status
Published
tags
BasicSkill
summary
type
Post
- 打开Kaggle的个人简介,找到个人的API,先点击Expire API Token然后再点击Create New API Token
- 新建Colab笔记本,输入以下命令上传Token文件
!pip install -q kaggle from google.colab import files files.upload()
- 建立Kaggle目录并验证Token可用
!mkdir ~/.kaggle !cp kaggle.json ~/.kaggle/ !chmod 600 ~/.kaggle/kaggle.json !kaggle datasets list
- 使用命令行下载Kaggle数据集
!kaggle competitions download -c name-of-the-competition
- 解压缩
!pip install pyunpack !pip install patool from pyunpack import Archive !unzip 'xxx/xxx.zip' -d './' #解压到当前目录