Published May 19, 2025 | Version v1

Code4ML 2.0

Authors/Creators

Description

This is an enriched version of the Code4ML dataset, a large-scale corpus of annotated Python code snippets, competition summaries, and data descriptions sourced from Kaggle. The initial release includes approximately 2.5 million snippets of machine learning code extracted from around 100,000 Jupyter notebooks. A portion of these snippets has been manually annotated by human assessors through a custom-built, user-friendly interface designed for this task.

The original dataset is organized into multiple CSV files, each containing structured data on different entities:

  • code_blocks.csv: Contains raw code snippets extracted from Kaggle.
  • kernels_meta.csv: Metadata for the notebooks (kernels) from which the code snippets were derived.
  • competitions_meta.csv: Metadata describing Kaggle competitions, including information about tasks and data.
  • markup_data.csv: Annotated code blocks with semantic types, allowing deeper analysis of code structure.
  • vertices.csv: A mapping from numeric IDs to semantic types and subclasses, used to interpret annotated code blocks.

Table 1. code_blocks.csv structure

Column Description
code_blocks_index Global index linking code blocks to markup_data.csv.
kernel_id Identifier for the Kaggle Jupyter notebook from which the code block was extracted.
code_block_id

Position of the code block within the notebook.

code_block

The actual machine learning code snippet.

 

Table 2. kernels_meta.csv structure

Column Description
kernel_id Identifier for the Kaggle Jupyter notebook.
kaggle_score Performance metric of the notebook.
kaggle_comments Number of comments on the notebook.
kaggle_upvotes Number of upvotes the notebook received.
kernel_link URL to the notebook.
comp_name Name of the associated Kaggle competition.

 

Table 3. competitions_meta.csv structure

Column Description
comp_name Name of the Kaggle competition.
description Overview of the competition task.
data_type Type of data used in the competition.
comp_type Classification of the competition.
subtitle Short description of the task.
EvaluationAlgorithmAbbreviation Metric used for assessing competition submissions.
data_sources Links to datasets used.
metric type Class label for the assessment metric.

 

Table 4. markup_data.csv structure

Column Description
code_block Machine learning code block.
too_long Flag indicating whether the block spans multiple semantic types.
marks Confidence level of the annotation.
graph_vertex_id ID of the semantic type.

 

The dataset allows mapping between these tables. For example:

  • code_blocks.csv can be linked to kernels_meta.csv via the kernel_id column.
  • kernels_meta.csv is connected to competitions_meta.csv through comp_name. To maintain quality, kernels_meta.csv includes only notebooks with available Kaggle scores.

In addition, data_with_preds.csv contains automatically classified code blocks, with a mapping back to code_blocks.csvvia the code_blocks_index column.

 

Code4ML 2.0 Enhancements

The updated Code4ML 2.0 corpus introduces kernels extracted from Meta Kaggle Code. These kernels correspond to the kaggle competitions launched since 2020. The natural descriptions of the competitions are retrieved with the aim of LLM. 

Notebooks in kernels_meta2.csv may not have a Kaggle score but include a leaderboard ranking (rank), providing additional context for evaluation.

competitions_meta_2.csv is enriched with data_cards, decsribing the data used in the competitions.

Applications

The Code4ML 2.0 corpus is a versatile resource, enabling training and evaluation of models in areas such as:

  • Code generation
  • Code understanding
  • Natural language processing of code-related tasks

Files

code_blocks.csv

Files (1.2 GB)

Name Size
md5:81227d0d1fed6b74d6544b25fbce4f1f
986.6 MB Preview Download
md5:5a8a3ee9afc3e6c620f040036da9d59d
139.3 MB Preview Download
md5:7e7f8e07ee3e2937fe19e119d30a85c7
582.3 kB Preview Download
md5:3187e2b584456258670a4dd85b04c81e
445.3 kB Preview Download
md5:44eafce3cfb073e0a2c93adffa939c87
54.9 MB Preview Download
md5:738958a342398cdbb82eb5473405c4c6
2.2 MB Preview Download
md5:e839d44501c85d94a657269b6cb7eae5
2.1 MB Preview Download
md5:2d1d10dcfc66a49d6520c2ab70db8cfc
2.3 MB Preview Download
md5:0afd0b11950f36b3df30007f026dd212
407 Bytes Preview Download
md5:9a71351669f045e04fd702134f7cde96
2.4 kB Preview Download