Table of Content
在colab平台上使用kaggle家数据集资源
!pip install kaggle
“`
–– coding: utf-8 ––
“””kaggle数据集加载.ipynb
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/gist/napoler/cc05bf83dc19e26ea8b828c983d8cfdb/kaggle.ipynb
“””
api_key = “” #@param {type:”string”}
api_token = {“username”:”USERNAME”,”key”:api_key}
api_token = {“username”:”terorg”,”key”:”5c8d80bf3084dc6ee”} #@param {type:”raw”}
Info on how to get your api key (kaggle.json) here: https://github.com/Kaggle/kaggle-api#api-credentials
import json
import zipfile
import os
!mkdir /content/.kaggle/
with open(‘/root/.kaggle/kaggle.json’, ‘w’) as file:
json.dump(api_token, file)
!chmod 600 /content/.kaggle/kaggle.json
!kaggle config path -p /content
!kaggle competitions download -c jigsaw-toxic-comment-classification-challenge
os.chdir(‘/content/competitions/jigsaw-toxic-comment-classification-challenge’)
for file in os.listdir():
zip_ref = zipfile.ZipFile(file, ‘r’)
zip_ref.extractall()
zip_ref.close()
“`