Use Colab for Kaggle Competition

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