dslighting 1.7.1__py3-none-any.whl → 1.7.6__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.
- dslighting/__init__.py +1 -1
- dslighting/core/agent.py +78 -62
- {dslighting-1.7.1.dist-info → dslighting-1.7.6.dist-info}/METADATA +1 -1
- {dslighting-1.7.1.dist-info → dslighting-1.7.6.dist-info}/RECORD +352 -7
- {dslighting-1.7.1.dist-info → dslighting-1.7.6.dist-info}/top_level.txt +1 -0
- mlebench/README.md +39 -0
- mlebench/__init__.py +0 -0
- mlebench/cli.py +221 -0
- mlebench/competitions/3d-object-detection-for-autonomous-vehicles/grade.py +161 -0
- mlebench/competitions/3d-object-detection-for-autonomous-vehicles/mAP_evaluation.py +425 -0
- mlebench/competitions/3d-object-detection-for-autonomous-vehicles/prepare.py +483 -0
- mlebench/competitions/3d-object-detection-for-autonomous-vehicles/prepare_val.py +719 -0
- mlebench/competitions/AI4Code/grade.py +70 -0
- mlebench/competitions/AI4Code/prepare.py +84 -0
- mlebench/competitions/AI4Code/prepare_val.py +159 -0
- mlebench/competitions/__init__.py +0 -0
- mlebench/competitions/aerial-cactus-identification/grade.py +11 -0
- mlebench/competitions/aerial-cactus-identification/prepare.py +71 -0
- mlebench/competitions/aerial-cactus-identification/prepare_val.py +133 -0
- mlebench/competitions/alaska2-image-steganalysis/grade.py +136 -0
- mlebench/competitions/alaska2-image-steganalysis/prepare.py +88 -0
- mlebench/competitions/alaska2-image-steganalysis/prepare_val.py +148 -0
- mlebench/competitions/aptos2019-blindness-detection/grade.py +35 -0
- mlebench/competitions/aptos2019-blindness-detection/prepare.py +75 -0
- mlebench/competitions/aptos2019-blindness-detection/prepare_val.py +123 -0
- mlebench/competitions/bike-sharing-demand/__init__.py +0 -0
- mlebench/competitions/bike-sharing-demand/grade.py +55 -0
- mlebench/competitions/bike-sharing-demand/prepare.py +37 -0
- mlebench/competitions/billion-word-imputation/grade.py +37 -0
- mlebench/competitions/billion-word-imputation/prepare.py +107 -0
- mlebench/competitions/billion-word-imputation/prepare_val.py +179 -0
- mlebench/competitions/bms-molecular-translation/grade.py +40 -0
- mlebench/competitions/bms-molecular-translation/prepare.py +68 -0
- mlebench/competitions/bms-molecular-translation/prepare_val.py +131 -0
- mlebench/competitions/cassava-leaf-disease-classification/grade.py +12 -0
- mlebench/competitions/cassava-leaf-disease-classification/prepare.py +113 -0
- mlebench/competitions/cassava-leaf-disease-classification/prepare_val.py +186 -0
- mlebench/competitions/cdiscount-image-classification-challenge/grade.py +11 -0
- mlebench/competitions/cdiscount-image-classification-challenge/prepare.py +144 -0
- mlebench/competitions/cdiscount-image-classification-challenge/prepare_val.py +205 -0
- mlebench/competitions/chaii-hindi-and-tamil-question-answering/grade.py +67 -0
- mlebench/competitions/chaii-hindi-and-tamil-question-answering/prepare.py +31 -0
- mlebench/competitions/chaii-hindi-and-tamil-question-answering/prepare_val.py +94 -0
- mlebench/competitions/champs-scalar-coupling/grade.py +60 -0
- mlebench/competitions/champs-scalar-coupling/prepare.py +116 -0
- mlebench/competitions/champs-scalar-coupling/prepare_val.py +155 -0
- mlebench/competitions/conways-reverse-game-of-life-2020/__init__.py +0 -0
- mlebench/competitions/conways-reverse-game-of-life-2020/grade.py +40 -0
- mlebench/competitions/conways-reverse-game-of-life-2020/prepare.py +41 -0
- mlebench/competitions/demand-forecasting-kernels-only/__init__.py +0 -0
- mlebench/competitions/demand-forecasting-kernels-only/grade.py +66 -0
- mlebench/competitions/demand-forecasting-kernels-only/prepare.py +27 -0
- mlebench/competitions/demand_forecasting_kernels_only/__init__.py +0 -0
- mlebench/competitions/demand_forecasting_kernels_only/grade.py +66 -0
- mlebench/competitions/demand_forecasting_kernels_only/prepare.py +27 -0
- mlebench/competitions/denoising-dirty-documents/grade.py +44 -0
- mlebench/competitions/denoising-dirty-documents/prepare.py +134 -0
- mlebench/competitions/denoising-dirty-documents/prepare_val.py +178 -0
- mlebench/competitions/detecting-insults-in-social-commentary/grade.py +11 -0
- mlebench/competitions/detecting-insults-in-social-commentary/prepare.py +72 -0
- mlebench/competitions/detecting-insults-in-social-commentary/prepare_val.py +128 -0
- mlebench/competitions/dog-breed-identification/dogs.py +124 -0
- mlebench/competitions/dog-breed-identification/grade.py +42 -0
- mlebench/competitions/dog-breed-identification/prepare.py +55 -0
- mlebench/competitions/dog-breed-identification/prepare_val.py +104 -0
- mlebench/competitions/dogs-vs-cats-redux-kernels-edition/grade.py +43 -0
- mlebench/competitions/dogs-vs-cats-redux-kernels-edition/prepare.py +70 -0
- mlebench/competitions/dogs-vs-cats-redux-kernels-edition/prepare_val.py +143 -0
- mlebench/competitions/ethanol-concentration/grade.py +23 -0
- mlebench/competitions/ethanol-concentration/prepare.py +90 -0
- mlebench/competitions/facebook-recruiting-iii-keyword-extraction/grade.py +60 -0
- mlebench/competitions/facebook-recruiting-iii-keyword-extraction/prepare.py +41 -0
- mlebench/competitions/facebook-recruiting-iii-keyword-extraction/prepare_val.py +92 -0
- mlebench/competitions/feedback-prize-english-language-learning/__init__.py +0 -0
- mlebench/competitions/feedback-prize-english-language-learning/grade.py +60 -0
- mlebench/competitions/feedback-prize-english-language-learning/prepare.py +39 -0
- mlebench/competitions/freesound-audio-tagging-2019/grade.py +64 -0
- mlebench/competitions/freesound-audio-tagging-2019/prepare.py +94 -0
- mlebench/competitions/freesound-audio-tagging-2019/prepare_val.py +175 -0
- mlebench/competitions/freesound-audio-tagging-2019/vocabulary.py +83 -0
- mlebench/competitions/google-quest-challenge/classes.py +32 -0
- mlebench/competitions/google-quest-challenge/grade.py +45 -0
- mlebench/competitions/google-quest-challenge/prepare.py +58 -0
- mlebench/competitions/google-quest-challenge/prepare_val.py +120 -0
- mlebench/competitions/google-research-identify-contrails-reduce-global-warming/grade.py +77 -0
- mlebench/competitions/google-research-identify-contrails-reduce-global-warming/prepare.py +155 -0
- mlebench/competitions/google-research-identify-contrails-reduce-global-warming/prepare_val.py +211 -0
- mlebench/competitions/h-and-m-personalized-fashion-recommendations/grade.py +42 -0
- mlebench/competitions/h-and-m-personalized-fashion-recommendations/prepare.py +102 -0
- mlebench/competitions/h-and-m-personalized-fashion-recommendations/prepare_val.py +132 -0
- mlebench/competitions/handwriting/grade.py +23 -0
- mlebench/competitions/handwriting/prepare.py +179 -0
- mlebench/competitions/herbarium-2020-fgvc7/grade.py +34 -0
- mlebench/competitions/herbarium-2020-fgvc7/prepare.py +251 -0
- mlebench/competitions/herbarium-2020-fgvc7/prepare_val.py +242 -0
- mlebench/competitions/herbarium-2021-fgvc8/grade.py +34 -0
- mlebench/competitions/herbarium-2021-fgvc8/prepare.py +251 -0
- mlebench/competitions/herbarium-2021-fgvc8/prepare_val.py +222 -0
- mlebench/competitions/herbarium-2022-fgvc9/grade.py +31 -0
- mlebench/competitions/herbarium-2022-fgvc9/prepare.py +233 -0
- mlebench/competitions/herbarium-2022-fgvc9/prepare_val.py +213 -0
- mlebench/competitions/histopathologic-cancer-detection/grade.py +12 -0
- mlebench/competitions/histopathologic-cancer-detection/prepare.py +59 -0
- mlebench/competitions/histopathologic-cancer-detection/prepare_val.py +131 -0
- mlebench/competitions/hms-harmful-brain-activity-classification/constants.py +9 -0
- mlebench/competitions/hms-harmful-brain-activity-classification/grade.py +43 -0
- mlebench/competitions/hms-harmful-brain-activity-classification/kaggle_metric_utilities.py +96 -0
- mlebench/competitions/hms-harmful-brain-activity-classification/kullback_leibler_divergence.py +118 -0
- mlebench/competitions/hms-harmful-brain-activity-classification/prepare.py +121 -0
- mlebench/competitions/hms-harmful-brain-activity-classification/prepare_val.py +190 -0
- mlebench/competitions/hotel-id-2021-fgvc8/grade.py +41 -0
- mlebench/competitions/hotel-id-2021-fgvc8/prepare.py +63 -0
- mlebench/competitions/hotel-id-2021-fgvc8/prepare_val.py +132 -0
- mlebench/competitions/hubmap-kidney-segmentation/grade.py +62 -0
- mlebench/competitions/hubmap-kidney-segmentation/prepare.py +108 -0
- mlebench/competitions/hubmap-kidney-segmentation/prepare_val.py +153 -0
- mlebench/competitions/icecube-neutrinos-in-deep-ice/grade.py +111 -0
- mlebench/competitions/icecube-neutrinos-in-deep-ice/prepare.py +127 -0
- mlebench/competitions/icecube-neutrinos-in-deep-ice/prepare_val.py +183 -0
- mlebench/competitions/ili/grade.py +60 -0
- mlebench/competitions/ili/prepare.py +99 -0
- mlebench/competitions/imet-2020-fgvc7/grade.py +54 -0
- mlebench/competitions/imet-2020-fgvc7/prepare.py +77 -0
- mlebench/competitions/imet-2020-fgvc7/prepare_val.py +157 -0
- mlebench/competitions/inaturalist-2019-fgvc6/grade.py +35 -0
- mlebench/competitions/inaturalist-2019-fgvc6/prepare.py +259 -0
- mlebench/competitions/inaturalist-2019-fgvc6/prepare_val.py +304 -0
- mlebench/competitions/instant-gratification/__init__.py +0 -0
- mlebench/competitions/instant-gratification/grade.py +55 -0
- mlebench/competitions/instant-gratification/prepare.py +25 -0
- mlebench/competitions/instant_gratification/__init__.py +0 -0
- mlebench/competitions/instant_gratification/grade.py +55 -0
- mlebench/competitions/instant_gratification/prepare.py +25 -0
- mlebench/competitions/invasive-species-monitoring/grade.py +11 -0
- mlebench/competitions/invasive-species-monitoring/prepare.py +97 -0
- mlebench/competitions/invasive-species-monitoring/prepare_val.py +164 -0
- mlebench/competitions/iwildcam-2019-fgvc6/grade.py +44 -0
- mlebench/competitions/iwildcam-2019-fgvc6/prepare.py +118 -0
- mlebench/competitions/iwildcam-2019-fgvc6/prepare_val.py +194 -0
- mlebench/competitions/iwildcam-2020-fgvc7/grade.py +11 -0
- mlebench/competitions/iwildcam-2020-fgvc7/prepare.py +164 -0
- mlebench/competitions/iwildcam-2020-fgvc7/prepare_val.py +245 -0
- mlebench/competitions/jigsaw-toxic-comment-classification-challenge/classes.py +1 -0
- mlebench/competitions/jigsaw-toxic-comment-classification-challenge/grade.py +54 -0
- mlebench/competitions/jigsaw-toxic-comment-classification-challenge/prepare.py +42 -0
- mlebench/competitions/jigsaw-toxic-comment-classification-challenge/prepare_val.py +88 -0
- mlebench/competitions/jigsaw-unintended-bias-in-toxicity-classification/grade.py +153 -0
- mlebench/competitions/jigsaw-unintended-bias-in-toxicity-classification/prepare.py +36 -0
- mlebench/competitions/jigsaw-unintended-bias-in-toxicity-classification/prepare_val.py +117 -0
- mlebench/competitions/kuzushiji-recognition/grade.py +58 -0
- mlebench/competitions/kuzushiji-recognition/kuzushiji_metric.py +118 -0
- mlebench/competitions/kuzushiji-recognition/prepare.py +92 -0
- mlebench/competitions/kuzushiji-recognition/prepare_val.py +149 -0
- mlebench/competitions/leaf-classification/classes.py +101 -0
- mlebench/competitions/leaf-classification/grade.py +44 -0
- mlebench/competitions/leaf-classification/prepare.py +60 -0
- mlebench/competitions/leaf-classification/prepare_val.py +116 -0
- mlebench/competitions/learning-agency-lab-automated-essay-scoring-2/grade.py +44 -0
- mlebench/competitions/learning-agency-lab-automated-essay-scoring-2/prepare.py +51 -0
- mlebench/competitions/learning-agency-lab-automated-essay-scoring-2/prepare_val.py +96 -0
- mlebench/competitions/liverpool-ion-switching/__init__.py +0 -0
- mlebench/competitions/liverpool-ion-switching/grade.py +52 -0
- mlebench/competitions/liverpool-ion-switching/prepare.py +27 -0
- mlebench/competitions/liverpool_ion_switching/__init__.py +0 -0
- mlebench/competitions/liverpool_ion_switching/grade.py +52 -0
- mlebench/competitions/liverpool_ion_switching/prepare.py +27 -0
- mlebench/competitions/lmsys-chatbot-arena/grade.py +63 -0
- mlebench/competitions/lmsys-chatbot-arena/prepare.py +52 -0
- mlebench/competitions/lmsys-chatbot-arena/prepare_val.py +115 -0
- mlebench/competitions/mcm_2024_c_test/grade.py +107 -0
- mlebench/competitions/mcm_2024_c_test/prepare.py +2 -0
- mlebench/competitions/ml2021spring-hw2/grade.py +11 -0
- mlebench/competitions/ml2021spring-hw2/prepare.py +58 -0
- mlebench/competitions/ml2021spring-hw2/prepare_val.py +135 -0
- mlebench/competitions/mlsp-2013-birds/grade.py +11 -0
- mlebench/competitions/mlsp-2013-birds/prepare.py +182 -0
- mlebench/competitions/mlsp-2013-birds/prepare_val.py +241 -0
- mlebench/competitions/movie-review-sentiment-analysis-kernels-only/grade.py +11 -0
- mlebench/competitions/movie-review-sentiment-analysis-kernels-only/prepare.py +58 -0
- mlebench/competitions/movie-review-sentiment-analysis-kernels-only/prepare_val.py +120 -0
- mlebench/competitions/multi-modal-gesture-recognition/grade.py +58 -0
- mlebench/competitions/multi-modal-gesture-recognition/prepare.py +85 -0
- mlebench/competitions/multi-modal-gesture-recognition/prepare_val.py +139 -0
- mlebench/competitions/my-custom-task-01/prepare.py +2 -0
- mlebench/competitions/new-my-task-01/prepare.py +2 -0
- mlebench/competitions/new-my-task-03/grade.py +107 -0
- mlebench/competitions/new-my-task-03/prepare.py +2 -0
- mlebench/competitions/new-york-city-taxi-fare-prediction/grade.py +28 -0
- mlebench/competitions/new-york-city-taxi-fare-prediction/prepare.py +44 -0
- mlebench/competitions/new-york-city-taxi-fare-prediction/prepare_val.py +89 -0
- mlebench/competitions/nfl-player-contact-detection/grade.py +36 -0
- mlebench/competitions/nfl-player-contact-detection/prepare.py +101 -0
- mlebench/competitions/nfl-player-contact-detection/prepare_val.py +186 -0
- mlebench/competitions/nomad2018-predict-transparent-conductors/grade.py +47 -0
- mlebench/competitions/nomad2018-predict-transparent-conductors/prepare.py +77 -0
- mlebench/competitions/nomad2018-predict-transparent-conductors/prepare_val.py +144 -0
- mlebench/competitions/osic-pulmonary-fibrosis-progression/grade.py +74 -0
- mlebench/competitions/osic-pulmonary-fibrosis-progression/prepare.py +95 -0
- mlebench/competitions/osic-pulmonary-fibrosis-progression/prepare_val.py +167 -0
- mlebench/competitions/paddy-disease-classification/grade.py +35 -0
- mlebench/competitions/paddy-disease-classification/prepare.py +69 -0
- mlebench/competitions/paddy-disease-classification/prepare_val.py +122 -0
- mlebench/competitions/petfinder-pawpularity-score/grade.py +41 -0
- mlebench/competitions/petfinder-pawpularity-score/prepare.py +76 -0
- mlebench/competitions/petfinder-pawpularity-score/prepare_val.py +154 -0
- mlebench/competitions/plant-pathology-2020-fgvc7/grade.py +41 -0
- mlebench/competitions/plant-pathology-2020-fgvc7/prepare.py +74 -0
- mlebench/competitions/plant-pathology-2020-fgvc7/prepare_val.py +160 -0
- mlebench/competitions/plant-pathology-2021-fgvc8/grade.py +54 -0
- mlebench/competitions/plant-pathology-2021-fgvc8/prepare.py +65 -0
- mlebench/competitions/plant-pathology-2021-fgvc8/prepare_val.py +130 -0
- mlebench/competitions/plant-seedlings-classification/grade.py +39 -0
- mlebench/competitions/plant-seedlings-classification/prepare.py +91 -0
- mlebench/competitions/plant-seedlings-classification/prepare_val.py +158 -0
- mlebench/competitions/playground-series-s3e1/__init__.py +0 -0
- mlebench/competitions/playground-series-s3e1/grade.py +52 -0
- mlebench/competitions/playground-series-s3e1/prepare.py +25 -0
- mlebench/competitions/playground-series-s3e11/__init__.py +0 -0
- mlebench/competitions/playground-series-s3e11/grade.py +55 -0
- mlebench/competitions/playground-series-s3e11/prepare.py +25 -0
- mlebench/competitions/playground-series-s3e18/grade.py +39 -0
- mlebench/competitions/playground-series-s3e18/prepare.py +36 -0
- mlebench/competitions/playground-series-s3e18/prepare_val.py +89 -0
- mlebench/competitions/playground_series_s3e1/__init__.py +0 -0
- mlebench/competitions/playground_series_s3e1/grade.py +52 -0
- mlebench/competitions/playground_series_s3e1/prepare.py +25 -0
- mlebench/competitions/playground_series_s3e11/__init__.py +0 -0
- mlebench/competitions/playground_series_s3e11/grade.py +55 -0
- mlebench/competitions/playground_series_s3e11/prepare.py +25 -0
- mlebench/competitions/predict-volcanic-eruptions-ingv-oe/grade.py +44 -0
- mlebench/competitions/predict-volcanic-eruptions-ingv-oe/prepare.py +68 -0
- mlebench/competitions/predict-volcanic-eruptions-ingv-oe/prepare_val.py +146 -0
- mlebench/competitions/random-acts-of-pizza/grade.py +14 -0
- mlebench/competitions/random-acts-of-pizza/prepare.py +80 -0
- mlebench/competitions/random-acts-of-pizza/prepare_val.py +144 -0
- mlebench/competitions/ranzcr-clip-catheter-line-classification/classes.py +11 -0
- mlebench/competitions/ranzcr-clip-catheter-line-classification/grade.py +31 -0
- mlebench/competitions/ranzcr-clip-catheter-line-classification/prepare.py +53 -0
- mlebench/competitions/ranzcr-clip-catheter-line-classification/prepare_val.py +113 -0
- mlebench/competitions/rsna-2022-cervical-spine-fracture-detection/grade.py +124 -0
- mlebench/competitions/rsna-2022-cervical-spine-fracture-detection/prepare.py +219 -0
- mlebench/competitions/rsna-2022-cervical-spine-fracture-detection/prepare_val.py +257 -0
- mlebench/competitions/rsna-breast-cancer-detection/grade.py +65 -0
- mlebench/competitions/rsna-breast-cancer-detection/prepare.py +141 -0
- mlebench/competitions/rsna-breast-cancer-detection/prepare_val.py +201 -0
- mlebench/competitions/rsna-miccai-brain-tumor-radiogenomic-classification/grade.py +13 -0
- mlebench/competitions/rsna-miccai-brain-tumor-radiogenomic-classification/prepare.py +47 -0
- mlebench/competitions/rsna-miccai-brain-tumor-radiogenomic-classification/prepare_val.py +97 -0
- mlebench/competitions/santander-customer-satisfaction/grade.py +10 -0
- mlebench/competitions/santander-customer-satisfaction/prepare.py +41 -0
- mlebench/competitions/sciencebench-001-clintox-nn/__init__.py +0 -0
- mlebench/competitions/sciencebench-001-clintox-nn/grade.py +56 -0
- mlebench/competitions/sciencebench-001-clintox-nn/prepare.py +75 -0
- mlebench/competitions/sciencebench-015-aai/grade.py +37 -0
- mlebench/competitions/sciencebench-015-aai/prepare.py +102 -0
- mlebench/competitions/sciencebench-051-brain-blood-qsar/grade.py +58 -0
- mlebench/competitions/sciencebench-051-brain-blood-qsar/prepare.py +69 -0
- mlebench/competitions/sciencebench-101-experimental-band-gap-prediction/grade.py +55 -0
- mlebench/competitions/sciencebench-101-experimental-band-gap-prediction/prepare.py +88 -0
- mlebench/competitions/see-click-predict-fix/__init__.py +0 -0
- mlebench/competitions/see-click-predict-fix/grade.py +66 -0
- mlebench/competitions/see-click-predict-fix/prepare.py +25 -0
- mlebench/competitions/see_click_predict_fix/__init__.py +0 -0
- mlebench/competitions/see_click_predict_fix/grade.py +66 -0
- mlebench/competitions/see_click_predict_fix/prepare.py +25 -0
- mlebench/competitions/seti-breakthrough-listen/grade.py +11 -0
- mlebench/competitions/seti-breakthrough-listen/prepare.py +71 -0
- mlebench/competitions/seti-breakthrough-listen/prepare_val.py +159 -0
- mlebench/competitions/siim-covid19-detection/grade.py +194 -0
- mlebench/competitions/siim-covid19-detection/prepare.py +123 -0
- mlebench/competitions/siim-covid19-detection/prepare_val.py +164 -0
- mlebench/competitions/siim-isic-melanoma-classification/grade.py +11 -0
- mlebench/competitions/siim-isic-melanoma-classification/prepare.py +127 -0
- mlebench/competitions/siim-isic-melanoma-classification/prepare_val.py +158 -0
- mlebench/competitions/smartphone-decimeter-2022/grade.py +55 -0
- mlebench/competitions/smartphone-decimeter-2022/notebook.py +86 -0
- mlebench/competitions/smartphone-decimeter-2022/prepare.py +143 -0
- mlebench/competitions/smartphone-decimeter-2022/prepare_val.py +199 -0
- mlebench/competitions/spaceship-titanic/grade.py +11 -0
- mlebench/competitions/spaceship-titanic/prepare.py +23 -0
- mlebench/competitions/spaceship-titanic/prepare_val.py +61 -0
- mlebench/competitions/spooky-author-identification/classes.py +1 -0
- mlebench/competitions/spooky-author-identification/grade.py +38 -0
- mlebench/competitions/spooky-author-identification/prepare.py +40 -0
- mlebench/competitions/spooky-author-identification/prepare_val.py +78 -0
- mlebench/competitions/stanford-covid-vaccine/grade.py +65 -0
- mlebench/competitions/stanford-covid-vaccine/prepare.py +129 -0
- mlebench/competitions/stanford-covid-vaccine/prepare_val.py +199 -0
- mlebench/competitions/statoil-iceberg-classifier-challenge/grade.py +41 -0
- mlebench/competitions/statoil-iceberg-classifier-challenge/prepare.py +105 -0
- mlebench/competitions/statoil-iceberg-classifier-challenge/prepare_val.py +157 -0
- mlebench/competitions/tabular-playground-series-dec-2021/grade.py +11 -0
- mlebench/competitions/tabular-playground-series-dec-2021/prepare.py +39 -0
- mlebench/competitions/tabular-playground-series-dec-2021/prepare_val.py +99 -0
- mlebench/competitions/tabular-playground-series-may-2022/grade.py +9 -0
- mlebench/competitions/tabular-playground-series-may-2022/prepare.py +56 -0
- mlebench/competitions/tabular-playground-series-may-2022/prepare_val.py +116 -0
- mlebench/competitions/tensorflow-speech-recognition-challenge/grade.py +11 -0
- mlebench/competitions/tensorflow-speech-recognition-challenge/prepare.py +90 -0
- mlebench/competitions/tensorflow-speech-recognition-challenge/prepare_val.py +148 -0
- mlebench/competitions/tensorflow2-question-answering/grade.py +122 -0
- mlebench/competitions/tensorflow2-question-answering/prepare.py +122 -0
- mlebench/competitions/tensorflow2-question-answering/prepare_val.py +187 -0
- mlebench/competitions/text-normalization-challenge-english-language/grade.py +49 -0
- mlebench/competitions/text-normalization-challenge-english-language/prepare.py +115 -0
- mlebench/competitions/text-normalization-challenge-english-language/prepare_val.py +213 -0
- mlebench/competitions/text-normalization-challenge-russian-language/grade.py +49 -0
- mlebench/competitions/text-normalization-challenge-russian-language/prepare.py +113 -0
- mlebench/competitions/text-normalization-challenge-russian-language/prepare_val.py +165 -0
- mlebench/competitions/tgs-salt-identification-challenge/grade.py +144 -0
- mlebench/competitions/tgs-salt-identification-challenge/prepare.py +158 -0
- mlebench/competitions/tgs-salt-identification-challenge/prepare_val.py +166 -0
- mlebench/competitions/the-icml-2013-whale-challenge-right-whale-redux/grade.py +11 -0
- mlebench/competitions/the-icml-2013-whale-challenge-right-whale-redux/prepare.py +95 -0
- mlebench/competitions/the-icml-2013-whale-challenge-right-whale-redux/prepare_val.py +141 -0
- mlebench/competitions/tmdb-box-office-prediction/__init__.py +0 -0
- mlebench/competitions/tmdb-box-office-prediction/grade.py +55 -0
- mlebench/competitions/tmdb-box-office-prediction/prepare.py +35 -0
- mlebench/competitions/tweet-sentiment-extraction/grade.py +67 -0
- mlebench/competitions/tweet-sentiment-extraction/prepare.py +36 -0
- mlebench/competitions/tweet-sentiment-extraction/prepare_val.py +106 -0
- mlebench/competitions/us-patent-phrase-to-phrase-matching/grade.py +31 -0
- mlebench/competitions/us-patent-phrase-to-phrase-matching/prepare.py +33 -0
- mlebench/competitions/us-patent-phrase-to-phrase-matching/prepare_val.py +71 -0
- mlebench/competitions/utils.py +266 -0
- mlebench/competitions/uw-madison-gi-tract-image-segmentation/grade.py +158 -0
- mlebench/competitions/uw-madison-gi-tract-image-segmentation/prepare.py +139 -0
- mlebench/competitions/uw-madison-gi-tract-image-segmentation/prepare_val.py +193 -0
- mlebench/competitions/ventilator-pressure-prediction/__init__.py +0 -0
- mlebench/competitions/ventilator-pressure-prediction/grade.py +52 -0
- mlebench/competitions/ventilator-pressure-prediction/prepare.py +27 -0
- mlebench/competitions/ventilator-pressure-prediction/prepare_val.py +142 -0
- mlebench/competitions/ventilator_pressure_prediction/__init__.py +0 -0
- mlebench/competitions/ventilator_pressure_prediction/grade.py +52 -0
- mlebench/competitions/ventilator_pressure_prediction/prepare.py +27 -0
- mlebench/competitions/vesuvius-challenge-ink-detection/grade.py +97 -0
- mlebench/competitions/vesuvius-challenge-ink-detection/prepare.py +122 -0
- mlebench/competitions/vesuvius-challenge-ink-detection/prepare_val.py +170 -0
- mlebench/competitions/vinbigdata-chest-xray-abnormalities-detection/grade.py +220 -0
- mlebench/competitions/vinbigdata-chest-xray-abnormalities-detection/prepare.py +129 -0
- mlebench/competitions/vinbigdata-chest-xray-abnormalities-detection/prepare_val.py +204 -0
- mlebench/competitions/whale-categorization-playground/grade.py +41 -0
- mlebench/competitions/whale-categorization-playground/prepare.py +103 -0
- mlebench/competitions/whale-categorization-playground/prepare_val.py +196 -0
- mlebench/data.py +420 -0
- mlebench/grade.py +209 -0
- mlebench/grade_helpers.py +235 -0
- mlebench/metrics.py +75 -0
- mlebench/registry.py +332 -0
- mlebench/utils.py +346 -0
- {dslighting-1.7.1.dist-info → dslighting-1.7.6.dist-info}/WHEEL +0 -0
- {dslighting-1.7.1.dist-info → dslighting-1.7.6.dist-info}/entry_points.txt +0 -0
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import shutil
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
import pandas as pd
|
|
5
|
+
from sklearn.model_selection import train_test_split
|
|
6
|
+
from tqdm.auto import tqdm
|
|
7
|
+
|
|
8
|
+
from mlebench.utils import get_logger
|
|
9
|
+
|
|
10
|
+
logger = get_logger(__name__)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def _create_split_files(
|
|
14
|
+
original_meta_df: pd.DataFrame,
|
|
15
|
+
train_batch_ids: list,
|
|
16
|
+
test_batch_ids: list,
|
|
17
|
+
public_dir: Path,
|
|
18
|
+
private_dir: Path,
|
|
19
|
+
raw_dir: Path,
|
|
20
|
+
):
|
|
21
|
+
"""
|
|
22
|
+
Helper function to process a split (e.g., train/test or train_val/test_val),
|
|
23
|
+
save the necessary files, and run checks.
|
|
24
|
+
"""
|
|
25
|
+
logger.info(f"Processing split for destination: {public_dir.name}")
|
|
26
|
+
public_dir.mkdir(exist_ok=True, parents=True)
|
|
27
|
+
private_dir.mkdir(exist_ok=True, parents=True)
|
|
28
|
+
|
|
29
|
+
new_train = (
|
|
30
|
+
original_meta_df[original_meta_df["batch_id"].isin(train_batch_ids)]
|
|
31
|
+
.reset_index(drop=True)
|
|
32
|
+
.copy()
|
|
33
|
+
)
|
|
34
|
+
new_test = (
|
|
35
|
+
original_meta_df[original_meta_df["batch_id"].isin(test_batch_ids)]
|
|
36
|
+
.reset_index(drop=True)
|
|
37
|
+
.copy()
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
logger.info("Creating label-less test and sample submission")
|
|
41
|
+
new_test_without_labels = new_test.drop(columns=["azimuth", "zenith"])
|
|
42
|
+
|
|
43
|
+
# format private test to only contain event_id and labels
|
|
44
|
+
new_test = new_test[["event_id", "azimuth", "zenith"]]
|
|
45
|
+
|
|
46
|
+
# copy the format as the private test and fill dummy values like kaggle.com
|
|
47
|
+
sample_submission = new_test.copy()
|
|
48
|
+
sample_submission["azimuth"] = 1
|
|
49
|
+
sample_submission["zenith"] = 1
|
|
50
|
+
|
|
51
|
+
logger.info("Saving metadata files")
|
|
52
|
+
new_train.to_parquet(public_dir / "train_meta.parquet", index=False, engine="fastparquet")
|
|
53
|
+
new_test_without_labels.to_parquet(
|
|
54
|
+
public_dir / "test_meta.parquet", index=False, engine="fastparquet"
|
|
55
|
+
)
|
|
56
|
+
sample_submission.to_csv(public_dir / "sample_submission.csv", index=False)
|
|
57
|
+
new_test.to_csv(private_dir / "test.csv", index=False)
|
|
58
|
+
|
|
59
|
+
logger.info("Copying sensor geometry and batch data files")
|
|
60
|
+
# sensor_geometry can be copied as is
|
|
61
|
+
shutil.copy(raw_dir / "sensor_geometry.csv", public_dir / "sensor_geometry.csv")
|
|
62
|
+
|
|
63
|
+
# copy the raw train files to train and test folders respectively
|
|
64
|
+
train_ids_set = set(train_batch_ids)
|
|
65
|
+
train_dest = public_dir / "train"
|
|
66
|
+
train_dest.mkdir(exist_ok=True, parents=True)
|
|
67
|
+
test_ids_set = set(test_batch_ids)
|
|
68
|
+
test_dest = public_dir / "test"
|
|
69
|
+
test_dest.mkdir(exist_ok=True, parents=True)
|
|
70
|
+
|
|
71
|
+
for batch_file in tqdm(
|
|
72
|
+
sorted((raw_dir / "train").glob("*.parquet")), desc=f"Copying batches to {public_dir.name}"
|
|
73
|
+
):
|
|
74
|
+
batch_id = int(batch_file.stem.split("_")[-1])
|
|
75
|
+
if batch_id in train_ids_set:
|
|
76
|
+
shutil.copy(batch_file, train_dest / batch_file.name)
|
|
77
|
+
elif batch_id in test_ids_set:
|
|
78
|
+
shutil.copy(batch_file, test_dest / batch_file.name)
|
|
79
|
+
|
|
80
|
+
logger.info("Running checks")
|
|
81
|
+
assert len(list(public_dir.glob("train/*.parquet"))) == len(
|
|
82
|
+
train_batch_ids
|
|
83
|
+
), "Not all train batches copied"
|
|
84
|
+
assert len(list(public_dir.glob("test/*.parquet"))) == len(
|
|
85
|
+
test_batch_ids
|
|
86
|
+
), "Not all test batches copied"
|
|
87
|
+
assert len(train_batch_ids) + len(test_batch_ids) == len(
|
|
88
|
+
set(train_batch_ids) | set(test_batch_ids)
|
|
89
|
+
), "Something went wrong with splitting the batches"
|
|
90
|
+
|
|
91
|
+
# Drop the 'split' column for accurate checks, as it's not in the final data
|
|
92
|
+
original_meta_subset = original_meta_df[
|
|
93
|
+
original_meta_df["batch_id"].isin(train_batch_ids + test_batch_ids)
|
|
94
|
+
]
|
|
95
|
+
if "split" in original_meta_subset.columns:
|
|
96
|
+
original_meta_subset = original_meta_subset.drop(columns=["split"])
|
|
97
|
+
|
|
98
|
+
assert len(new_train) + len(new_test) == len(
|
|
99
|
+
original_meta_subset
|
|
100
|
+
), "Expected train + test to equal the original data"
|
|
101
|
+
assert len(sample_submission) == len(
|
|
102
|
+
new_test
|
|
103
|
+
), "Length mismatch between private test and sample submission"
|
|
104
|
+
|
|
105
|
+
assert sample_submission.columns.equals(
|
|
106
|
+
new_test.columns
|
|
107
|
+
), "Column mismatch between sample_submission and private test"
|
|
108
|
+
assert new_train.columns.equals(
|
|
109
|
+
original_meta_subset.columns
|
|
110
|
+
), f"Unexpected columns in train, expected {original_meta_subset.columns}, got {new_train.columns}"
|
|
111
|
+
assert new_test_without_labels.columns.equals(
|
|
112
|
+
original_meta_subset.drop(columns=["azimuth", "zenith"]).columns
|
|
113
|
+
), f"Unexpected columns in test"
|
|
114
|
+
|
|
115
|
+
assert (
|
|
116
|
+
len(set(new_train["event_id"]).intersection(set(new_test["event_id"]))) == 0
|
|
117
|
+
), "Event ids overlap between train and test"
|
|
118
|
+
assert set(new_test["event_id"]) == set(
|
|
119
|
+
sample_submission["event_id"]
|
|
120
|
+
), "Event ids mismatch between test and sample submission"
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
def prepare(raw: Path, public: Path, private: Path):
|
|
124
|
+
DEV = False
|
|
125
|
+
|
|
126
|
+
if DEV:
|
|
127
|
+
batch_cutoff = 66 # 66 instead of 660 when in dev mode
|
|
128
|
+
else:
|
|
129
|
+
batch_cutoff = None
|
|
130
|
+
|
|
131
|
+
logger.info("Loading raw metadata")
|
|
132
|
+
old_train = pd.read_parquet(raw / "train_meta.parquet")
|
|
133
|
+
batch_ids = old_train["batch_id"].unique()[:batch_cutoff]
|
|
134
|
+
|
|
135
|
+
# Clean the dataframe for processing.
|
|
136
|
+
# The original script adds a 'split' column which we don't need in the helper.
|
|
137
|
+
old_train_clean = old_train[old_train["batch_id"].isin(batch_ids)].drop(
|
|
138
|
+
columns=["split"], errors="ignore"
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
# --- 1. Original Split: Raw Data -> Train / Test ---
|
|
142
|
+
logger.info("Splitting batches into original train and test sets")
|
|
143
|
+
train_batch_ids, test_batch_ids = train_test_split(
|
|
144
|
+
batch_ids, test_size=0.1, random_state=0
|
|
145
|
+
)
|
|
146
|
+
|
|
147
|
+
# Process and save the original split to 'public' and 'private'
|
|
148
|
+
_create_split_files(
|
|
149
|
+
original_meta_df=old_train_clean,
|
|
150
|
+
train_batch_ids=list(train_batch_ids),
|
|
151
|
+
test_batch_ids=list(test_batch_ids),
|
|
152
|
+
public_dir=public,
|
|
153
|
+
private_dir=private,
|
|
154
|
+
raw_dir=raw,
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
# --- 2. New Validation Split: Original Train -> New Train / Validation Test ---
|
|
158
|
+
logger.info("Creating new parallel directories for validation split")
|
|
159
|
+
public_val = public.parent / "public_val"
|
|
160
|
+
private_val = private.parent / "private_val"
|
|
161
|
+
|
|
162
|
+
# The new validation set should be the same size as the original test set.
|
|
163
|
+
# Calculate the required test_size for the second split.
|
|
164
|
+
# test_size = (size of desired val set) / (size of set being split)
|
|
165
|
+
# = len(test_batch_ids) / len(train_batch_ids)
|
|
166
|
+
test_val_size_ratio = len(test_batch_ids) / len(train_batch_ids)
|
|
167
|
+
|
|
168
|
+
logger.info(f"Splitting original train set to create validation set")
|
|
169
|
+
train_val_batch_ids, test_val_batch_ids = train_test_split(
|
|
170
|
+
train_batch_ids, test_size=test_val_size_ratio, random_state=0
|
|
171
|
+
)
|
|
172
|
+
|
|
173
|
+
# Process and save the new validation split to 'public_val' and 'private_val'
|
|
174
|
+
_create_split_files(
|
|
175
|
+
original_meta_df=old_train_clean,
|
|
176
|
+
train_batch_ids=list(train_val_batch_ids),
|
|
177
|
+
test_batch_ids=list(test_val_batch_ids),
|
|
178
|
+
public_dir=public_val,
|
|
179
|
+
private_dir=private_val,
|
|
180
|
+
raw_dir=raw,
|
|
181
|
+
)
|
|
182
|
+
|
|
183
|
+
logger.info("All data preparation tasks are complete.")
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import pandas as pd
|
|
2
|
+
import numpy as np
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def grade(submission: pd.DataFrame, answers: pd.DataFrame) -> float:
|
|
6
|
+
"""
|
|
7
|
+
Grade the submission using MSE metric.
|
|
8
|
+
|
|
9
|
+
Args:
|
|
10
|
+
submission: DataFrame with columns ['id', 'pred_0', 'pred_1', ..., 'pred_167']
|
|
11
|
+
Each row represents one test sample
|
|
12
|
+
Columns pred_0 to pred_167 represent flattened predictions (24 timesteps * 7 features)
|
|
13
|
+
answers: DataFrame with columns ['id', 'pred_0', 'pred_1', ..., 'pred_167']
|
|
14
|
+
Ground truth in same format as submission
|
|
15
|
+
|
|
16
|
+
Returns:
|
|
17
|
+
MSE score (float) - lower is better
|
|
18
|
+
"""
|
|
19
|
+
try:
|
|
20
|
+
# Extract prediction columns (pred_0 to pred_167 for 24*7=168 values)
|
|
21
|
+
pred_cols = [f'pred_{i}' for i in range(24 * 7)]
|
|
22
|
+
|
|
23
|
+
# Check if all required columns exist
|
|
24
|
+
if not all(col in submission.columns for col in pred_cols):
|
|
25
|
+
print(f"Error: Missing prediction columns. Expected columns: {pred_cols[:5]}...{pred_cols[-5:]}")
|
|
26
|
+
return float(1e10)
|
|
27
|
+
|
|
28
|
+
# Sort by id to ensure alignment
|
|
29
|
+
submission = submission.sort_values('id').reset_index(drop=True)
|
|
30
|
+
answers = answers.sort_values('id').reset_index(drop=True)
|
|
31
|
+
|
|
32
|
+
# Extract predictions
|
|
33
|
+
predictions = submission[pred_cols].values
|
|
34
|
+
ground_truth = answers[pred_cols].values
|
|
35
|
+
|
|
36
|
+
# Reshape to (N, 24, 7) for MSE calculation
|
|
37
|
+
predictions_3d = predictions.reshape(-1, 24, 7)
|
|
38
|
+
ground_truth_3d = ground_truth.reshape(-1, 24, 7)
|
|
39
|
+
|
|
40
|
+
# Ensure shapes match
|
|
41
|
+
if predictions_3d.shape != ground_truth_3d.shape:
|
|
42
|
+
print(f"Error: Shape mismatch. Got {predictions_3d.shape}, expected {ground_truth_3d.shape}")
|
|
43
|
+
return float(1e10)
|
|
44
|
+
|
|
45
|
+
# Calculate MSE (primary metric)
|
|
46
|
+
mse = np.mean((predictions_3d - ground_truth_3d) ** 2)
|
|
47
|
+
|
|
48
|
+
# Calculate MAE (for logging/debugging)
|
|
49
|
+
mae = np.mean(np.abs(predictions_3d - ground_truth_3d))
|
|
50
|
+
|
|
51
|
+
print(f"MSE: {mse:.6f}, MAE: {mae:.6f}")
|
|
52
|
+
|
|
53
|
+
return float(mse)
|
|
54
|
+
|
|
55
|
+
except Exception as e:
|
|
56
|
+
print(f"Error during grading: {e}")
|
|
57
|
+
import traceback
|
|
58
|
+
traceback.print_exc()
|
|
59
|
+
# Return a very high score (bad) on error
|
|
60
|
+
return float(1e10)
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import pandas as pd
|
|
2
|
+
import numpy as np
|
|
3
|
+
import sys
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def prepare(raw: Path, public: Path, private: Path):
|
|
8
|
+
"""
|
|
9
|
+
Prepare the ILI dataset for the benchmark.
|
|
10
|
+
|
|
11
|
+
This function converts the CSV time series data to numpy arrays for
|
|
12
|
+
time series forecasting.
|
|
13
|
+
|
|
14
|
+
Args:
|
|
15
|
+
raw: Path to raw data directory (contains national_illness.csv)
|
|
16
|
+
public: Path to public directory (visible to participants)
|
|
17
|
+
private: Path to private directory (hidden from participants, used for grading)
|
|
18
|
+
"""
|
|
19
|
+
try:
|
|
20
|
+
# Add raw directory to path temporarily to import dataset module
|
|
21
|
+
sys.path.insert(0, str(raw))
|
|
22
|
+
|
|
23
|
+
# Use the local dataset module to load data
|
|
24
|
+
from dataset import get_dataset
|
|
25
|
+
|
|
26
|
+
# Change to raw directory to load data
|
|
27
|
+
import os
|
|
28
|
+
original_dir = os.getcwd()
|
|
29
|
+
os.chdir(str(raw))
|
|
30
|
+
|
|
31
|
+
try:
|
|
32
|
+
# Load train and test datasets
|
|
33
|
+
X_train, y_train = get_dataset('train')
|
|
34
|
+
X_test, y_test = get_dataset('test')
|
|
35
|
+
|
|
36
|
+
print(f"Loaded training data: X_train.shape = {X_train.shape}, y_train.shape = {y_train.shape}")
|
|
37
|
+
print(f"Loaded test data: X_test.shape = {X_test.shape}, y_test.shape = {y_test.shape}")
|
|
38
|
+
|
|
39
|
+
# Save training data as numpy arrays in public directory
|
|
40
|
+
np.save(public / "train_input.npy", X_train)
|
|
41
|
+
np.save(public / "train_target.npy", y_train)
|
|
42
|
+
|
|
43
|
+
# Save test input (without targets) in public directory
|
|
44
|
+
np.save(public / "test_input.npy", X_test)
|
|
45
|
+
|
|
46
|
+
# Save test targets for grading (private)
|
|
47
|
+
# Save as both numpy (for convenience) and CSV (for framework compatibility)
|
|
48
|
+
np.save(private / "test_targets.npy", y_test)
|
|
49
|
+
|
|
50
|
+
# Also save as CSV for framework compatibility
|
|
51
|
+
test_targets_flat = y_test.reshape(len(y_test), -1)
|
|
52
|
+
test_targets_df = pd.DataFrame(test_targets_flat,
|
|
53
|
+
columns=[f'pred_{i}' for i in range(24 * 7)])
|
|
54
|
+
test_targets_df.insert(0, 'id', range(len(y_test)))
|
|
55
|
+
test_targets_df.to_csv(private / "test_targets.csv", index=False)
|
|
56
|
+
|
|
57
|
+
# Create sample submission CSV file
|
|
58
|
+
# Flatten (N, 24, 7) to (N, 168) where 168 = 24*7
|
|
59
|
+
sample_submission_flat = np.zeros((len(y_test), 24 * 7))
|
|
60
|
+
sample_submission_df = pd.DataFrame(sample_submission_flat,
|
|
61
|
+
columns=[f'pred_{i}' for i in range(24 * 7)])
|
|
62
|
+
sample_submission_df.insert(0, 'id', range(len(y_test)))
|
|
63
|
+
sample_submission_df.to_csv(public / "sample_submission.csv", index=False)
|
|
64
|
+
|
|
65
|
+
# Also save numpy version for convenience
|
|
66
|
+
np.save(public / "sample_submission.npy", np.zeros_like(y_test))
|
|
67
|
+
|
|
68
|
+
print(f"Data preparation completed:")
|
|
69
|
+
print(f" - Training: {len(X_train)} samples")
|
|
70
|
+
print(f" - Test: {len(X_test)} samples")
|
|
71
|
+
print(f" - Input sequence length: {X_train.shape[1]}")
|
|
72
|
+
print(f" - Input features: {X_train.shape[2]}")
|
|
73
|
+
print(f" - Output sequence length: {y_train.shape[1]}")
|
|
74
|
+
print(f" - Output features: {y_train.shape[2]}")
|
|
75
|
+
|
|
76
|
+
finally:
|
|
77
|
+
os.chdir(original_dir)
|
|
78
|
+
sys.path.remove(str(raw))
|
|
79
|
+
|
|
80
|
+
except Exception as e:
|
|
81
|
+
print(f"Error loading data: {e}")
|
|
82
|
+
import traceback
|
|
83
|
+
traceback.print_exc()
|
|
84
|
+
# Fallback: create dummy files if loading fails
|
|
85
|
+
print("Creating dummy submission files...")
|
|
86
|
+
dummy_array = np.zeros((1, 24, 7))
|
|
87
|
+
np.save(private / "test_targets.npy", dummy_array)
|
|
88
|
+
np.save(public / "sample_submission.npy", dummy_array)
|
|
89
|
+
|
|
90
|
+
# Validation checks
|
|
91
|
+
assert (public / "train_input.npy").exists(), "Training input should exist"
|
|
92
|
+
assert (public / "train_target.npy").exists(), "Training target should exist"
|
|
93
|
+
assert (public / "test_input.npy").exists(), "Test input should exist"
|
|
94
|
+
assert (private / "test_targets.npy").exists(), "Test targets should exist"
|
|
95
|
+
assert (public / "sample_submission.npy").exists(), "Sample submission should exist"
|
|
96
|
+
|
|
97
|
+
print(f"\nPrepared ILI dataset:")
|
|
98
|
+
print(f" - Public files: {list(public.glob('*'))}")
|
|
99
|
+
print(f" - Private files: {list(private.glob('*'))}")
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import pandas as pd
|
|
2
|
+
from scipy.sparse import csr_matrix
|
|
3
|
+
from sklearn.metrics import f1_score
|
|
4
|
+
from sklearn.preprocessing import MultiLabelBinarizer
|
|
5
|
+
|
|
6
|
+
from mlebench.grade_helpers import InvalidSubmissionError
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def prepare_for_metric(
|
|
10
|
+
submission: pd.DataFrame, answers: pd.DataFrame
|
|
11
|
+
) -> tuple[csr_matrix, csr_matrix]:
|
|
12
|
+
"""Transforms the submission and answers DataFrames into the required format for grading as sparse matrices."""
|
|
13
|
+
|
|
14
|
+
# Answers checks
|
|
15
|
+
assert (
|
|
16
|
+
"id" in answers.columns and "attribute_ids" in answers.columns
|
|
17
|
+
), "Answers DataFrame must have 'id' and 'attribute_ids' columns"
|
|
18
|
+
|
|
19
|
+
# Submission checks
|
|
20
|
+
if "id" not in submission.columns:
|
|
21
|
+
raise InvalidSubmissionError("Submission DataFrame must have an 'id' column.")
|
|
22
|
+
if "attribute_ids" not in submission.columns:
|
|
23
|
+
raise InvalidSubmissionError("Submission DataFrame must have a 'attribute_ids' column.")
|
|
24
|
+
if len(submission) != len(answers):
|
|
25
|
+
raise InvalidSubmissionError(
|
|
26
|
+
"Submission and answers DataFrames must have the same number of rows."
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
# Match order
|
|
30
|
+
submission = submission.sort_values(by="id").reset_index(drop=True)
|
|
31
|
+
answers = answers.sort_values(by="id").reset_index(drop=True)
|
|
32
|
+
if (submission["id"].values != answers["id"].values).any():
|
|
33
|
+
raise InvalidSubmissionError(
|
|
34
|
+
"Submission and answers DataFrames must have matching 'id' columns."
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
# pandas reads empty cells as NaNs, which are float. We fill with empty string to match type
|
|
38
|
+
submission["attribute_ids"] = submission["attribute_ids"].fillna("")
|
|
39
|
+
answers["attribute_ids"] = answers["attribute_ids"].fillna("")
|
|
40
|
+
|
|
41
|
+
# Get classes
|
|
42
|
+
classes = set(answers["attribute_ids"].str.split().explode().unique())
|
|
43
|
+
|
|
44
|
+
# Convert to sparse matrices using MultiLabelBinarizer
|
|
45
|
+
mlb = MultiLabelBinarizer(classes=sorted(classes), sparse_output=True)
|
|
46
|
+
y_true = mlb.fit_transform(answers["attribute_ids"].str.split())
|
|
47
|
+
y_pred = mlb.transform(submission["attribute_ids"].str.split())
|
|
48
|
+
|
|
49
|
+
return y_true, y_pred
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def grade(submission: pd.DataFrame, answers: pd.DataFrame) -> float:
|
|
53
|
+
y_true, y_pred = prepare_for_metric(submission, answers)
|
|
54
|
+
return f1_score(y_true=y_true, y_pred=y_pred, average="micro")
|
|
@@ -0,0 +1,77 @@
|
|
|
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
|
+
dev = False
|
|
13
|
+
|
|
14
|
+
# Create train, test from train split
|
|
15
|
+
old_train = read_csv(raw / "train.csv")
|
|
16
|
+
# 25958/(142119+ 25958) = 0.15 original test split
|
|
17
|
+
new_train, answers = train_test_split(old_train, test_size=0.15, random_state=0)
|
|
18
|
+
|
|
19
|
+
# Sample submission
|
|
20
|
+
sample_submission_df = answers.copy()
|
|
21
|
+
sample_submission_df["attribute_ids"] = "0 1 2"
|
|
22
|
+
|
|
23
|
+
# Checks
|
|
24
|
+
assert len(answers) + len(new_train) == len(
|
|
25
|
+
old_train
|
|
26
|
+
), "New train and test should have the same length as the old train"
|
|
27
|
+
assert len(answers) == len(
|
|
28
|
+
sample_submission_df
|
|
29
|
+
), "Answers and sample submission should have the same length"
|
|
30
|
+
assert (
|
|
31
|
+
answers.columns.tolist() == old_train.columns.tolist()
|
|
32
|
+
), "Answers and old_train should have the same columns"
|
|
33
|
+
assert (
|
|
34
|
+
sample_submission_df.columns.tolist() == old_train.columns.tolist()
|
|
35
|
+
), "Sample submission and old train should have the same columns"
|
|
36
|
+
assert (
|
|
37
|
+
new_train.columns.tolist() == old_train.columns.tolist()
|
|
38
|
+
), "New train and old train should have the same columns"
|
|
39
|
+
assert set(new_train["id"]).isdisjoint(
|
|
40
|
+
set(answers["id"])
|
|
41
|
+
), "New train and answers should have no overlap of rows"
|
|
42
|
+
|
|
43
|
+
# Write CSVs
|
|
44
|
+
answers.to_csv(private / "answers.csv", index=False)
|
|
45
|
+
new_train.to_csv(public / "train.csv", index=False)
|
|
46
|
+
sample_submission_df.to_csv(public / "sample_submission.csv", index=False)
|
|
47
|
+
|
|
48
|
+
# Copy over files
|
|
49
|
+
shutil.copyfile(src=raw / "labels.csv", dst=public / "labels.csv")
|
|
50
|
+
|
|
51
|
+
(public / "test").mkdir(exist_ok=True)
|
|
52
|
+
(public / "train").mkdir(exist_ok=True)
|
|
53
|
+
|
|
54
|
+
if dev:
|
|
55
|
+
# Reduce the number of images to be copied to 10% of the original, for testing
|
|
56
|
+
new_train = new_train.head(int(len(new_train) * 0.1))
|
|
57
|
+
answers = answers.head(int(len(answers) * 0.1))
|
|
58
|
+
|
|
59
|
+
for file_id in tqdm(new_train["id"], desc="Copying train images"):
|
|
60
|
+
shutil.copyfile(
|
|
61
|
+
src=raw / "train" / f"{file_id}.png",
|
|
62
|
+
dst=public / "train" / f"{file_id}.png",
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
for file_id in tqdm(answers["id"], desc="Copying test images"):
|
|
66
|
+
shutil.copyfile(
|
|
67
|
+
src=raw / "train" / f"{file_id}.png",
|
|
68
|
+
dst=public / "test" / f"{file_id}.png",
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
# File copying checks
|
|
72
|
+
assert len(list(public.glob("train/*.png"))) == len(
|
|
73
|
+
new_train
|
|
74
|
+
), "Train images should have the same number of images as the train"
|
|
75
|
+
assert len(list(public.glob("test/*.png"))) == len(
|
|
76
|
+
answers
|
|
77
|
+
), "Test images should have the same number of images as the test"
|
|
@@ -0,0 +1,157 @@
|
|
|
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 _process_split(
|
|
11
|
+
train_df,
|
|
12
|
+
test_df,
|
|
13
|
+
public_path: Path,
|
|
14
|
+
private_path: Path,
|
|
15
|
+
raw_images_path: Path,
|
|
16
|
+
dev: bool,
|
|
17
|
+
):
|
|
18
|
+
"""
|
|
19
|
+
Helper function to process a single data split (train/test).
|
|
20
|
+
|
|
21
|
+
It handles the creation of directories, writing of CSVs (train, answers,
|
|
22
|
+
sample_submission), and copying of image files. This ensures a consistent
|
|
23
|
+
output structure for any given split.
|
|
24
|
+
"""
|
|
25
|
+
# Create output directories
|
|
26
|
+
public_path.mkdir(exist_ok=True, parents=True)
|
|
27
|
+
private_path.mkdir(exist_ok=True, parents=True)
|
|
28
|
+
(public_path / "test").mkdir(exist_ok=True)
|
|
29
|
+
(public_path / "train").mkdir(exist_ok=True)
|
|
30
|
+
|
|
31
|
+
# The test_df is the ground truth for the test set
|
|
32
|
+
answers = test_df
|
|
33
|
+
|
|
34
|
+
# Create a sample submission from the answers dataframe
|
|
35
|
+
sample_submission_df = answers.copy()
|
|
36
|
+
sample_submission_df["attribute_ids"] = "0 1 2"
|
|
37
|
+
|
|
38
|
+
# Checks
|
|
39
|
+
assert len(answers) == len(
|
|
40
|
+
sample_submission_df
|
|
41
|
+
), "Answers and sample submission should have the same length"
|
|
42
|
+
assert (
|
|
43
|
+
sample_submission_df.columns.tolist() == answers.columns.tolist()
|
|
44
|
+
), "Sample submission and answers should have the same columns"
|
|
45
|
+
|
|
46
|
+
# Write CSVs
|
|
47
|
+
train_df.to_csv(public_path / "train.csv", index=False)
|
|
48
|
+
answers.to_csv(private_path / "answers.csv", index=False)
|
|
49
|
+
sample_submission_df.to_csv(public_path / "sample_submission.csv", index=False)
|
|
50
|
+
|
|
51
|
+
# If in dev mode, reduce the number of images to copy for faster execution
|
|
52
|
+
if dev:
|
|
53
|
+
train_df_to_copy = train_df.head(int(len(train_df) * 0.1))
|
|
54
|
+
answers_to_copy = answers.head(int(len(answers) * 0.1))
|
|
55
|
+
else:
|
|
56
|
+
train_df_to_copy = train_df
|
|
57
|
+
answers_to_copy = answers
|
|
58
|
+
|
|
59
|
+
# Copy train images
|
|
60
|
+
for file_id in tqdm(
|
|
61
|
+
train_df_to_copy["id"], desc=f"Copying train images to {public_path.name}"
|
|
62
|
+
):
|
|
63
|
+
shutil.copyfile(
|
|
64
|
+
src=raw_images_path / f"{file_id}.png",
|
|
65
|
+
dst=public_path / "train" / f"{file_id}.png",
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
# Copy test images
|
|
69
|
+
for file_id in tqdm(
|
|
70
|
+
answers_to_copy["id"], desc=f"Copying test images to {public_path.name}"
|
|
71
|
+
):
|
|
72
|
+
shutil.copyfile(
|
|
73
|
+
src=raw_images_path / f"{file_id}.png",
|
|
74
|
+
dst=public_path / "test" / f"{file_id}.png",
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
# File copying checks
|
|
78
|
+
assert len(list(public_path.glob("train/*.png"))) == len(
|
|
79
|
+
train_df_to_copy
|
|
80
|
+
), f"Train images in {public_path.name} should match dataframe"
|
|
81
|
+
assert len(list(public_path.glob("test/*.png"))) == len(
|
|
82
|
+
answers_to_copy
|
|
83
|
+
), f"Test images in {public_path.name} should match dataframe"
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def prepare(raw: Path, public: Path, private: Path):
|
|
87
|
+
|
|
88
|
+
dev = False
|
|
89
|
+
|
|
90
|
+
# --- 1. Original Split: Create main train and test sets ---
|
|
91
|
+
|
|
92
|
+
# Create train, test from train split
|
|
93
|
+
old_train = read_csv(raw / "train.csv")
|
|
94
|
+
# 25958/(142119+ 25958) = 0.15 original test split
|
|
95
|
+
main_train, main_test = train_test_split(old_train, test_size=0.15, random_state=0)
|
|
96
|
+
|
|
97
|
+
# Checks
|
|
98
|
+
assert len(main_test) + len(main_train) == len(
|
|
99
|
+
old_train
|
|
100
|
+
), "New train and test should have the same length as the old train"
|
|
101
|
+
assert (
|
|
102
|
+
main_test.columns.tolist() == old_train.columns.tolist()
|
|
103
|
+
), "Answers and old_train should have the same columns"
|
|
104
|
+
assert (
|
|
105
|
+
main_train.columns.tolist() == old_train.columns.tolist()
|
|
106
|
+
), "New train and old train should have the same columns"
|
|
107
|
+
assert set(main_train["id"]).isdisjoint(
|
|
108
|
+
set(main_test["id"])
|
|
109
|
+
), "New train and answers should have no overlap of rows"
|
|
110
|
+
|
|
111
|
+
# Process and save the original split to `public` and `private` directories
|
|
112
|
+
_process_split(
|
|
113
|
+
train_df=main_train,
|
|
114
|
+
test_df=main_test,
|
|
115
|
+
public_path=public,
|
|
116
|
+
private_path=private,
|
|
117
|
+
raw_images_path=raw / "train",
|
|
118
|
+
dev=dev,
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
# Copy over metadata file for the original split
|
|
122
|
+
shutil.copyfile(src=raw / "labels.csv", dst=public / "labels.csv")
|
|
123
|
+
|
|
124
|
+
# --- 2. New Validation Split: Create validation train and test sets ---
|
|
125
|
+
|
|
126
|
+
# Define paths for the new validation split, parallel to the original ones
|
|
127
|
+
public_val = public.parent / "public_val"
|
|
128
|
+
private_val = private.parent / "private_val"
|
|
129
|
+
|
|
130
|
+
# The test_size for the second split is calculated to yield a validation set
|
|
131
|
+
# of approximately the same size as the original test set.
|
|
132
|
+
# Original test set size = 0.15 * N
|
|
133
|
+
# Original train set size = 0.85 * N
|
|
134
|
+
# We want: test_size_val * (0.85 * N) ~= 0.15 * N
|
|
135
|
+
# So, test_size_val ~= 0.15 / 0.85
|
|
136
|
+
test_size_for_val_split = 0.15 / (1 - 0.15)
|
|
137
|
+
|
|
138
|
+
# Split the main_train set again to create a smaller training set and a validation set.
|
|
139
|
+
# We use the same random_state to ensure this split is also deterministic.
|
|
140
|
+
train_val, test_val = train_test_split(
|
|
141
|
+
main_train, test_size=test_size_for_val_split, random_state=0
|
|
142
|
+
)
|
|
143
|
+
|
|
144
|
+
# Process and save the validation split to `public_val` and `private_val`.
|
|
145
|
+
# The filenames and structure will be identical to the original split, but
|
|
146
|
+
# will contain the new, smaller training set and the validation set.
|
|
147
|
+
_process_split(
|
|
148
|
+
train_df=train_val,
|
|
149
|
+
test_df=test_val,
|
|
150
|
+
public_path=public_val,
|
|
151
|
+
private_path=private_val,
|
|
152
|
+
raw_images_path=raw / "train",
|
|
153
|
+
dev=dev,
|
|
154
|
+
)
|
|
155
|
+
|
|
156
|
+
# Copy over metadata file for the validation split
|
|
157
|
+
shutil.copyfile(src=raw / "labels.csv", dst=public_val / "labels.csv")
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import pandas as pd
|
|
2
|
+
from sklearn.metrics import accuracy_score
|
|
3
|
+
|
|
4
|
+
from mlebench.grade_helpers import InvalidSubmissionError
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def prepare_for_metric(submission: pd.DataFrame, answers: pd.DataFrame):
|
|
8
|
+
"""
|
|
9
|
+
`submission` and `answers` are pd.DataFrame with "id" and "predicted" columns
|
|
10
|
+
"""
|
|
11
|
+
if len(submission) != len(answers):
|
|
12
|
+
raise InvalidSubmissionError(
|
|
13
|
+
f"Submission length {len(submission)} != answers length {len(answers)}"
|
|
14
|
+
)
|
|
15
|
+
if "id" not in submission.columns or "predicted" not in submission.columns:
|
|
16
|
+
raise InvalidSubmissionError("Submission must have 'id' and 'predicted' columns")
|
|
17
|
+
|
|
18
|
+
assert "id" in answers.columns, "Answers must have 'id' column"
|
|
19
|
+
assert "predicted" in answers.columns, "Answers must have 'predicted' column"
|
|
20
|
+
|
|
21
|
+
# Sort submission and answers by "id"
|
|
22
|
+
submission = submission.sort_values("id")
|
|
23
|
+
answers = answers.sort_values("id")
|
|
24
|
+
if (submission["id"].values != answers["id"].values).any():
|
|
25
|
+
raise InvalidSubmissionError("Submission and answers have mismatched 'id' columns")
|
|
26
|
+
|
|
27
|
+
y_true = [int(y) for y in answers["predicted"]]
|
|
28
|
+
y_pred = [int(y) if isinstance(y, int) else int(y.split()[0]) for y in submission["predicted"]]
|
|
29
|
+
return y_true, y_pred
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def grade(submission: pd.DataFrame, answers: pd.DataFrame) -> float:
|
|
33
|
+
y_true, y_pred = prepare_for_metric(submission, answers)
|
|
34
|
+
accuracy = accuracy_score(y_true=y_true, y_pred=y_pred)
|
|
35
|
+
return 1 - accuracy
|