dimsmauls commited on
Commit
3630fe5
·
verified ·
1 Parent(s): 6921c45

Add Code4ML annotated subset with SonarQube and MLScent ratings

Browse files
Files changed (5) hide show
  1. .gitattributes +1 -60
  2. LICENSE +12 -0
  3. NOTICE.txt +6 -0
  4. README.md +173 -0
  5. code4ml_annotated.csv +0 -0
.gitattributes CHANGED
@@ -1,60 +1 @@
1
- *.7z filter=lfs diff=lfs merge=lfs -text
2
- *.arrow filter=lfs diff=lfs merge=lfs -text
3
- *.avro filter=lfs diff=lfs merge=lfs -text
4
- *.bin filter=lfs diff=lfs merge=lfs -text
5
- *.bz2 filter=lfs diff=lfs merge=lfs -text
6
- *.ckpt filter=lfs diff=lfs merge=lfs -text
7
- *.ftz filter=lfs diff=lfs merge=lfs -text
8
- *.gz filter=lfs diff=lfs merge=lfs -text
9
- *.h5 filter=lfs diff=lfs merge=lfs -text
10
- *.joblib filter=lfs diff=lfs merge=lfs -text
11
- *.lfs.* filter=lfs diff=lfs merge=lfs -text
12
- *.lz4 filter=lfs diff=lfs merge=lfs -text
13
- *.mds filter=lfs diff=lfs merge=lfs -text
14
- *.mlmodel filter=lfs diff=lfs merge=lfs -text
15
- *.model filter=lfs diff=lfs merge=lfs -text
16
- *.msgpack filter=lfs diff=lfs merge=lfs -text
17
- *.npy filter=lfs diff=lfs merge=lfs -text
18
- *.npz filter=lfs diff=lfs merge=lfs -text
19
- *.onnx filter=lfs diff=lfs merge=lfs -text
20
- *.ot filter=lfs diff=lfs merge=lfs -text
21
- *.parquet filter=lfs diff=lfs merge=lfs -text
22
- *.pb filter=lfs diff=lfs merge=lfs -text
23
- *.pickle filter=lfs diff=lfs merge=lfs -text
24
- *.pkl filter=lfs diff=lfs merge=lfs -text
25
- *.pt filter=lfs diff=lfs merge=lfs -text
26
- *.pth filter=lfs diff=lfs merge=lfs -text
27
- *.rar filter=lfs diff=lfs merge=lfs -text
28
- *.safetensors filter=lfs diff=lfs merge=lfs -text
29
- saved_model/**/* filter=lfs diff=lfs merge=lfs -text
30
- *.tar.* filter=lfs diff=lfs merge=lfs -text
31
- *.tar filter=lfs diff=lfs merge=lfs -text
32
- *.tflite filter=lfs diff=lfs merge=lfs -text
33
- *.tgz filter=lfs diff=lfs merge=lfs -text
34
- *.wasm filter=lfs diff=lfs merge=lfs -text
35
- *.xz filter=lfs diff=lfs merge=lfs -text
36
- *.zip filter=lfs diff=lfs merge=lfs -text
37
- *.zst filter=lfs diff=lfs merge=lfs -text
38
- *tfevents* filter=lfs diff=lfs merge=lfs -text
39
- # Audio files - uncompressed
40
- *.pcm filter=lfs diff=lfs merge=lfs -text
41
- *.sam filter=lfs diff=lfs merge=lfs -text
42
- *.raw filter=lfs diff=lfs merge=lfs -text
43
- # Audio files - compressed
44
- *.aac filter=lfs diff=lfs merge=lfs -text
45
- *.flac filter=lfs diff=lfs merge=lfs -text
46
- *.mp3 filter=lfs diff=lfs merge=lfs -text
47
- *.ogg filter=lfs diff=lfs merge=lfs -text
48
- *.wav filter=lfs diff=lfs merge=lfs -text
49
- # Image files - uncompressed
50
- *.bmp filter=lfs diff=lfs merge=lfs -text
51
- *.gif filter=lfs diff=lfs merge=lfs -text
52
- *.png filter=lfs diff=lfs merge=lfs -text
53
- *.tiff filter=lfs diff=lfs merge=lfs -text
54
- # Image files - compressed
55
- *.jpg filter=lfs diff=lfs merge=lfs -text
56
- *.jpeg filter=lfs diff=lfs merge=lfs -text
57
- *.webp filter=lfs diff=lfs merge=lfs -text
58
- # Video files - compressed
59
- *.mp4 filter=lfs diff=lfs merge=lfs -text
60
- *.webm filter=lfs diff=lfs merge=lfs -text
 
1
+ *.csv filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
LICENSE ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Code4ML Annotated Subset
2
+ Copyright (c) 2026 Dimas Maulana Ahmad
3
+
4
+ This dataset compilation is licensed under the Creative Commons Attribution 4.0
5
+ International License (CC-BY-4.0).
6
+ Full text: https://creativecommons.org/licenses/by/4.0/legalcode
7
+
8
+ It is derived from Code4ML (Drozdova et al., 2023; https://zenodo.org/records/7312803),
9
+ which is also released under CC-BY-4.0.
10
+
11
+ The `code_block` snippets are Kaggle notebook code, each published under the Apache
12
+ License 2.0. See NOTICE.txt.
NOTICE.txt ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ This dataset contains code snippets from the Code4ML corpus
2
+ (Drozdova et al., 2023; https://zenodo.org/records/7312803).
3
+
4
+ Original notice from Code4ML:
5
+
6
+ Notebooks for this dataset are taken from https://kaggle.com. Each notebook is published under a vanilla Apache 2.0 license and can be found by the related link from the kernels_meta.csv kernel_link field. Those are split into cells and stripped from redundant comments/markdown explanations. Python PEP8 code style fixes might also be enforced. No code-affecting changes to the notebook have been made.
README.md CHANGED
@@ -1,3 +1,176 @@
1
  ---
2
  license: cc-by-4.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: cc-by-4.0
3
+ pretty_name: Code4ML Annotated Subset with SonarQube and MLScent Ratings
4
+ language:
5
+ - en
6
+ tags:
7
+ - code
8
+ - python
9
+ - machine-learning
10
+ - code4ml
11
+ - kaggle
12
+ - code-quality
13
+ - static-analysis
14
+ - sonarqube
15
+ task_categories:
16
+ - text-generation
17
+ - text-classification
18
+ size_categories:
19
+ - 1K<n<10K
20
+ configs:
21
+ - config_name: default
22
+ data_files:
23
+ - split: train
24
+ path: code4ml_annotated.csv
25
  ---
26
+
27
+ # Code4ML Annotated Subset with SonarQube and MLScent Ratings
28
+
29
+ The 7,947 manually annotated Python snippets from the **Code4ML** corpus
30
+ ([Zenodo record 7312803](https://zenodo.org/records/7312803)), joined with their task-class
31
+ names and annotated with structural code-quality ratings from **SonarQube** and **MLScent**.
32
+
33
+ Code4ML contains 2,599,355 code cells from 23,103 Kaggle notebooks. Only this annotated
34
+ subset carries a human-assigned task label, so it is the subset usable for building
35
+ instruction–code pairs. This repository holds that subset in one file. Each snippet was scanned on its own, so
36
+ the ratings describe the snippet, not its whole notebook.
37
+
38
+ ## Dataset summary
39
+
40
+ | | |
41
+ |---|---|
42
+ | Records | 7,947 |
43
+ | Source file | Code4ML `markup_data.csv`, labels from `vertices.csv` |
44
+ | Task classes | 12 classes, 70 subclasses |
45
+ | Format | single comma-delimited CSV with header |
46
+ | Language | Python |
47
+
48
+ ## Columns
49
+
50
+ | column | type | description |
51
+ |---|---|---|
52
+ | `id` | int | row index from Code4ML `markup_data.csv` |
53
+ | `code_block` | string | the Python snippet (one notebook cell, may span multiple lines) |
54
+ | `too_long` | string | `Yes`/`No` flag from the Code4ML annotators |
55
+ | `marks` | int | annotator confidence, 1 (lowest) to 5 (highest) |
56
+ | `graph_vertex_id` | int | task-label id from Code4ML `vertices.csv` |
57
+ | `graph_vertex_class` | string | task class, e.g. `Data_Transform`, `Model_Train` |
58
+ | `graph_vertex_subclass` | string | task subclass, e.g. `choose_model_class` |
59
+ | `kernel_id` | int or empty | Kaggle notebook id, recovered by matching `code_block` text against Code4ML `code_blocks.csv`; empty when the text appears in more than one notebook or none |
60
+ | `sqale_rating` | float | SonarQube SQALE rating (1.0 = A … 5.0 = E) |
61
+ | `maintainability_rating` | string | SonarQube maintainability grade `A`–`E` |
62
+ | `code_smells` | int | SonarQube code smells |
63
+ | `complexity` | int | SonarQube cyclomatic complexity |
64
+ | `cognitive_complexity` | int | SonarQube cognitive complexity |
65
+ | `bugs` | int | SonarQube bugs |
66
+ | `sqale_index` | int | SonarQube technical debt (minutes) |
67
+ | `ncloc` | int or empty | non-comment lines of code; empty when SonarQube did not analyse the snippet |
68
+ | `mlscent_analysis_status` | string | `ok`, `no_ml_import` (no ML library import in the snippet or its recovered notebook imports), or `invalid_python` |
69
+ | `mlscent_smell_count` | int | number of MLScent findings |
70
+ | `mlscent_unique_smell_count` | int | number of distinct MLScent smell types |
71
+ | `mlscent_findings_json` | JSON string | all MLScent findings |
72
+ | `mlscent_ml_rating` | string | `A`–`E` from ML-specific findings only, by severity; `N/A` when MLScent did not analyse the snippet |
73
+ | `mlscent_ml_rating_basis` | string | findings and severities behind `mlscent_ml_rating` |
74
+ | `mlscent_ml_findings_json` | JSON string | ML-specific findings used for the rating |
75
+ | `mlscent_ignored_findings_json` | JSON string | finding types not used for the rating |
76
+ | `context_line_count` | int | lines of recovered notebook ML imports prepended for MLScent analysis |
77
+ | `combined_rating` | string | worse of `maintainability_rating` and `mlscent_ml_rating`; `N/A` when either is missing |
78
+
79
+ ## Statistics
80
+
81
+ Task classes:
82
+
83
+ | `graph_vertex_class` | Snippets |
84
+ |---|---:|
85
+ | Data_Transform | 2,387 |
86
+ | Debug | 1,446 |
87
+ | Visualization | 862 |
88
+ | Model_Train | 816 |
89
+ | Data_Extraction | 517 |
90
+ | Environment | 441 |
91
+ | Other | 372 |
92
+ | Model_Evaluation | 354 |
93
+ | Data_Export | 350 |
94
+ | EDA | 231 |
95
+ | Hyperparam_Tuning | 160 |
96
+ | Model_Interpretation | 11 |
97
+
98
+ Annotator confidence (`marks`):
99
+
100
+ | 1 | 2 | 3 | 4 | 5 |
101
+ |---:|---:|---:|---:|---:|
102
+ | 44 | 210 | 903 | 1,419 | 5,371 |
103
+
104
+ Other properties:
105
+
106
+ | Property | Value |
107
+ |---|---|
108
+ | `too_long` = `Yes` | 1,360 |
109
+ | Duplicate `code_block` values | 108 |
110
+ | Lines per snippet (median / p75 / max) | 2 / 6 / 582 |
111
+
112
+ Ratings:
113
+
114
+ | Rating | `maintainability_rating` | `mlscent_ml_rating` | `combined_rating` |
115
+ |---|---:|---:|---:|
116
+ | A | 7,816 | 3,045 | 2,996 |
117
+ | B | 84 | 952 | 962 |
118
+ | C | 40 | 56 | 89 |
119
+ | D | 7 | 111 | 117 |
120
+ | E | 0 | 8 | 8 |
121
+ | N/A | — | 3,775 | 3,775 |
122
+
123
+ | Rating property | Value |
124
+ |---|---|
125
+ | `kernel_id` recovered | 4,373 |
126
+ | `ncloc` empty (not analysed by SonarQube) | 1,003 |
127
+ | `mlscent_analysis_status` = `ok` / `no_ml_import` / `invalid_python` | 4,172 / 3,551 / 224 |
128
+
129
+ No rows were removed or modified; duplicates and short snippets are kept as in the source.
130
+
131
+ ## How the ratings were produced
132
+
133
+ 1. **SonarQube** Community Edition, default Python profile, through a FastAPI wrapper around
134
+ `sonar-scanner` (`/scan-batch`).
135
+ 2. **MLScent** (`ml-code-smell-detector==0.1.2`), with recovered notebook ML imports
136
+ prepended as context, through a local rating service (`/rate-batch`).
137
+ 3. The data was split into two halves, each rated by its own SonarQube + MLScent instance
138
+ pair, then merged back by `id`.
139
+
140
+ ## Usage
141
+
142
+ ```python
143
+ from datasets import load_dataset
144
+
145
+ ds = load_dataset("dimsmauls/code4ml-annotated-rated", split="train")
146
+ print(ds[0]["graph_vertex_class"], ds[0]["combined_rating"], ds[0]["code_block"])
147
+ ```
148
+
149
+ ## Provenance & attribution
150
+
151
+ - **Source corpus:** Code4ML, [Zenodo record 7312803](https://zenodo.org/records/7312803),
152
+ released under CC-BY-4.0.
153
+ - **Original code:** the snippets are Kaggle notebook cells, each published under the
154
+ **Apache-2.0** license. See `NOTICE.txt`.
155
+ - **This derivative** joins `markup_data.csv` with the class names from `vertices.csv` and adds
156
+ SonarQube and MLScent rating columns. No code was changed.
157
+
158
+ ## Citation
159
+
160
+ Please cite the original Code4ML work:
161
+
162
+ ```bibtex
163
+ @article{drozdova2023code4ml,
164
+ title={Code4ML: a Large-scale Dataset of Annotated Machine Learning Code},
165
+ author={Drozdova, Anastasia and Trofimova, Ekaterina and Guseva, Polina and Scherbakova, Anna and Ustyuzhanin, Andrey},
166
+ journal={PeerJ Computer Science},
167
+ year={2023},
168
+ doi={10.7717/peerj-cs.1230}
169
+ }
170
+ ```
171
+
172
+ ## License
173
+
174
+ Released under [CC-BY-4.0](https://creativecommons.org/licenses/by/4.0/), the same license
175
+ as Code4ML. The underlying `code_block` snippets are Kaggle notebook code under
176
+ **Apache-2.0**; that attribution is preserved in `NOTICE.txt`.
code4ml_annotated.csv ADDED
The diff for this file is too large to render. See raw diff