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.
- dslighting/__init__.py +1 -1
- dslighting/core/agent.py +78 -62
- {dslighting-1.7.1.dist-info → dslighting-1.7.8.dist-info}/METADATA +3 -1
- {dslighting-1.7.1.dist-info → dslighting-1.7.8.dist-info}/RECORD +352 -7
- {dslighting-1.7.1.dist-info → dslighting-1.7.8.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.8.dist-info}/WHEEL +0 -0
- {dslighting-1.7.1.dist-info → dslighting-1.7.8.dist-info}/entry_points.txt +0 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
import pandas as pd
|
|
3
|
+
from pandas import DataFrame, Series
|
|
4
|
+
from sklearn.metrics import fbeta_score
|
|
5
|
+
|
|
6
|
+
from mlebench.competitions.utils import rle_decode
|
|
7
|
+
from mlebench.grade_helpers import InvalidSubmissionError
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def grade(submission: DataFrame, answers: DataFrame) -> float:
|
|
11
|
+
scores = []
|
|
12
|
+
|
|
13
|
+
if len(submission) != len(answers):
|
|
14
|
+
raise InvalidSubmissionError(
|
|
15
|
+
f"Expected {len(answers)} rows in the submission DataFrame, but got {len(submission)} "
|
|
16
|
+
f"rows."
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
for (_, actual), (_, expected) in zip(submission.iterrows(), answers.iterrows()):
|
|
20
|
+
score = grade_row(actual, expected)
|
|
21
|
+
scores.append(score)
|
|
22
|
+
|
|
23
|
+
return np.mean(scores)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def grade_row(submission: Series, answer: Series) -> float:
|
|
27
|
+
expected_submission_indices = ["Id", "Predicted"]
|
|
28
|
+
expected_answer_indices = expected_submission_indices + ["width", "height"]
|
|
29
|
+
|
|
30
|
+
assert set(answer.index) == set(
|
|
31
|
+
expected_answer_indices
|
|
32
|
+
), f"Expected indices {set(expected_answer_indices)}, got {set(answer.index)}."
|
|
33
|
+
|
|
34
|
+
if len(submission) != len(expected_submission_indices):
|
|
35
|
+
raise InvalidSubmissionError(
|
|
36
|
+
f"Expected {len(expected_submission_indices)} indices in the submission DataFrame, "
|
|
37
|
+
f"but got {len(submission)} indices."
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
if not set(submission.index).issuperset(set(expected_submission_indices)):
|
|
41
|
+
raise InvalidSubmissionError(
|
|
42
|
+
f"Expected columns {expected_submission_indices}, got {set(submission.index)}."
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
assert (
|
|
46
|
+
submission["Id"] == answer["Id"]
|
|
47
|
+
), "Expected 'Id' column to be the same in both DataFrames."
|
|
48
|
+
|
|
49
|
+
submission_rle = submission["Predicted"]
|
|
50
|
+
answer_rle = answer["Predicted"]
|
|
51
|
+
|
|
52
|
+
if not isinstance(submission_rle, str):
|
|
53
|
+
raise InvalidSubmissionError(
|
|
54
|
+
f"Expected 'Predicted' column to be a string, got {type(submission_rle)}."
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
assert isinstance(
|
|
58
|
+
answer_rle, str
|
|
59
|
+
), f"Expected 'Predicted' column in answer to be a string, got {type(answer_rle)}."
|
|
60
|
+
|
|
61
|
+
assert "width" in answer.index, "Expected 'width' index in answer."
|
|
62
|
+
assert "height" in answer.index, "Expected 'height' index in answer."
|
|
63
|
+
|
|
64
|
+
width = int(answer["width"])
|
|
65
|
+
height = int(answer["height"])
|
|
66
|
+
|
|
67
|
+
# The `rle_decode` assumes the run-length encoded string is ordered top to bottom then left to right,
|
|
68
|
+
# that is, 1 is (1,1), 2 is (2,1) and so on. The Vesuvius Challenge requires the opposite order, that
|
|
69
|
+
# is, 1 is (1,1), 2 is (1,2) and so on. To fix this, we decode the transpose of the matrix, then
|
|
70
|
+
# transpose it back.
|
|
71
|
+
try:
|
|
72
|
+
submission_matrix = rle_decode(submission_rle, height=width, width=height).T
|
|
73
|
+
except AssertionError as e:
|
|
74
|
+
raise InvalidSubmissionError(f"Error decoding RLE masks: {e}")
|
|
75
|
+
|
|
76
|
+
answer_matrix = rle_decode(answer_rle, height=width, width=height).T
|
|
77
|
+
|
|
78
|
+
assert submission_matrix.shape == (
|
|
79
|
+
height,
|
|
80
|
+
width,
|
|
81
|
+
), f"Expected submission matrix to have shape ({height}, {width}), got {submission_matrix.shape}."
|
|
82
|
+
|
|
83
|
+
assert (
|
|
84
|
+
submission_matrix.shape == answer_matrix.shape
|
|
85
|
+
), f"Expected submission matrix to have shape {answer_matrix.shape}, got {submission_matrix.shape}."
|
|
86
|
+
|
|
87
|
+
y_pred = submission_matrix.flatten().astype(bool)
|
|
88
|
+
y_true = answer_matrix.flatten().astype(bool)
|
|
89
|
+
|
|
90
|
+
assert np.isclose(submission_matrix.sum().sum(), y_pred.sum()), (
|
|
91
|
+
f"Expected the sum of the submission matrix to be preserved when flattening and converting "
|
|
92
|
+
f"to bool, but got {np.sum(y_pred)} instead of {np.sum(submission_matrix)}."
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
score = fbeta_score(y_true=y_true, y_pred=y_pred, beta=0.5)
|
|
96
|
+
|
|
97
|
+
return score
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import shutil
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
import pandas as pd
|
|
5
|
+
from PIL import Image
|
|
6
|
+
from tqdm import tqdm
|
|
7
|
+
|
|
8
|
+
from mlebench.utils import read_csv
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def prepare(raw: Path, public: Path, private: Path) -> None:
|
|
12
|
+
# Copy train images to `public/train/{1,2}/`
|
|
13
|
+
shutil.copytree(
|
|
14
|
+
src=raw / "train" / "1",
|
|
15
|
+
dst=public / "train" / "1",
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
shutil.copytree(
|
|
19
|
+
src=raw / "train" / "2",
|
|
20
|
+
dst=public / "train" / "2",
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
# Create test `inklabels_rle.csv`
|
|
24
|
+
inklabels_rle = read_csv(raw / "train" / "3" / "inklabels_rle.csv")
|
|
25
|
+
|
|
26
|
+
assert (
|
|
27
|
+
len(inklabels_rle) == 1
|
|
28
|
+
), f"Expected a single row in `inklabels_rle.csv`, got {len(inklabels_rle)} rows."
|
|
29
|
+
|
|
30
|
+
img_path = raw / "train" / "3" / "ir.png"
|
|
31
|
+
|
|
32
|
+
assert img_path.is_file(), f"Expected image file at {img_path}, but it does not exist."
|
|
33
|
+
|
|
34
|
+
with Image.open(img_path) as img:
|
|
35
|
+
width, height = img.size
|
|
36
|
+
|
|
37
|
+
inklabels_rle["width"] = width
|
|
38
|
+
inklabels_rle["height"] = height
|
|
39
|
+
inklabels_rle["Id"] = "a"
|
|
40
|
+
|
|
41
|
+
inklabels_rle.to_csv(private / "inklabels_rle.csv", index=False)
|
|
42
|
+
|
|
43
|
+
# Write `gold_submission.csv`
|
|
44
|
+
inklabels_rle.drop(columns=["width", "height"]).to_csv(
|
|
45
|
+
private / "gold_submission.csv",
|
|
46
|
+
index=False,
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
# Copy test images to `{public,private}/test/a/`
|
|
50
|
+
test_imgs = list((raw / "train" / "3").rglob("*"))
|
|
51
|
+
|
|
52
|
+
for fpath in tqdm(test_imgs, desc="Creating test images"):
|
|
53
|
+
if not fpath.is_file():
|
|
54
|
+
continue
|
|
55
|
+
|
|
56
|
+
assert fpath.suffix in [
|
|
57
|
+
".png",
|
|
58
|
+
".csv",
|
|
59
|
+
".tif",
|
|
60
|
+
], f"Expected file with extension png, csv, or tif, got `{fpath.suffix}` for file `{fpath}`"
|
|
61
|
+
|
|
62
|
+
relative_path = fpath.relative_to(raw / "train" / "3")
|
|
63
|
+
|
|
64
|
+
if fpath.name in ["inklabels.png", "inklabels_rle.csv", "ir.png"]:
|
|
65
|
+
continue # skip test images and labels
|
|
66
|
+
|
|
67
|
+
dst = public / "test" / "a" / relative_path
|
|
68
|
+
dst.parent.mkdir(parents=True, exist_ok=True)
|
|
69
|
+
shutil.copy(fpath, dst) # everything else to `public`
|
|
70
|
+
|
|
71
|
+
sample_submission = pd.DataFrame({"Id": ["a"], "Predicted": ["1 1 5 1"]})
|
|
72
|
+
sample_submission.to_csv(public / "sample_submission.csv", index=False)
|
|
73
|
+
|
|
74
|
+
# Sanity checks
|
|
75
|
+
assert len(sample_submission) == len(inklabels_rle), (
|
|
76
|
+
f"Expected {len(inklabels_rle)} rows in `sample_submission.csv`, got "
|
|
77
|
+
f"{len(sample_submission)} rows."
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
actual_sample_submission = read_csv(public / "sample_submission.csv")
|
|
81
|
+
actual_inklabels_rle = read_csv(private / "inklabels_rle.csv")
|
|
82
|
+
|
|
83
|
+
assert (
|
|
84
|
+
"Id" in actual_sample_submission.columns
|
|
85
|
+
), f"Expected column `Id` in `sample_submission.csv`."
|
|
86
|
+
assert (
|
|
87
|
+
"Predicted" in actual_sample_submission.columns
|
|
88
|
+
), f"Expected column `Predicted` in `sample_submission.csv`."
|
|
89
|
+
|
|
90
|
+
assert "Id" in actual_inklabels_rle.columns, f"Expected column `Id` in `inklabels_rle.csv`."
|
|
91
|
+
assert (
|
|
92
|
+
"Predicted" in actual_inklabels_rle.columns
|
|
93
|
+
), f"Expected column `Predicted` in `inklabels_rle.csv`."
|
|
94
|
+
assert (
|
|
95
|
+
"width" in actual_inklabels_rle.columns
|
|
96
|
+
), f"Expected column `width` in `inklabels_rle.csv`."
|
|
97
|
+
assert (
|
|
98
|
+
"height" in actual_inklabels_rle.columns
|
|
99
|
+
), f"Expected column `height` in `inklabels_rle.csv`."
|
|
100
|
+
|
|
101
|
+
assert len(list((public / "train" / "1").rglob("*"))) == len(
|
|
102
|
+
list((raw / "train" / "1").rglob("*"))
|
|
103
|
+
), (
|
|
104
|
+
f"Expected {len(list(raw / 'train' / '1').rglob('*'))} files in `public/train/1`, got "
|
|
105
|
+
f"{len(list(public / 'train' / '1').rglob('*'))} files."
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
assert len(list((public / "train" / "2").rglob("*"))) == len(
|
|
109
|
+
list((raw / "train" / "2").rglob("*"))
|
|
110
|
+
), (
|
|
111
|
+
f"Expected {len(list(raw / 'train' / '2').rglob('*'))} files in `public/train/2`, got "
|
|
112
|
+
f"{len(list(public / 'train' / '2').rglob('*'))} files."
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
n_test_actual = len(list((public / "test" / "a").rglob("*")))
|
|
116
|
+
n_test_expected = len(list((raw / "train" / "3").rglob("*"))) - len(
|
|
117
|
+
["inklabels.png", "inklabels_rle.csv", "ir.png"]
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
assert n_test_actual == n_test_expected, (
|
|
121
|
+
f"Expected " f"{n_test_expected} " f"files in `public/test/a`, got {n_test_actual} files."
|
|
122
|
+
)
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import shutil
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
from typing import List
|
|
4
|
+
|
|
5
|
+
import pandas as pd
|
|
6
|
+
from PIL import Image
|
|
7
|
+
from tqdm import tqdm
|
|
8
|
+
|
|
9
|
+
from mlebench.utils import read_csv
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def prepare(raw: Path, public: Path, private: Path) -> None:
|
|
13
|
+
"""
|
|
14
|
+
Prepares the data by creating a primary train/test split and a secondary
|
|
15
|
+
train/validation split.
|
|
16
|
+
|
|
17
|
+
The primary split uses fragments {1, 2} for training and {3} for testing,
|
|
18
|
+
outputting to `public/` and `private/` directories.
|
|
19
|
+
|
|
20
|
+
The secondary split uses fragment {1} for training and {2} for validation,
|
|
21
|
+
outputting to `public_val/` and `private_val/` directories, mirroring the
|
|
22
|
+
structure and logic of the primary split.
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
def _create_split_data(
|
|
26
|
+
train_fragment_ids: List[str],
|
|
27
|
+
test_fragment_id: str,
|
|
28
|
+
raw_path: Path,
|
|
29
|
+
public_path: Path,
|
|
30
|
+
private_path: Path,
|
|
31
|
+
) -> None:
|
|
32
|
+
"""
|
|
33
|
+
A generic helper function to process a set of train/test fragments
|
|
34
|
+
and generate the corresponding public and private data.
|
|
35
|
+
"""
|
|
36
|
+
# Ensure destination directories exist
|
|
37
|
+
public_path.mkdir(parents=True, exist_ok=True)
|
|
38
|
+
private_path.mkdir(parents=True, exist_ok=True)
|
|
39
|
+
|
|
40
|
+
# Copy train images to `public_path/train/{id}/`
|
|
41
|
+
for frag_id in train_fragment_ids:
|
|
42
|
+
shutil.copytree(
|
|
43
|
+
src=raw_path / "train" / frag_id,
|
|
44
|
+
dst=public_path / "train" / frag_id,
|
|
45
|
+
dirs_exist_ok=True, # Make script re-runnable
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
test_fragment_path = raw_path / "train" / test_fragment_id
|
|
49
|
+
|
|
50
|
+
# Create test `inklabels_rle.csv`
|
|
51
|
+
inklabels_rle = read_csv(test_fragment_path / "inklabels_rle.csv")
|
|
52
|
+
|
|
53
|
+
assert (
|
|
54
|
+
len(inklabels_rle) == 1
|
|
55
|
+
), f"Expected a single row in `inklabels_rle.csv`, got {len(inklabels_rle)} rows."
|
|
56
|
+
|
|
57
|
+
img_path = test_fragment_path / "ir.png"
|
|
58
|
+
|
|
59
|
+
assert img_path.is_file(), f"Expected image file at {img_path}, but it does not exist."
|
|
60
|
+
|
|
61
|
+
with Image.open(img_path) as img:
|
|
62
|
+
width, height = img.size
|
|
63
|
+
|
|
64
|
+
inklabels_rle["width"] = width
|
|
65
|
+
inklabels_rle["height"] = height
|
|
66
|
+
inklabels_rle["Id"] = "a"
|
|
67
|
+
|
|
68
|
+
inklabels_rle.to_csv(private_path / "inklabels_rle.csv", index=False)
|
|
69
|
+
|
|
70
|
+
# Write `gold_submission.csv`
|
|
71
|
+
inklabels_rle.drop(columns=["width", "height"]).to_csv(
|
|
72
|
+
private_path / "gold_submission.csv",
|
|
73
|
+
index=False,
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
# Copy test images to `public_path/test/a/`
|
|
77
|
+
test_imgs = list(test_fragment_path.rglob("*"))
|
|
78
|
+
|
|
79
|
+
for fpath in tqdm(test_imgs, desc=f"Creating test images for {public_path.name}"):
|
|
80
|
+
if not fpath.is_file():
|
|
81
|
+
continue
|
|
82
|
+
|
|
83
|
+
assert fpath.suffix in [
|
|
84
|
+
".png",
|
|
85
|
+
".csv",
|
|
86
|
+
".tif",
|
|
87
|
+
], f"Expected file with extension png, csv, or tif, got `{fpath.suffix}` for file `{fpath}`"
|
|
88
|
+
|
|
89
|
+
relative_path = fpath.relative_to(test_fragment_path)
|
|
90
|
+
|
|
91
|
+
if fpath.name in ["inklabels.png", "inklabels_rle.csv", "ir.png"]:
|
|
92
|
+
continue # skip test images and labels
|
|
93
|
+
|
|
94
|
+
dst = public_path / "test" / "a" / relative_path
|
|
95
|
+
dst.parent.mkdir(parents=True, exist_ok=True)
|
|
96
|
+
shutil.copy(fpath, dst) # everything else to `public_path`
|
|
97
|
+
|
|
98
|
+
sample_submission = pd.DataFrame({"Id": ["a"], "Predicted": ["1 1 5 1"]})
|
|
99
|
+
sample_submission.to_csv(public_path / "sample_submission.csv", index=False)
|
|
100
|
+
|
|
101
|
+
# Sanity checks
|
|
102
|
+
assert len(sample_submission) == len(inklabels_rle), (
|
|
103
|
+
f"Expected {len(inklabels_rle)} rows in `sample_submission.csv`, got "
|
|
104
|
+
f"{len(sample_submission)} rows."
|
|
105
|
+
)
|
|
106
|
+
|
|
107
|
+
actual_sample_submission = read_csv(public_path / "sample_submission.csv")
|
|
108
|
+
actual_inklabels_rle = read_csv(private_path / "inklabels_rle.csv")
|
|
109
|
+
|
|
110
|
+
assert (
|
|
111
|
+
"Id" in actual_sample_submission.columns
|
|
112
|
+
), f"Expected column `Id` in `sample_submission.csv`."
|
|
113
|
+
assert (
|
|
114
|
+
"Predicted" in actual_sample_submission.columns
|
|
115
|
+
), f"Expected column `Predicted` in `sample_submission.csv`."
|
|
116
|
+
|
|
117
|
+
assert "Id" in actual_inklabels_rle.columns, f"Expected column `Id` in `inklabels_rle.csv`."
|
|
118
|
+
assert (
|
|
119
|
+
"Predicted" in actual_inklabels_rle.columns
|
|
120
|
+
), f"Expected column `Predicted` in `inklabels_rle.csv`."
|
|
121
|
+
assert (
|
|
122
|
+
"width" in actual_inklabels_rle.columns
|
|
123
|
+
), f"Expected column `width` in `inklabels_rle.csv`."
|
|
124
|
+
assert (
|
|
125
|
+
"height" in actual_inklabels_rle.columns
|
|
126
|
+
), f"Expected column `height` in `inklabels_rle.csv`."
|
|
127
|
+
|
|
128
|
+
for frag_id in train_fragment_ids:
|
|
129
|
+
assert len(list((public_path / "train" / frag_id).rglob("*"))) == len(
|
|
130
|
+
list((raw_path / "train" / frag_id).rglob("*"))
|
|
131
|
+
), (
|
|
132
|
+
f"Expected {len(list((raw_path / 'train' / frag_id).rglob('*')))} files in `{public_path}/train/{frag_id}`, got "
|
|
133
|
+
f"{len(list((public_path / 'train' / frag_id).rglob('*')))} files."
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
n_test_actual = len(list((public_path / "test" / "a").rglob("*")))
|
|
137
|
+
n_test_expected = len(list(test_fragment_path.rglob("*"))) - len(
|
|
138
|
+
["inklabels.png", "inklabels_rle.csv", "ir.png"]
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
assert n_test_actual == n_test_expected, (
|
|
142
|
+
f"Expected " f"{n_test_expected} " f"files in `{public_path}/test/a`, got {n_test_actual} files."
|
|
143
|
+
)
|
|
144
|
+
|
|
145
|
+
# --- Primary Split (Original Behavior) ---
|
|
146
|
+
# This call generates the original `public` and `private` directories.
|
|
147
|
+
# The contents will be identical to the original script's output.
|
|
148
|
+
_create_split_data(
|
|
149
|
+
train_fragment_ids=["1", "2"],
|
|
150
|
+
test_fragment_id="3",
|
|
151
|
+
raw_path=raw,
|
|
152
|
+
public_path=public,
|
|
153
|
+
private_path=private,
|
|
154
|
+
)
|
|
155
|
+
|
|
156
|
+
# --- New Validation Split ---
|
|
157
|
+
# Define paths for the new validation set directories.
|
|
158
|
+
public_val = public.parent / "public_val"
|
|
159
|
+
private_val = private.parent / "private_val"
|
|
160
|
+
|
|
161
|
+
# This call splits the original training data ({1, 2}) into a new, smaller
|
|
162
|
+
# training set ({1}) and a validation set ({2}). The output structure
|
|
163
|
+
# in `public_val` and `private_val` will mirror the original one.
|
|
164
|
+
_create_split_data(
|
|
165
|
+
train_fragment_ids=["1"],
|
|
166
|
+
test_fragment_id="2",
|
|
167
|
+
raw_path=raw,
|
|
168
|
+
public_path=public_val,
|
|
169
|
+
private_path=private_val,
|
|
170
|
+
)
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
import pandas as pd
|
|
3
|
+
from pycocotools.coco import COCO
|
|
4
|
+
from pycocotools.cocoeval import COCOeval
|
|
5
|
+
|
|
6
|
+
from mlebench.grade_helpers import InvalidSubmissionError
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def prepare_for_metric(submission: pd.DataFrame, answers: pd.DataFrame) -> dict:
|
|
10
|
+
"""Prepare the submission and answers for the metric."""
|
|
11
|
+
|
|
12
|
+
required_answer_columns = ["class_id", "x_min", "y_min", "x_max", "y_max", "image_id"]
|
|
13
|
+
for col in required_answer_columns:
|
|
14
|
+
assert col in answers.columns, f"Answers must have a `{col}` column"
|
|
15
|
+
for col in ["x_min", "y_min", "x_max", "y_max"]:
|
|
16
|
+
assert (
|
|
17
|
+
not answers[col].isnull().values.any()
|
|
18
|
+
), f"Answers must not contain any NaN values in `{col}` column, but got {answers[col].isnull().values}"
|
|
19
|
+
|
|
20
|
+
required_submission_columns = ["PredictionString", "image_id"]
|
|
21
|
+
for col in required_submission_columns:
|
|
22
|
+
if col not in submission.columns:
|
|
23
|
+
raise InvalidSubmissionError(f"Submission must have a `{col}` column")
|
|
24
|
+
|
|
25
|
+
if set(submission["image_id"]) != set(answers["image_id"]):
|
|
26
|
+
raise InvalidSubmissionError(
|
|
27
|
+
"The set of image_ids in the submission must match the set of image_ids in the answers"
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
return {"true_df": answers, "pred_df": submission}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def grade(submission: pd.DataFrame, answers: pd.DataFrame) -> float:
|
|
34
|
+
inputs = prepare_for_metric(submission, answers)
|
|
35
|
+
vineval = VinBigDataEval(inputs["true_df"])
|
|
36
|
+
cocoEvalResults = vineval.evaluate(inputs["pred_df"])
|
|
37
|
+
return cocoEvalResults.stats[0]
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class VinBigDataEval:
|
|
41
|
+
"""Helper class for calculating the competition metric.
|
|
42
|
+
|
|
43
|
+
You should remove the duplicated annoatations from the `true_df` dataframe
|
|
44
|
+
before using this script. Otherwise it may give incorrect results.
|
|
45
|
+
|
|
46
|
+
>>> vineval = VinBigDataEval(valid_df)
|
|
47
|
+
>>> cocoEvalResults = vineval.evaluate(pred_df)
|
|
48
|
+
|
|
49
|
+
Arguments:
|
|
50
|
+
true_df: pd.DataFrame Clean (no duplication) Training/Validating dataframe.
|
|
51
|
+
|
|
52
|
+
Authors:
|
|
53
|
+
Peter (https://kaggle.com/pestipeti)
|
|
54
|
+
|
|
55
|
+
See:
|
|
56
|
+
https://www.kaggle.com/pestipeti/competition-metric-map-0-4
|
|
57
|
+
|
|
58
|
+
Returns: None
|
|
59
|
+
|
|
60
|
+
"""
|
|
61
|
+
|
|
62
|
+
def __init__(self, true_df):
|
|
63
|
+
|
|
64
|
+
self.true_df = true_df
|
|
65
|
+
|
|
66
|
+
self.image_ids = true_df["image_id"].unique()
|
|
67
|
+
self.annotations = {
|
|
68
|
+
"type": "instances",
|
|
69
|
+
"images": self.__gen_images(self.image_ids),
|
|
70
|
+
"categories": self.__gen_categories(self.true_df),
|
|
71
|
+
"annotations": self.__gen_annotations(self.true_df, self.image_ids),
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
self.predictions = {
|
|
75
|
+
"images": self.annotations["images"].copy(),
|
|
76
|
+
"categories": self.annotations["categories"].copy(),
|
|
77
|
+
"annotations": None,
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
def __gen_categories(self, df):
|
|
81
|
+
print("Generating category data...")
|
|
82
|
+
|
|
83
|
+
if "class_name" not in df.columns:
|
|
84
|
+
df["class_name"] = df["class_id"]
|
|
85
|
+
|
|
86
|
+
cats = df[["class_name", "class_id"]]
|
|
87
|
+
cats = cats.drop_duplicates().sort_values(by="class_id").values
|
|
88
|
+
|
|
89
|
+
results = []
|
|
90
|
+
|
|
91
|
+
for cat in cats:
|
|
92
|
+
results.append(
|
|
93
|
+
{
|
|
94
|
+
"id": cat[1],
|
|
95
|
+
"name": cat[0],
|
|
96
|
+
"supercategory": "none",
|
|
97
|
+
}
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
return results
|
|
101
|
+
|
|
102
|
+
def __gen_images(self, image_ids):
|
|
103
|
+
print("Generating image data...")
|
|
104
|
+
results = []
|
|
105
|
+
|
|
106
|
+
for idx, image_id in enumerate(image_ids):
|
|
107
|
+
|
|
108
|
+
# Add image identification.
|
|
109
|
+
results.append(
|
|
110
|
+
{
|
|
111
|
+
"id": idx,
|
|
112
|
+
}
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
return results
|
|
116
|
+
|
|
117
|
+
def __gen_annotations(self, df, image_ids):
|
|
118
|
+
print("Generating annotation data...")
|
|
119
|
+
k = 0
|
|
120
|
+
results = []
|
|
121
|
+
|
|
122
|
+
for idx, image_id in enumerate(image_ids):
|
|
123
|
+
|
|
124
|
+
# Add image annotations
|
|
125
|
+
for i, row in df[df["image_id"] == image_id].iterrows():
|
|
126
|
+
|
|
127
|
+
results.append(
|
|
128
|
+
{
|
|
129
|
+
"id": k,
|
|
130
|
+
"image_id": idx,
|
|
131
|
+
"category_id": row["class_id"],
|
|
132
|
+
"bbox": np.array([row["x_min"], row["y_min"], row["x_max"], row["y_max"]]),
|
|
133
|
+
"segmentation": [],
|
|
134
|
+
"ignore": 0,
|
|
135
|
+
"area": (row["x_max"] - row["x_min"]) * (row["y_max"] - row["y_min"]),
|
|
136
|
+
"iscrowd": 0,
|
|
137
|
+
}
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
k += 1
|
|
141
|
+
|
|
142
|
+
return results
|
|
143
|
+
|
|
144
|
+
def __decode_prediction_string(self, pred_str):
|
|
145
|
+
data = list(map(float, pred_str.split(" ")))
|
|
146
|
+
data = np.array(data)
|
|
147
|
+
|
|
148
|
+
return data.reshape(-1, 6)
|
|
149
|
+
|
|
150
|
+
def __gen_predictions(self, df, image_ids):
|
|
151
|
+
print("Generating prediction data...")
|
|
152
|
+
k = 0
|
|
153
|
+
results = []
|
|
154
|
+
|
|
155
|
+
for i, row in df.iterrows():
|
|
156
|
+
|
|
157
|
+
image_id = row["image_id"]
|
|
158
|
+
preds = self.__decode_prediction_string(row["PredictionString"])
|
|
159
|
+
|
|
160
|
+
for j, pred in enumerate(preds):
|
|
161
|
+
|
|
162
|
+
results.append(
|
|
163
|
+
{
|
|
164
|
+
"id": k,
|
|
165
|
+
"image_id": int(np.where(image_ids == image_id)[0]),
|
|
166
|
+
"category_id": int(pred[0]),
|
|
167
|
+
"bbox": np.array([pred[2], pred[3], pred[4], pred[5]]),
|
|
168
|
+
"segmentation": [],
|
|
169
|
+
"ignore": 0,
|
|
170
|
+
"area": (pred[4] - pred[2]) * (pred[5] - pred[3]),
|
|
171
|
+
"iscrowd": 0,
|
|
172
|
+
"score": pred[1],
|
|
173
|
+
}
|
|
174
|
+
)
|
|
175
|
+
|
|
176
|
+
k += 1
|
|
177
|
+
|
|
178
|
+
return results
|
|
179
|
+
|
|
180
|
+
def evaluate(self, pred_df, n_imgs=-1):
|
|
181
|
+
"""Evaluating your results
|
|
182
|
+
|
|
183
|
+
Arguments:
|
|
184
|
+
pred_df: pd.DataFrame your predicted results in the
|
|
185
|
+
competition output format.
|
|
186
|
+
|
|
187
|
+
n_imgs: int Number of images use for calculating the
|
|
188
|
+
result.All of the images if `n_imgs` <= 0
|
|
189
|
+
|
|
190
|
+
Returns:
|
|
191
|
+
COCOEval object
|
|
192
|
+
"""
|
|
193
|
+
|
|
194
|
+
if pred_df is not None:
|
|
195
|
+
self.predictions["annotations"] = self.__gen_predictions(pred_df, self.image_ids)
|
|
196
|
+
|
|
197
|
+
coco_ds = COCO()
|
|
198
|
+
coco_ds.dataset = self.annotations
|
|
199
|
+
coco_ds.createIndex()
|
|
200
|
+
|
|
201
|
+
coco_dt = COCO()
|
|
202
|
+
coco_dt.dataset = self.predictions
|
|
203
|
+
coco_dt.createIndex()
|
|
204
|
+
|
|
205
|
+
imgIds = sorted(coco_ds.getImgIds())
|
|
206
|
+
|
|
207
|
+
if n_imgs > 0:
|
|
208
|
+
imgIds = np.random.choice(imgIds, n_imgs)
|
|
209
|
+
|
|
210
|
+
cocoEval = COCOeval(coco_ds, coco_dt, "bbox")
|
|
211
|
+
cocoEval.params.imgIds = imgIds
|
|
212
|
+
cocoEval.params.useCats = True
|
|
213
|
+
cocoEval.params.iouType = "bbox"
|
|
214
|
+
cocoEval.params.iouThrs = np.array([0.4])
|
|
215
|
+
|
|
216
|
+
cocoEval.evaluate()
|
|
217
|
+
cocoEval.accumulate()
|
|
218
|
+
cocoEval.summarize()
|
|
219
|
+
|
|
220
|
+
return cocoEval
|