dslighting 1.7.1__py3-none-any.whl → 1.7.8__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (352) hide show
  1. dslighting/__init__.py +1 -1
  2. dslighting/core/agent.py +78 -62
  3. {dslighting-1.7.1.dist-info → dslighting-1.7.8.dist-info}/METADATA +3 -1
  4. {dslighting-1.7.1.dist-info → dslighting-1.7.8.dist-info}/RECORD +352 -7
  5. {dslighting-1.7.1.dist-info → dslighting-1.7.8.dist-info}/top_level.txt +1 -0
  6. mlebench/README.md +39 -0
  7. mlebench/__init__.py +0 -0
  8. mlebench/cli.py +221 -0
  9. mlebench/competitions/3d-object-detection-for-autonomous-vehicles/grade.py +161 -0
  10. mlebench/competitions/3d-object-detection-for-autonomous-vehicles/mAP_evaluation.py +425 -0
  11. mlebench/competitions/3d-object-detection-for-autonomous-vehicles/prepare.py +483 -0
  12. mlebench/competitions/3d-object-detection-for-autonomous-vehicles/prepare_val.py +719 -0
  13. mlebench/competitions/AI4Code/grade.py +70 -0
  14. mlebench/competitions/AI4Code/prepare.py +84 -0
  15. mlebench/competitions/AI4Code/prepare_val.py +159 -0
  16. mlebench/competitions/__init__.py +0 -0
  17. mlebench/competitions/aerial-cactus-identification/grade.py +11 -0
  18. mlebench/competitions/aerial-cactus-identification/prepare.py +71 -0
  19. mlebench/competitions/aerial-cactus-identification/prepare_val.py +133 -0
  20. mlebench/competitions/alaska2-image-steganalysis/grade.py +136 -0
  21. mlebench/competitions/alaska2-image-steganalysis/prepare.py +88 -0
  22. mlebench/competitions/alaska2-image-steganalysis/prepare_val.py +148 -0
  23. mlebench/competitions/aptos2019-blindness-detection/grade.py +35 -0
  24. mlebench/competitions/aptos2019-blindness-detection/prepare.py +75 -0
  25. mlebench/competitions/aptos2019-blindness-detection/prepare_val.py +123 -0
  26. mlebench/competitions/bike-sharing-demand/__init__.py +0 -0
  27. mlebench/competitions/bike-sharing-demand/grade.py +55 -0
  28. mlebench/competitions/bike-sharing-demand/prepare.py +37 -0
  29. mlebench/competitions/billion-word-imputation/grade.py +37 -0
  30. mlebench/competitions/billion-word-imputation/prepare.py +107 -0
  31. mlebench/competitions/billion-word-imputation/prepare_val.py +179 -0
  32. mlebench/competitions/bms-molecular-translation/grade.py +40 -0
  33. mlebench/competitions/bms-molecular-translation/prepare.py +68 -0
  34. mlebench/competitions/bms-molecular-translation/prepare_val.py +131 -0
  35. mlebench/competitions/cassava-leaf-disease-classification/grade.py +12 -0
  36. mlebench/competitions/cassava-leaf-disease-classification/prepare.py +113 -0
  37. mlebench/competitions/cassava-leaf-disease-classification/prepare_val.py +186 -0
  38. mlebench/competitions/cdiscount-image-classification-challenge/grade.py +11 -0
  39. mlebench/competitions/cdiscount-image-classification-challenge/prepare.py +144 -0
  40. mlebench/competitions/cdiscount-image-classification-challenge/prepare_val.py +205 -0
  41. mlebench/competitions/chaii-hindi-and-tamil-question-answering/grade.py +67 -0
  42. mlebench/competitions/chaii-hindi-and-tamil-question-answering/prepare.py +31 -0
  43. mlebench/competitions/chaii-hindi-and-tamil-question-answering/prepare_val.py +94 -0
  44. mlebench/competitions/champs-scalar-coupling/grade.py +60 -0
  45. mlebench/competitions/champs-scalar-coupling/prepare.py +116 -0
  46. mlebench/competitions/champs-scalar-coupling/prepare_val.py +155 -0
  47. mlebench/competitions/conways-reverse-game-of-life-2020/__init__.py +0 -0
  48. mlebench/competitions/conways-reverse-game-of-life-2020/grade.py +40 -0
  49. mlebench/competitions/conways-reverse-game-of-life-2020/prepare.py +41 -0
  50. mlebench/competitions/demand-forecasting-kernels-only/__init__.py +0 -0
  51. mlebench/competitions/demand-forecasting-kernels-only/grade.py +66 -0
  52. mlebench/competitions/demand-forecasting-kernels-only/prepare.py +27 -0
  53. mlebench/competitions/demand_forecasting_kernels_only/__init__.py +0 -0
  54. mlebench/competitions/demand_forecasting_kernels_only/grade.py +66 -0
  55. mlebench/competitions/demand_forecasting_kernels_only/prepare.py +27 -0
  56. mlebench/competitions/denoising-dirty-documents/grade.py +44 -0
  57. mlebench/competitions/denoising-dirty-documents/prepare.py +134 -0
  58. mlebench/competitions/denoising-dirty-documents/prepare_val.py +178 -0
  59. mlebench/competitions/detecting-insults-in-social-commentary/grade.py +11 -0
  60. mlebench/competitions/detecting-insults-in-social-commentary/prepare.py +72 -0
  61. mlebench/competitions/detecting-insults-in-social-commentary/prepare_val.py +128 -0
  62. mlebench/competitions/dog-breed-identification/dogs.py +124 -0
  63. mlebench/competitions/dog-breed-identification/grade.py +42 -0
  64. mlebench/competitions/dog-breed-identification/prepare.py +55 -0
  65. mlebench/competitions/dog-breed-identification/prepare_val.py +104 -0
  66. mlebench/competitions/dogs-vs-cats-redux-kernels-edition/grade.py +43 -0
  67. mlebench/competitions/dogs-vs-cats-redux-kernels-edition/prepare.py +70 -0
  68. mlebench/competitions/dogs-vs-cats-redux-kernels-edition/prepare_val.py +143 -0
  69. mlebench/competitions/ethanol-concentration/grade.py +23 -0
  70. mlebench/competitions/ethanol-concentration/prepare.py +90 -0
  71. mlebench/competitions/facebook-recruiting-iii-keyword-extraction/grade.py +60 -0
  72. mlebench/competitions/facebook-recruiting-iii-keyword-extraction/prepare.py +41 -0
  73. mlebench/competitions/facebook-recruiting-iii-keyword-extraction/prepare_val.py +92 -0
  74. mlebench/competitions/feedback-prize-english-language-learning/__init__.py +0 -0
  75. mlebench/competitions/feedback-prize-english-language-learning/grade.py +60 -0
  76. mlebench/competitions/feedback-prize-english-language-learning/prepare.py +39 -0
  77. mlebench/competitions/freesound-audio-tagging-2019/grade.py +64 -0
  78. mlebench/competitions/freesound-audio-tagging-2019/prepare.py +94 -0
  79. mlebench/competitions/freesound-audio-tagging-2019/prepare_val.py +175 -0
  80. mlebench/competitions/freesound-audio-tagging-2019/vocabulary.py +83 -0
  81. mlebench/competitions/google-quest-challenge/classes.py +32 -0
  82. mlebench/competitions/google-quest-challenge/grade.py +45 -0
  83. mlebench/competitions/google-quest-challenge/prepare.py +58 -0
  84. mlebench/competitions/google-quest-challenge/prepare_val.py +120 -0
  85. mlebench/competitions/google-research-identify-contrails-reduce-global-warming/grade.py +77 -0
  86. mlebench/competitions/google-research-identify-contrails-reduce-global-warming/prepare.py +155 -0
  87. mlebench/competitions/google-research-identify-contrails-reduce-global-warming/prepare_val.py +211 -0
  88. mlebench/competitions/h-and-m-personalized-fashion-recommendations/grade.py +42 -0
  89. mlebench/competitions/h-and-m-personalized-fashion-recommendations/prepare.py +102 -0
  90. mlebench/competitions/h-and-m-personalized-fashion-recommendations/prepare_val.py +132 -0
  91. mlebench/competitions/handwriting/grade.py +23 -0
  92. mlebench/competitions/handwriting/prepare.py +179 -0
  93. mlebench/competitions/herbarium-2020-fgvc7/grade.py +34 -0
  94. mlebench/competitions/herbarium-2020-fgvc7/prepare.py +251 -0
  95. mlebench/competitions/herbarium-2020-fgvc7/prepare_val.py +242 -0
  96. mlebench/competitions/herbarium-2021-fgvc8/grade.py +34 -0
  97. mlebench/competitions/herbarium-2021-fgvc8/prepare.py +251 -0
  98. mlebench/competitions/herbarium-2021-fgvc8/prepare_val.py +222 -0
  99. mlebench/competitions/herbarium-2022-fgvc9/grade.py +31 -0
  100. mlebench/competitions/herbarium-2022-fgvc9/prepare.py +233 -0
  101. mlebench/competitions/herbarium-2022-fgvc9/prepare_val.py +213 -0
  102. mlebench/competitions/histopathologic-cancer-detection/grade.py +12 -0
  103. mlebench/competitions/histopathologic-cancer-detection/prepare.py +59 -0
  104. mlebench/competitions/histopathologic-cancer-detection/prepare_val.py +131 -0
  105. mlebench/competitions/hms-harmful-brain-activity-classification/constants.py +9 -0
  106. mlebench/competitions/hms-harmful-brain-activity-classification/grade.py +43 -0
  107. mlebench/competitions/hms-harmful-brain-activity-classification/kaggle_metric_utilities.py +96 -0
  108. mlebench/competitions/hms-harmful-brain-activity-classification/kullback_leibler_divergence.py +118 -0
  109. mlebench/competitions/hms-harmful-brain-activity-classification/prepare.py +121 -0
  110. mlebench/competitions/hms-harmful-brain-activity-classification/prepare_val.py +190 -0
  111. mlebench/competitions/hotel-id-2021-fgvc8/grade.py +41 -0
  112. mlebench/competitions/hotel-id-2021-fgvc8/prepare.py +63 -0
  113. mlebench/competitions/hotel-id-2021-fgvc8/prepare_val.py +132 -0
  114. mlebench/competitions/hubmap-kidney-segmentation/grade.py +62 -0
  115. mlebench/competitions/hubmap-kidney-segmentation/prepare.py +108 -0
  116. mlebench/competitions/hubmap-kidney-segmentation/prepare_val.py +153 -0
  117. mlebench/competitions/icecube-neutrinos-in-deep-ice/grade.py +111 -0
  118. mlebench/competitions/icecube-neutrinos-in-deep-ice/prepare.py +127 -0
  119. mlebench/competitions/icecube-neutrinos-in-deep-ice/prepare_val.py +183 -0
  120. mlebench/competitions/ili/grade.py +60 -0
  121. mlebench/competitions/ili/prepare.py +99 -0
  122. mlebench/competitions/imet-2020-fgvc7/grade.py +54 -0
  123. mlebench/competitions/imet-2020-fgvc7/prepare.py +77 -0
  124. mlebench/competitions/imet-2020-fgvc7/prepare_val.py +157 -0
  125. mlebench/competitions/inaturalist-2019-fgvc6/grade.py +35 -0
  126. mlebench/competitions/inaturalist-2019-fgvc6/prepare.py +259 -0
  127. mlebench/competitions/inaturalist-2019-fgvc6/prepare_val.py +304 -0
  128. mlebench/competitions/instant-gratification/__init__.py +0 -0
  129. mlebench/competitions/instant-gratification/grade.py +55 -0
  130. mlebench/competitions/instant-gratification/prepare.py +25 -0
  131. mlebench/competitions/instant_gratification/__init__.py +0 -0
  132. mlebench/competitions/instant_gratification/grade.py +55 -0
  133. mlebench/competitions/instant_gratification/prepare.py +25 -0
  134. mlebench/competitions/invasive-species-monitoring/grade.py +11 -0
  135. mlebench/competitions/invasive-species-monitoring/prepare.py +97 -0
  136. mlebench/competitions/invasive-species-monitoring/prepare_val.py +164 -0
  137. mlebench/competitions/iwildcam-2019-fgvc6/grade.py +44 -0
  138. mlebench/competitions/iwildcam-2019-fgvc6/prepare.py +118 -0
  139. mlebench/competitions/iwildcam-2019-fgvc6/prepare_val.py +194 -0
  140. mlebench/competitions/iwildcam-2020-fgvc7/grade.py +11 -0
  141. mlebench/competitions/iwildcam-2020-fgvc7/prepare.py +164 -0
  142. mlebench/competitions/iwildcam-2020-fgvc7/prepare_val.py +245 -0
  143. mlebench/competitions/jigsaw-toxic-comment-classification-challenge/classes.py +1 -0
  144. mlebench/competitions/jigsaw-toxic-comment-classification-challenge/grade.py +54 -0
  145. mlebench/competitions/jigsaw-toxic-comment-classification-challenge/prepare.py +42 -0
  146. mlebench/competitions/jigsaw-toxic-comment-classification-challenge/prepare_val.py +88 -0
  147. mlebench/competitions/jigsaw-unintended-bias-in-toxicity-classification/grade.py +153 -0
  148. mlebench/competitions/jigsaw-unintended-bias-in-toxicity-classification/prepare.py +36 -0
  149. mlebench/competitions/jigsaw-unintended-bias-in-toxicity-classification/prepare_val.py +117 -0
  150. mlebench/competitions/kuzushiji-recognition/grade.py +58 -0
  151. mlebench/competitions/kuzushiji-recognition/kuzushiji_metric.py +118 -0
  152. mlebench/competitions/kuzushiji-recognition/prepare.py +92 -0
  153. mlebench/competitions/kuzushiji-recognition/prepare_val.py +149 -0
  154. mlebench/competitions/leaf-classification/classes.py +101 -0
  155. mlebench/competitions/leaf-classification/grade.py +44 -0
  156. mlebench/competitions/leaf-classification/prepare.py +60 -0
  157. mlebench/competitions/leaf-classification/prepare_val.py +116 -0
  158. mlebench/competitions/learning-agency-lab-automated-essay-scoring-2/grade.py +44 -0
  159. mlebench/competitions/learning-agency-lab-automated-essay-scoring-2/prepare.py +51 -0
  160. mlebench/competitions/learning-agency-lab-automated-essay-scoring-2/prepare_val.py +96 -0
  161. mlebench/competitions/liverpool-ion-switching/__init__.py +0 -0
  162. mlebench/competitions/liverpool-ion-switching/grade.py +52 -0
  163. mlebench/competitions/liverpool-ion-switching/prepare.py +27 -0
  164. mlebench/competitions/liverpool_ion_switching/__init__.py +0 -0
  165. mlebench/competitions/liverpool_ion_switching/grade.py +52 -0
  166. mlebench/competitions/liverpool_ion_switching/prepare.py +27 -0
  167. mlebench/competitions/lmsys-chatbot-arena/grade.py +63 -0
  168. mlebench/competitions/lmsys-chatbot-arena/prepare.py +52 -0
  169. mlebench/competitions/lmsys-chatbot-arena/prepare_val.py +115 -0
  170. mlebench/competitions/mcm_2024_c_test/grade.py +107 -0
  171. mlebench/competitions/mcm_2024_c_test/prepare.py +2 -0
  172. mlebench/competitions/ml2021spring-hw2/grade.py +11 -0
  173. mlebench/competitions/ml2021spring-hw2/prepare.py +58 -0
  174. mlebench/competitions/ml2021spring-hw2/prepare_val.py +135 -0
  175. mlebench/competitions/mlsp-2013-birds/grade.py +11 -0
  176. mlebench/competitions/mlsp-2013-birds/prepare.py +182 -0
  177. mlebench/competitions/mlsp-2013-birds/prepare_val.py +241 -0
  178. mlebench/competitions/movie-review-sentiment-analysis-kernels-only/grade.py +11 -0
  179. mlebench/competitions/movie-review-sentiment-analysis-kernels-only/prepare.py +58 -0
  180. mlebench/competitions/movie-review-sentiment-analysis-kernels-only/prepare_val.py +120 -0
  181. mlebench/competitions/multi-modal-gesture-recognition/grade.py +58 -0
  182. mlebench/competitions/multi-modal-gesture-recognition/prepare.py +85 -0
  183. mlebench/competitions/multi-modal-gesture-recognition/prepare_val.py +139 -0
  184. mlebench/competitions/my-custom-task-01/prepare.py +2 -0
  185. mlebench/competitions/new-my-task-01/prepare.py +2 -0
  186. mlebench/competitions/new-my-task-03/grade.py +107 -0
  187. mlebench/competitions/new-my-task-03/prepare.py +2 -0
  188. mlebench/competitions/new-york-city-taxi-fare-prediction/grade.py +28 -0
  189. mlebench/competitions/new-york-city-taxi-fare-prediction/prepare.py +44 -0
  190. mlebench/competitions/new-york-city-taxi-fare-prediction/prepare_val.py +89 -0
  191. mlebench/competitions/nfl-player-contact-detection/grade.py +36 -0
  192. mlebench/competitions/nfl-player-contact-detection/prepare.py +101 -0
  193. mlebench/competitions/nfl-player-contact-detection/prepare_val.py +186 -0
  194. mlebench/competitions/nomad2018-predict-transparent-conductors/grade.py +47 -0
  195. mlebench/competitions/nomad2018-predict-transparent-conductors/prepare.py +77 -0
  196. mlebench/competitions/nomad2018-predict-transparent-conductors/prepare_val.py +144 -0
  197. mlebench/competitions/osic-pulmonary-fibrosis-progression/grade.py +74 -0
  198. mlebench/competitions/osic-pulmonary-fibrosis-progression/prepare.py +95 -0
  199. mlebench/competitions/osic-pulmonary-fibrosis-progression/prepare_val.py +167 -0
  200. mlebench/competitions/paddy-disease-classification/grade.py +35 -0
  201. mlebench/competitions/paddy-disease-classification/prepare.py +69 -0
  202. mlebench/competitions/paddy-disease-classification/prepare_val.py +122 -0
  203. mlebench/competitions/petfinder-pawpularity-score/grade.py +41 -0
  204. mlebench/competitions/petfinder-pawpularity-score/prepare.py +76 -0
  205. mlebench/competitions/petfinder-pawpularity-score/prepare_val.py +154 -0
  206. mlebench/competitions/plant-pathology-2020-fgvc7/grade.py +41 -0
  207. mlebench/competitions/plant-pathology-2020-fgvc7/prepare.py +74 -0
  208. mlebench/competitions/plant-pathology-2020-fgvc7/prepare_val.py +160 -0
  209. mlebench/competitions/plant-pathology-2021-fgvc8/grade.py +54 -0
  210. mlebench/competitions/plant-pathology-2021-fgvc8/prepare.py +65 -0
  211. mlebench/competitions/plant-pathology-2021-fgvc8/prepare_val.py +130 -0
  212. mlebench/competitions/plant-seedlings-classification/grade.py +39 -0
  213. mlebench/competitions/plant-seedlings-classification/prepare.py +91 -0
  214. mlebench/competitions/plant-seedlings-classification/prepare_val.py +158 -0
  215. mlebench/competitions/playground-series-s3e1/__init__.py +0 -0
  216. mlebench/competitions/playground-series-s3e1/grade.py +52 -0
  217. mlebench/competitions/playground-series-s3e1/prepare.py +25 -0
  218. mlebench/competitions/playground-series-s3e11/__init__.py +0 -0
  219. mlebench/competitions/playground-series-s3e11/grade.py +55 -0
  220. mlebench/competitions/playground-series-s3e11/prepare.py +25 -0
  221. mlebench/competitions/playground-series-s3e18/grade.py +39 -0
  222. mlebench/competitions/playground-series-s3e18/prepare.py +36 -0
  223. mlebench/competitions/playground-series-s3e18/prepare_val.py +89 -0
  224. mlebench/competitions/playground_series_s3e1/__init__.py +0 -0
  225. mlebench/competitions/playground_series_s3e1/grade.py +52 -0
  226. mlebench/competitions/playground_series_s3e1/prepare.py +25 -0
  227. mlebench/competitions/playground_series_s3e11/__init__.py +0 -0
  228. mlebench/competitions/playground_series_s3e11/grade.py +55 -0
  229. mlebench/competitions/playground_series_s3e11/prepare.py +25 -0
  230. mlebench/competitions/predict-volcanic-eruptions-ingv-oe/grade.py +44 -0
  231. mlebench/competitions/predict-volcanic-eruptions-ingv-oe/prepare.py +68 -0
  232. mlebench/competitions/predict-volcanic-eruptions-ingv-oe/prepare_val.py +146 -0
  233. mlebench/competitions/random-acts-of-pizza/grade.py +14 -0
  234. mlebench/competitions/random-acts-of-pizza/prepare.py +80 -0
  235. mlebench/competitions/random-acts-of-pizza/prepare_val.py +144 -0
  236. mlebench/competitions/ranzcr-clip-catheter-line-classification/classes.py +11 -0
  237. mlebench/competitions/ranzcr-clip-catheter-line-classification/grade.py +31 -0
  238. mlebench/competitions/ranzcr-clip-catheter-line-classification/prepare.py +53 -0
  239. mlebench/competitions/ranzcr-clip-catheter-line-classification/prepare_val.py +113 -0
  240. mlebench/competitions/rsna-2022-cervical-spine-fracture-detection/grade.py +124 -0
  241. mlebench/competitions/rsna-2022-cervical-spine-fracture-detection/prepare.py +219 -0
  242. mlebench/competitions/rsna-2022-cervical-spine-fracture-detection/prepare_val.py +257 -0
  243. mlebench/competitions/rsna-breast-cancer-detection/grade.py +65 -0
  244. mlebench/competitions/rsna-breast-cancer-detection/prepare.py +141 -0
  245. mlebench/competitions/rsna-breast-cancer-detection/prepare_val.py +201 -0
  246. mlebench/competitions/rsna-miccai-brain-tumor-radiogenomic-classification/grade.py +13 -0
  247. mlebench/competitions/rsna-miccai-brain-tumor-radiogenomic-classification/prepare.py +47 -0
  248. mlebench/competitions/rsna-miccai-brain-tumor-radiogenomic-classification/prepare_val.py +97 -0
  249. mlebench/competitions/santander-customer-satisfaction/grade.py +10 -0
  250. mlebench/competitions/santander-customer-satisfaction/prepare.py +41 -0
  251. mlebench/competitions/sciencebench-001-clintox-nn/__init__.py +0 -0
  252. mlebench/competitions/sciencebench-001-clintox-nn/grade.py +56 -0
  253. mlebench/competitions/sciencebench-001-clintox-nn/prepare.py +75 -0
  254. mlebench/competitions/sciencebench-015-aai/grade.py +37 -0
  255. mlebench/competitions/sciencebench-015-aai/prepare.py +102 -0
  256. mlebench/competitions/sciencebench-051-brain-blood-qsar/grade.py +58 -0
  257. mlebench/competitions/sciencebench-051-brain-blood-qsar/prepare.py +69 -0
  258. mlebench/competitions/sciencebench-101-experimental-band-gap-prediction/grade.py +55 -0
  259. mlebench/competitions/sciencebench-101-experimental-band-gap-prediction/prepare.py +88 -0
  260. mlebench/competitions/see-click-predict-fix/__init__.py +0 -0
  261. mlebench/competitions/see-click-predict-fix/grade.py +66 -0
  262. mlebench/competitions/see-click-predict-fix/prepare.py +25 -0
  263. mlebench/competitions/see_click_predict_fix/__init__.py +0 -0
  264. mlebench/competitions/see_click_predict_fix/grade.py +66 -0
  265. mlebench/competitions/see_click_predict_fix/prepare.py +25 -0
  266. mlebench/competitions/seti-breakthrough-listen/grade.py +11 -0
  267. mlebench/competitions/seti-breakthrough-listen/prepare.py +71 -0
  268. mlebench/competitions/seti-breakthrough-listen/prepare_val.py +159 -0
  269. mlebench/competitions/siim-covid19-detection/grade.py +194 -0
  270. mlebench/competitions/siim-covid19-detection/prepare.py +123 -0
  271. mlebench/competitions/siim-covid19-detection/prepare_val.py +164 -0
  272. mlebench/competitions/siim-isic-melanoma-classification/grade.py +11 -0
  273. mlebench/competitions/siim-isic-melanoma-classification/prepare.py +127 -0
  274. mlebench/competitions/siim-isic-melanoma-classification/prepare_val.py +158 -0
  275. mlebench/competitions/smartphone-decimeter-2022/grade.py +55 -0
  276. mlebench/competitions/smartphone-decimeter-2022/notebook.py +86 -0
  277. mlebench/competitions/smartphone-decimeter-2022/prepare.py +143 -0
  278. mlebench/competitions/smartphone-decimeter-2022/prepare_val.py +199 -0
  279. mlebench/competitions/spaceship-titanic/grade.py +11 -0
  280. mlebench/competitions/spaceship-titanic/prepare.py +23 -0
  281. mlebench/competitions/spaceship-titanic/prepare_val.py +61 -0
  282. mlebench/competitions/spooky-author-identification/classes.py +1 -0
  283. mlebench/competitions/spooky-author-identification/grade.py +38 -0
  284. mlebench/competitions/spooky-author-identification/prepare.py +40 -0
  285. mlebench/competitions/spooky-author-identification/prepare_val.py +78 -0
  286. mlebench/competitions/stanford-covid-vaccine/grade.py +65 -0
  287. mlebench/competitions/stanford-covid-vaccine/prepare.py +129 -0
  288. mlebench/competitions/stanford-covid-vaccine/prepare_val.py +199 -0
  289. mlebench/competitions/statoil-iceberg-classifier-challenge/grade.py +41 -0
  290. mlebench/competitions/statoil-iceberg-classifier-challenge/prepare.py +105 -0
  291. mlebench/competitions/statoil-iceberg-classifier-challenge/prepare_val.py +157 -0
  292. mlebench/competitions/tabular-playground-series-dec-2021/grade.py +11 -0
  293. mlebench/competitions/tabular-playground-series-dec-2021/prepare.py +39 -0
  294. mlebench/competitions/tabular-playground-series-dec-2021/prepare_val.py +99 -0
  295. mlebench/competitions/tabular-playground-series-may-2022/grade.py +9 -0
  296. mlebench/competitions/tabular-playground-series-may-2022/prepare.py +56 -0
  297. mlebench/competitions/tabular-playground-series-may-2022/prepare_val.py +116 -0
  298. mlebench/competitions/tensorflow-speech-recognition-challenge/grade.py +11 -0
  299. mlebench/competitions/tensorflow-speech-recognition-challenge/prepare.py +90 -0
  300. mlebench/competitions/tensorflow-speech-recognition-challenge/prepare_val.py +148 -0
  301. mlebench/competitions/tensorflow2-question-answering/grade.py +122 -0
  302. mlebench/competitions/tensorflow2-question-answering/prepare.py +122 -0
  303. mlebench/competitions/tensorflow2-question-answering/prepare_val.py +187 -0
  304. mlebench/competitions/text-normalization-challenge-english-language/grade.py +49 -0
  305. mlebench/competitions/text-normalization-challenge-english-language/prepare.py +115 -0
  306. mlebench/competitions/text-normalization-challenge-english-language/prepare_val.py +213 -0
  307. mlebench/competitions/text-normalization-challenge-russian-language/grade.py +49 -0
  308. mlebench/competitions/text-normalization-challenge-russian-language/prepare.py +113 -0
  309. mlebench/competitions/text-normalization-challenge-russian-language/prepare_val.py +165 -0
  310. mlebench/competitions/tgs-salt-identification-challenge/grade.py +144 -0
  311. mlebench/competitions/tgs-salt-identification-challenge/prepare.py +158 -0
  312. mlebench/competitions/tgs-salt-identification-challenge/prepare_val.py +166 -0
  313. mlebench/competitions/the-icml-2013-whale-challenge-right-whale-redux/grade.py +11 -0
  314. mlebench/competitions/the-icml-2013-whale-challenge-right-whale-redux/prepare.py +95 -0
  315. mlebench/competitions/the-icml-2013-whale-challenge-right-whale-redux/prepare_val.py +141 -0
  316. mlebench/competitions/tmdb-box-office-prediction/__init__.py +0 -0
  317. mlebench/competitions/tmdb-box-office-prediction/grade.py +55 -0
  318. mlebench/competitions/tmdb-box-office-prediction/prepare.py +35 -0
  319. mlebench/competitions/tweet-sentiment-extraction/grade.py +67 -0
  320. mlebench/competitions/tweet-sentiment-extraction/prepare.py +36 -0
  321. mlebench/competitions/tweet-sentiment-extraction/prepare_val.py +106 -0
  322. mlebench/competitions/us-patent-phrase-to-phrase-matching/grade.py +31 -0
  323. mlebench/competitions/us-patent-phrase-to-phrase-matching/prepare.py +33 -0
  324. mlebench/competitions/us-patent-phrase-to-phrase-matching/prepare_val.py +71 -0
  325. mlebench/competitions/utils.py +266 -0
  326. mlebench/competitions/uw-madison-gi-tract-image-segmentation/grade.py +158 -0
  327. mlebench/competitions/uw-madison-gi-tract-image-segmentation/prepare.py +139 -0
  328. mlebench/competitions/uw-madison-gi-tract-image-segmentation/prepare_val.py +193 -0
  329. mlebench/competitions/ventilator-pressure-prediction/__init__.py +0 -0
  330. mlebench/competitions/ventilator-pressure-prediction/grade.py +52 -0
  331. mlebench/competitions/ventilator-pressure-prediction/prepare.py +27 -0
  332. mlebench/competitions/ventilator-pressure-prediction/prepare_val.py +142 -0
  333. mlebench/competitions/ventilator_pressure_prediction/__init__.py +0 -0
  334. mlebench/competitions/ventilator_pressure_prediction/grade.py +52 -0
  335. mlebench/competitions/ventilator_pressure_prediction/prepare.py +27 -0
  336. mlebench/competitions/vesuvius-challenge-ink-detection/grade.py +97 -0
  337. mlebench/competitions/vesuvius-challenge-ink-detection/prepare.py +122 -0
  338. mlebench/competitions/vesuvius-challenge-ink-detection/prepare_val.py +170 -0
  339. mlebench/competitions/vinbigdata-chest-xray-abnormalities-detection/grade.py +220 -0
  340. mlebench/competitions/vinbigdata-chest-xray-abnormalities-detection/prepare.py +129 -0
  341. mlebench/competitions/vinbigdata-chest-xray-abnormalities-detection/prepare_val.py +204 -0
  342. mlebench/competitions/whale-categorization-playground/grade.py +41 -0
  343. mlebench/competitions/whale-categorization-playground/prepare.py +103 -0
  344. mlebench/competitions/whale-categorization-playground/prepare_val.py +196 -0
  345. mlebench/data.py +420 -0
  346. mlebench/grade.py +209 -0
  347. mlebench/grade_helpers.py +235 -0
  348. mlebench/metrics.py +75 -0
  349. mlebench/registry.py +332 -0
  350. mlebench/utils.py +346 -0
  351. {dslighting-1.7.1.dist-info → dslighting-1.7.8.dist-info}/WHEEL +0 -0
  352. {dslighting-1.7.1.dist-info → dslighting-1.7.8.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,89 @@
1
+ from pathlib import Path
2
+ import pandas as pd
3
+
4
+ from sklearn.model_selection import train_test_split
5
+
6
+ from mlebench.utils import read_csv
7
+
8
+
9
+ def _save_split_files(train_df: pd.DataFrame, test_df: pd.DataFrame, public_dir: Path, private_dir: Path):
10
+ """
11
+ Saves the train/test splits to the specified public and private directories,
12
+ ensuring a consistent file structure and content format.
13
+
14
+ - Creates a sample submission file in public_dir.
15
+ - Saves the full test set (with labels) to private_dir.
16
+ - Saves the train set to public_dir.
17
+ - Saves the test set (without labels) to public_dir.
18
+ """
19
+ # Ensure output directories exist
20
+ public_dir.mkdir(parents=True, exist_ok=True)
21
+ private_dir.mkdir(parents=True, exist_ok=True)
22
+
23
+ # Create sample submission from a copy of the full test set
24
+ sample_submission = test_df.copy()
25
+ sample_submission["EC1"] = 0.5
26
+ sample_submission["EC2"] = 0.5
27
+ sample_submission.drop(
28
+ sample_submission.columns.difference(["id", "EC1", "EC2"]), axis=1, inplace=True
29
+ )
30
+ sample_submission.to_csv(public_dir / "sample_submission.csv", index=False)
31
+
32
+ # Create private files (full test set with labels)
33
+ test_df.to_csv(private_dir / "test.csv", index=False)
34
+
35
+ # Create public files visible to agents
36
+ train_df.to_csv(public_dir / "train.csv", index=False)
37
+
38
+ # Create public test set (without labels) from a new copy
39
+ public_test_df = test_df.copy()
40
+ public_test_df.drop(["EC1", "EC2", "EC3", "EC4", "EC5", "EC6"], axis=1, inplace=True)
41
+ public_test_df.to_csv(public_dir / "test.csv", index=False)
42
+
43
+
44
+ def prepare(raw: Path, public: Path, private: Path):
45
+ # Read the raw data
46
+ old_train = read_csv(raw / "train.csv")
47
+
48
+ # --- Step 1: Create the original train/test split ---
49
+ # This split is used for the main competition leaderboard. Its outputs
50
+ # in `public/` and `private/` must remain identical to the original script.
51
+ original_test_size = 0.1
52
+ new_train, new_test = train_test_split(
53
+ old_train, test_size=original_test_size, random_state=0
54
+ )
55
+
56
+ # Save the files for the original split, ensuring original outputs are unchanged
57
+ _save_split_files(new_train, new_test, public, private)
58
+
59
+ # --- Step 2: Create the new validation split ---
60
+ # This second split is derived from the *training data* of the first split.
61
+ # It creates a smaller training set and a validation set for users,
62
+ # saved to parallel `public_val/` and `private_val/` directories.
63
+
64
+ # Define paths for the new validation split outputs
65
+ public_val = public.parent / "public_val"
66
+ private_val = private.parent / "private_val"
67
+
68
+ # To keep the new validation set size (`test_val`) the same as the original
69
+ # test set size (`new_test`), we adjust the split ratio.
70
+ # test_val_size = original_test_size / (1 - original_test_size)
71
+ val_split_test_size = original_test_size / (1.0 - original_test_size)
72
+
73
+ # Create the new training and validation sets from the first-pass training data
74
+ train_val, test_val = train_test_split(
75
+ new_train, test_size=val_split_test_size, random_state=0
76
+ )
77
+
78
+ # Save the files for the new validation split using the same helper.
79
+ # This guarantees the file/directory structure is mirrored.
80
+ _save_split_files(train_val, test_val, public_val, private_val)
81
+
82
+ # Original checks (adapted slightly for clarity after refactoring)
83
+ public_test_df = read_csv(public / "test.csv")
84
+ public_train_df = read_csv(public / "train.csv")
85
+ assert public_test_df.shape[1] == 32, "Public test set should have 32 columns"
86
+ assert public_train_df.shape[1] == 38, "Public train set should have 38 columns"
87
+ assert len(public_train_df) + len(public_test_df) == len(
88
+ old_train
89
+ ), "Length of new_train and new_test should equal length of old_train"
@@ -0,0 +1,52 @@
1
+ import numpy as np
2
+ import pandas as pd
3
+ from sklearn.metrics import mean_squared_error
4
+
5
+ from mlebench.grade_helpers import InvalidSubmissionError
6
+
7
+
8
+ def prepare_for_metric(submission: pd.DataFrame, answers: pd.DataFrame):
9
+ """Prepare submission and answers for RMSE calculation."""
10
+ if len(submission) != len(answers):
11
+ raise InvalidSubmissionError(
12
+ f"Submission length ({len(submission)}) != answers length ({len(answers)})"
13
+ )
14
+
15
+ if "id" not in submission.columns:
16
+ raise InvalidSubmissionError("Submission must have an 'id' column")
17
+
18
+ if "MedHouseVal" not in submission.columns:
19
+ raise InvalidSubmissionError("Submission must have a 'MedHouseVal' column")
20
+
21
+ # Sort by id
22
+ submission = submission.sort_values("id").reset_index(drop=True)
23
+ answers = answers.sort_values("id").reset_index(drop=True)
24
+
25
+ # Check id alignment
26
+ if not (submission["id"] == answers["id"]).all():
27
+ raise InvalidSubmissionError("Submission and answers id mismatch")
28
+
29
+ # Extract predictions and true values
30
+ y_pred = submission["MedHouseVal"].values
31
+ y_true = answers["MedHouseVal"].values
32
+
33
+ # Validate predictions
34
+ try:
35
+ y_pred = y_pred.astype(float)
36
+ except (ValueError, TypeError):
37
+ raise InvalidSubmissionError("Predictions must be numeric")
38
+
39
+ if np.any(np.isnan(y_pred)):
40
+ raise InvalidSubmissionError("Predictions cannot contain NaN values")
41
+
42
+ return y_true, y_pred
43
+
44
+
45
+ def grade(submission: pd.DataFrame, answers: pd.DataFrame) -> float:
46
+ """Calculate RMSE score."""
47
+ y_true, y_pred = prepare_for_metric(submission, answers)
48
+
49
+ # RMSE
50
+ rmse = np.sqrt(mean_squared_error(y_true, y_pred))
51
+
52
+ return rmse
@@ -0,0 +1,25 @@
1
+ from pathlib import Path
2
+ import pandas as pd
3
+
4
+
5
+ def prepare(raw: Path, public: Path, private: Path):
6
+ """
7
+ Prepare playground-series-s3e1 dataset.
8
+ """
9
+ # Read data
10
+ train = pd.read_csv(raw / "train.csv")
11
+ test = pd.read_csv(raw / "test.csv")
12
+ sample_submission = pd.read_csv(raw / "sample_submission.csv")
13
+ test_answer = pd.read_csv(raw / "test_answer.csv")
14
+
15
+ # Public files (visible to agents)
16
+ train.to_csv(public / "train.csv", index=False)
17
+ test.to_csv(public / "test.csv", index=False)
18
+ sample_submission.to_csv(public / "sample_submission.csv", index=False)
19
+
20
+ # Private files (for grading)
21
+ test_answer.to_csv(private / "test.csv", index=False)
22
+
23
+ # Validation checks
24
+ assert len(test_answer) == len(sample_submission), \
25
+ f"Test answer ({len(test_answer)}) and sample submission ({len(sample_submission)}) must have same length"
@@ -0,0 +1,55 @@
1
+ import numpy as np
2
+ import pandas as pd
3
+ from sklearn.metrics import mean_squared_log_error
4
+
5
+ from mlebench.grade_helpers import InvalidSubmissionError
6
+
7
+
8
+ def prepare_for_metric(submission: pd.DataFrame, answers: pd.DataFrame):
9
+ """Prepare submission and answers for RMSLE calculation."""
10
+ if len(submission) != len(answers):
11
+ raise InvalidSubmissionError(
12
+ f"Submission length ({len(submission)}) != answers length ({len(answers)})"
13
+ )
14
+
15
+ if "id" not in submission.columns:
16
+ raise InvalidSubmissionError("Submission must have an 'id' column")
17
+
18
+ if "cost" not in submission.columns:
19
+ raise InvalidSubmissionError("Submission must have a 'cost' column")
20
+
21
+ # Sort by id
22
+ submission = submission.sort_values("id").reset_index(drop=True)
23
+ answers = answers.sort_values("id").reset_index(drop=True)
24
+
25
+ # Check id alignment
26
+ if not (submission["id"] == answers["id"]).all():
27
+ raise InvalidSubmissionError("Submission and answers id mismatch")
28
+
29
+ # Extract predictions and true values
30
+ y_pred = submission["cost"].values
31
+ y_true = answers["cost"].values
32
+
33
+ # Validate predictions
34
+ try:
35
+ y_pred = y_pred.astype(float)
36
+ except (ValueError, TypeError):
37
+ raise InvalidSubmissionError("Predictions must be numeric")
38
+
39
+ if np.any(np.isnan(y_pred)):
40
+ raise InvalidSubmissionError("Predictions cannot contain NaN values")
41
+
42
+ if np.any(y_pred < 0):
43
+ raise InvalidSubmissionError("Predictions cannot be negative")
44
+
45
+ return y_true, y_pred
46
+
47
+
48
+ def grade(submission: pd.DataFrame, answers: pd.DataFrame) -> float:
49
+ """Calculate RMSLE score."""
50
+ y_true, y_pred = prepare_for_metric(submission, answers)
51
+
52
+ # RMSLE
53
+ rmsle = np.sqrt(mean_squared_log_error(y_true, y_pred))
54
+
55
+ return rmsle
@@ -0,0 +1,25 @@
1
+ from pathlib import Path
2
+ import pandas as pd
3
+
4
+
5
+ def prepare(raw: Path, public: Path, private: Path):
6
+ """
7
+ Prepare playground-series-s3e11 dataset.
8
+ """
9
+ # Read data
10
+ train = pd.read_csv(raw / "train.csv")
11
+ test = pd.read_csv(raw / "test.csv")
12
+ sample_submission = pd.read_csv(raw / "sample_submission.csv")
13
+ test_answer = pd.read_csv(raw / "test_answer.csv")
14
+
15
+ # Public files (visible to agents)
16
+ train.to_csv(public / "train.csv", index=False)
17
+ test.to_csv(public / "test.csv", index=False)
18
+ sample_submission.to_csv(public / "sample_submission.csv", index=False)
19
+
20
+ # Private files (for grading)
21
+ test_answer.to_csv(private / "test.csv", index=False)
22
+
23
+ # Validation checks
24
+ assert len(test_answer) == len(sample_submission), \
25
+ f"Test answer ({len(test_answer)}) and sample submission ({len(sample_submission)}) must have same length"
@@ -0,0 +1,44 @@
1
+ from pandas import DataFrame
2
+ from sklearn.metrics import mean_absolute_error
3
+
4
+ from mlebench.grade_helpers import InvalidSubmissionError
5
+
6
+
7
+ def prepare_for_grading(submission: DataFrame, answers: DataFrame, target_column: str) -> DataFrame:
8
+ """
9
+ Merge the submission's target_column into the answers DataFrame, matching on 'segment_id'.
10
+ target_column from the submission DataFrame will have the suffix '_pred',
11
+ and target_column from the answers DataFrame will have the suffix '_true'.
12
+ """
13
+
14
+ # Answers checks
15
+ assert (
16
+ target_column in answers.columns
17
+ ), f"Target column {target_column} not found in answers DataFrame."
18
+ assert "segment_id" in answers.columns, "Segment ID column not found in answers DataFrame."
19
+
20
+ # Submission checks
21
+ if target_column not in submission.columns:
22
+ raise InvalidSubmissionError(
23
+ f"Target column {target_column} not found in submissions DataFrame."
24
+ )
25
+ if "segment_id" not in submission.columns:
26
+ raise InvalidSubmissionError("Segment ID column not found in submission DataFrame.")
27
+ if not set(submission["segment_id"]) == set(answers["segment_id"]):
28
+ raise InvalidSubmissionError(
29
+ f"Submission is missing the following segment_ids: {set(answers['segment_id']) - set(submission['segment_id'])}"
30
+ )
31
+
32
+ merged = answers.merge(
33
+ submission[["segment_id", target_column]], on="segment_id", suffixes=("_true", "_pred")
34
+ )
35
+ return merged
36
+
37
+
38
+ def grade(submission: DataFrame, answers: DataFrame) -> float:
39
+ merged = prepare_for_grading(submission, answers, "time_to_eruption")
40
+ score = mean_absolute_error(
41
+ y_true=merged["time_to_eruption_true"], y_pred=merged["time_to_eruption_pred"]
42
+ )
43
+ rounded_score = int(round(score))
44
+ return rounded_score
@@ -0,0 +1,68 @@
1
+ import shutil
2
+ from pathlib import Path
3
+
4
+ from sklearn.model_selection import train_test_split
5
+ from tqdm import tqdm
6
+
7
+ from mlebench.utils import read_csv
8
+
9
+
10
+ def prepare(raw: Path, public: Path, private: Path):
11
+
12
+ # Create train, test from train split
13
+ old_train = read_csv(raw / "train.csv")
14
+ new_train, answers = train_test_split(old_train, test_size=0.1, random_state=0)
15
+
16
+ # Create sample submission
17
+ submission_df = answers.copy()
18
+ submission_df["time_to_eruption"] = 0
19
+
20
+ # Checks
21
+ assert len(answers) == len(submission_df), "Answers and submission should have the same length"
22
+ assert not any(
23
+ new_train["segment_id"].isin(answers["segment_id"])
24
+ ), "No segment_id should be in both train and answers"
25
+ assert list(new_train.columns) == [
26
+ "segment_id",
27
+ "time_to_eruption",
28
+ ], "new_train should have columns 'segment_id' and 'time_to_eruption'"
29
+ assert list(submission_df.columns) == [
30
+ "segment_id",
31
+ "time_to_eruption",
32
+ ], "submission_df should have columns 'segment_id' and 'time_to_eruption'"
33
+ assert list(answers.columns) == [
34
+ "segment_id",
35
+ "time_to_eruption",
36
+ ], "answers should have columns 'segment_id' and 'time_to_eruption'"
37
+ assert len(new_train) + len(answers) == len(
38
+ old_train
39
+ ), "The sum of the length of new_train and answers should be equal to the length of old_train"
40
+
41
+ # Write CSVs
42
+ answers.to_csv(private / "test.csv", index=False)
43
+ new_train.to_csv(public / "train.csv", index=False)
44
+ submission_df.to_csv(public / "sample_submission.csv", index=False)
45
+
46
+ # Copy over files
47
+ (public / "test").mkdir(exist_ok=True)
48
+ (public / "train").mkdir(exist_ok=True)
49
+
50
+ for file_id in tqdm(new_train["segment_id"], desc="Copying train files"):
51
+ shutil.copyfile(
52
+ src=raw / "train" / f"{file_id}.csv",
53
+ dst=public / "train" / f"{file_id}.csv",
54
+ )
55
+
56
+ for file_id in tqdm(answers["segment_id"], desc="Copying test files"):
57
+ shutil.copyfile(
58
+ src=raw / "train" / f"{file_id}.csv",
59
+ dst=public / "test" / f"{file_id}.csv",
60
+ )
61
+
62
+ # Checks on files
63
+ assert len(list(public.glob("train/*.csv"))) == len(
64
+ new_train
65
+ ), "Public train should have the same number of files as new_train"
66
+ assert len(list(public.glob("test/*.csv"))) == len(
67
+ answers
68
+ ), "Public test should have the same number of files as answers"
@@ -0,0 +1,146 @@
1
+ import shutil
2
+ from pathlib import Path
3
+ from typing import Tuple
4
+
5
+ import pandas as pd
6
+ from sklearn.model_selection import train_test_split
7
+ from tqdm import tqdm
8
+
9
+ from mlebench.utils import read_csv
10
+
11
+
12
+ def _create_split(
13
+ source_df: pd.DataFrame,
14
+ public_path: Path,
15
+ private_path: Path,
16
+ raw_files_dir: Path,
17
+ test_size: float,
18
+ random_state: int,
19
+ ) -> Tuple[pd.DataFrame, pd.DataFrame]:
20
+ """
21
+ Splits a dataframe into train and test sets, and creates the corresponding
22
+ directory structure with data files and labels.
23
+
24
+ Args:
25
+ source_df: The dataframe to split.
26
+ public_path: The path to the public output directory.
27
+ private_path: The path to the private output directory (for test labels).
28
+ raw_files_dir: The path to the directory containing the raw data files.
29
+ test_size: The proportion of the dataset to allocate to the test split.
30
+ random_state: The seed for the random number generator.
31
+
32
+ Returns:
33
+ A tuple containing the new training dataframe and the answers dataframe.
34
+ """
35
+ # Ensure output directories exist
36
+ public_path.mkdir(parents=True, exist_ok=True)
37
+ private_path.mkdir(parents=True, exist_ok=True)
38
+
39
+ # Create train, test from the source dataframe
40
+ new_train, answers = train_test_split(
41
+ source_df, test_size=test_size, random_state=random_state
42
+ )
43
+
44
+ # Create sample submission
45
+ submission_df = answers.copy()
46
+ submission_df["time_to_eruption"] = 0
47
+
48
+ # Checks
49
+ assert len(answers) == len(submission_df), "Answers and submission should have the same length"
50
+ assert not any(
51
+ new_train["segment_id"].isin(answers["segment_id"])
52
+ ), "No segment_id should be in both train and answers"
53
+ assert list(new_train.columns) == [
54
+ "segment_id",
55
+ "time_to_eruption",
56
+ ], "new_train should have columns 'segment_id' and 'time_to_eruption'"
57
+ assert list(submission_df.columns) == [
58
+ "segment_id",
59
+ "time_to_eruption",
60
+ ], "submission_df should have columns 'segment_id' and 'time_to_eruption'"
61
+ assert list(answers.columns) == [
62
+ "segment_id",
63
+ "time_to_eruption",
64
+ ], "answers should have columns 'segment_id' and 'time_to_eruption'"
65
+ assert len(new_train) + len(answers) == len(
66
+ source_df
67
+ ), "The sum of the length of new_train and answers should be equal to the length of source_df"
68
+
69
+ # Write CSVs
70
+ answers.to_csv(private_path / "test.csv", index=False)
71
+ new_train.to_csv(public_path / "train.csv", index=False)
72
+ submission_df.to_csv(public_path / "sample_submission.csv", index=False)
73
+
74
+ # Copy over files
75
+ (public_path / "test").mkdir(exist_ok=True)
76
+ (public_path / "train").mkdir(exist_ok=True)
77
+
78
+ for file_id in tqdm(new_train["segment_id"], desc=f"Copying train files to {public_path.name}"):
79
+ shutil.copyfile(
80
+ src=raw_files_dir / f"{file_id}.csv",
81
+ dst=public_path / "train" / f"{file_id}.csv",
82
+ )
83
+
84
+ for file_id in tqdm(answers["segment_id"], desc=f"Copying test files to {public_path.name}"):
85
+ shutil.copyfile(
86
+ src=raw_files_dir / f"{file_id}.csv",
87
+ dst=public_path / "test" / f"{file_id}.csv",
88
+ )
89
+
90
+ # Checks on files
91
+ assert len(list(public_path.glob("train/*.csv"))) == len(
92
+ new_train
93
+ ), f"Public train in {public_path.name} should have the same number of files as its train split"
94
+ assert len(list(public_path.glob("test/*.csv"))) == len(
95
+ answers
96
+ ), f"Public test in {public_path.name} should have the same number of files as its answer key"
97
+
98
+ return new_train, answers
99
+
100
+
101
+ def prepare(raw: Path, public: Path, private: Path):
102
+ """
103
+ Prepares the dataset by creating two splits:
104
+ 1. A standard train/test split for the main competition.
105
+ 2. A subsequent train/validation split for model development, created from
106
+ the training set of the first split.
107
+ """
108
+ RANDOM_STATE = 0
109
+ TEST_SIZE_ORIGINAL = 0.1
110
+
111
+ # Load the full raw training data manifest
112
+ original_train_df = read_csv(raw / "train.csv")
113
+ raw_files_dir = raw / "train"
114
+
115
+ # --- 1. Create the original train/test split for `public` and `private` ---
116
+ # This call produces the primary competition data. Its outputs must remain
117
+ # identical to those of the original script.
118
+ competition_train_df, competition_test_answers = _create_split(
119
+ source_df=original_train_df,
120
+ public_path=public,
121
+ private_path=private,
122
+ raw_files_dir=raw_files_dir,
123
+ test_size=TEST_SIZE_ORIGINAL,
124
+ random_state=RANDOM_STATE,
125
+ )
126
+
127
+ # --- 2. Create the new train/validation split for `public_val` and `private_val` ---
128
+ # This call creates a new split from the training data generated above.
129
+ # The new directories will mirror the structure of the originals.
130
+ public_val_path = public.parent / "public_val"
131
+ private_val_path = private.parent / "private_val"
132
+
133
+ # Calculate the test size for the second split to ensure the number of samples
134
+ # in the new validation set is the same as in the original test set.
135
+ validation_test_size = len(competition_test_answers) / len(competition_train_df)
136
+
137
+ # Create the new split using the same logic and random state.
138
+ # The source data is `competition_train_df`, the training set from the first split.
139
+ _create_split(
140
+ source_df=competition_train_df,
141
+ public_path=public_val_path,
142
+ private_path=private_val_path,
143
+ raw_files_dir=raw_files_dir,
144
+ test_size=validation_test_size,
145
+ random_state=RANDOM_STATE,
146
+ )
@@ -0,0 +1,14 @@
1
+ import pandas as pd
2
+ from sklearn.metrics import roc_auc_score
3
+
4
+ from mlebench.competitions.utils import prepare_for_auroc_metric
5
+
6
+
7
+ def grade(submission: pd.DataFrame, answers: pd.DataFrame) -> float:
8
+ roc_auc_inputs = prepare_for_auroc_metric(
9
+ submission=submission,
10
+ answers=answers,
11
+ id_col="request_id",
12
+ target_col="requester_received_pizza",
13
+ )
14
+ return roc_auc_score(y_true=roc_auc_inputs["y_true"], y_score=roc_auc_inputs["y_score"])
@@ -0,0 +1,80 @@
1
+ import json
2
+ import shutil
3
+ from pathlib import Path
4
+
5
+ import pandas as pd
6
+ from sklearn.model_selection import train_test_split
7
+
8
+
9
+ def prepare(raw: Path, public: Path, private: Path):
10
+ """
11
+ Splits the data in raw into public and private datasets with appropriate test/train splits.
12
+ """
13
+
14
+ # Load data
15
+ with open(raw / "train.json") as f:
16
+ old_train = json.load(f)
17
+ with open(raw / "test.json") as f:
18
+ old_test = json.load(f)
19
+
20
+ test_ratio = len(old_test) / (len(old_train) + len(old_test))
21
+
22
+ all_fields = list([key for key in old_train[0].keys()])
23
+ assert all(set(all_fields) == set([key for key in sample.keys()]) for sample in old_train)
24
+ test_fields = list([key for key in old_test[0].keys()])
25
+ assert all(set(test_fields) == set([key for key in sample.keys()]) for sample in old_test)
26
+
27
+ # Create train, test from train split
28
+ new_train, new_test = train_test_split(old_train, test_size=test_ratio, random_state=0)
29
+
30
+ new_test_without_labels = []
31
+ for sample in new_test:
32
+ # Keep only the fields in the test set
33
+ sample = {key: sample[key] for key in test_fields}
34
+ new_test_without_labels.append(sample)
35
+
36
+ # Save the new train and test splits
37
+ with open(public / "train.json", "w") as f:
38
+ json.dump(new_train, f, indent=4)
39
+ with open(public / "test.json", "w") as f:
40
+ json.dump(new_test_without_labels, f, indent=4)
41
+ # Also save zipped versions "train.json.zip" and "test.json.zip"
42
+ shutil.make_archive(public / "train", "zip", public, "train.json")
43
+ shutil.make_archive(public / "test", "zip", public, "test.json")
44
+
45
+ # Create answers
46
+ answers_rows = []
47
+ for sample in new_test:
48
+ answers_rows.append(
49
+ {
50
+ "request_id": sample["request_id"],
51
+ "requester_received_pizza": int(sample["requester_received_pizza"]),
52
+ }
53
+ )
54
+ answers = pd.DataFrame(answers_rows)
55
+ answers.to_csv(private / "test.csv", index=False)
56
+
57
+ # Create sample submission
58
+ sample_submission = answers.copy()
59
+ sample_submission["requester_received_pizza"] = 0
60
+ sample_submission.to_csv(public / "sampleSubmission.csv", index=False)
61
+
62
+ # Checks
63
+ assert len(new_train) + len(new_test) == len(
64
+ old_train
65
+ ), f"Expected {len(old_train)} total samples in new_train ({len(new_train)}) and new_test ({len(new_test)})"
66
+ assert len(new_test) == len(
67
+ new_test_without_labels
68
+ ), f"Expected new_test ({len(new_test)}) to have the same length as new_test_without_labels ({len(new_test_without_labels)})"
69
+ assert len(answers) == len(
70
+ new_test
71
+ ), f"Expected answers ({len(answers)}) to have the same length as new_test ({len(new_test)})"
72
+ assert len(sample_submission) == len(
73
+ new_test
74
+ ), f"Expected sample_submission ({len(sample_submission)}) to have the same length as new_test ({len(new_test)})"
75
+ assert set(answers.columns) == set(
76
+ ["request_id", "requester_received_pizza"]
77
+ ), "Answers must have 'request_id' and 'requester_received_pizza' columns"
78
+ assert set(sample_submission.columns) == set(
79
+ ["request_id", "requester_received_pizza"]
80
+ ), "Sample submission must have 'request_id' and 'requester_received_pizza' columns"