diff --git "a/notebooks/ToL_license_check.ipynb" "b/notebooks/ToL_license_check.ipynb" new file mode 100644--- /dev/null +++ "b/notebooks/ToL_license_check.ipynb" @@ -0,0 +1,4723 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [], + "source": [ + "import pandas as pd\n", + "import seaborn as sns\n", + "\n", + "sns.set_style(\"whitegrid\")\n", + "sns.set(rc = {'figure.figsize': (10,10)})" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Load in full images to ease process." + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "df = pd.read_csv(\"../data/predicted-catalog.csv\", low_memory = False)" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
splittreeoflife_ideol_content_ideol_page_idbioscan_partbioscan_filenameinat21_filenameinat21_cls_nameinat21_cls_numkingdomphylumclassorderfamilygenusspeciescommon
0trainf2f0aa29-e87b-469c-bf5b-51a3611ab00122131926.0269504.0NaNNaNNaNNaNNaNAnimaliaArthropodaInsectaLepidopteraLycaenidaeOrthomiellarantaizanaChinese Straight-wing Blue
1train5faa4f55-32e9-4872-953d-567e5d232e5222291283.06101931.0NaNNaNNaNNaNNaNPlantaeTracheophytaPolypodiopsidaPolypodialesWoodsiaceaeWoodsiasubcordataWoodsia subcordata
2train2282f2bf-2b52-4522-b588-dd6f356d5fd621802775.045513632.0NaNNaNNaNNaNNaNAnimaliaChordataAvesPasseriformesLaniidaeLaniusminorLesser Grey Shrike
3train76b57c36-2181-4e6d-a5c4-b40e22a0944912784812.051655800.0NaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNtenuisTenuis
4trainf57d3ab6-2cf5-484b-a590-e2a3d49a3ca229713643.045515896.0NaNNaNNaNNaNNaNAnimaliaChordataAvesCasuariiformesCasuariidaeCasuariuscasuariusSouthern Cassowary
\n", + "
" + ], + "text/plain": [ + " split treeoflife_id eol_content_id eol_page_id \\\n", + "0 train f2f0aa29-e87b-469c-bf5b-51a3611ab001 22131926.0 269504.0 \n", + "1 train 5faa4f55-32e9-4872-953d-567e5d232e52 22291283.0 6101931.0 \n", + "2 train 2282f2bf-2b52-4522-b588-dd6f356d5fd6 21802775.0 45513632.0 \n", + "3 train 76b57c36-2181-4e6d-a5c4-b40e22a09449 12784812.0 51655800.0 \n", + "4 train f57d3ab6-2cf5-484b-a590-e2a3d49a3ca2 29713643.0 45515896.0 \n", + "\n", + " bioscan_part bioscan_filename inat21_filename inat21_cls_name \\\n", + "0 NaN NaN NaN NaN \n", + "1 NaN NaN NaN NaN \n", + "2 NaN NaN NaN NaN \n", + "3 NaN NaN NaN NaN \n", + "4 NaN NaN NaN NaN \n", + "\n", + " inat21_cls_num kingdom phylum class order \\\n", + "0 NaN Animalia Arthropoda Insecta Lepidoptera \n", + "1 NaN Plantae Tracheophyta Polypodiopsida Polypodiales \n", + "2 NaN Animalia Chordata Aves Passeriformes \n", + "3 NaN NaN NaN NaN NaN \n", + "4 NaN Animalia Chordata Aves Casuariiformes \n", + "\n", + " family genus species common \n", + "0 Lycaenidae Orthomiella rantaizana Chinese Straight-wing Blue \n", + "1 Woodsiaceae Woodsia subcordata Woodsia subcordata \n", + "2 Laniidae Lanius minor Lesser Grey Shrike \n", + "3 NaN NaN tenuis Tenuis \n", + "4 Casuariidae Casuarius casuarius Southern Cassowary " + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df.head()" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "RangeIndex: 10092530 entries, 0 to 10092529\n", + "Data columns (total 17 columns):\n", + " # Column Non-Null Count Dtype \n", + "--- ------ -------------- ----- \n", + " 0 split 10092530 non-null object \n", + " 1 treeoflife_id 10092530 non-null object \n", + " 2 eol_content_id 6277374 non-null float64\n", + " 3 eol_page_id 6277374 non-null float64\n", + " 4 bioscan_part 1128313 non-null float64\n", + " 5 bioscan_filename 1128313 non-null object \n", + " 6 inat21_filename 2686843 non-null object \n", + " 7 inat21_cls_name 2686843 non-null object \n", + " 8 inat21_cls_num 2686843 non-null float64\n", + " 9 kingdom 9831721 non-null object \n", + " 10 phylum 9833317 non-null object \n", + " 11 class 9813548 non-null object \n", + " 12 order 9807409 non-null object \n", + " 13 family 9775447 non-null object \n", + " 14 genus 8908268 non-null object \n", + " 15 species 8749857 non-null object \n", + " 16 common 10092530 non-null object \n", + "dtypes: float64(4), object(13)\n", + "memory usage: 1.3+ GB\n" + ] + } + ], + "source": [ + "df.info(show_counts = True)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The `train_small` is duplicates of `train`, so we will drop those to analyze the full training set plus val." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "`predicted-catalog` doesn't have `train_small`, hence, it's a smaller file." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Let's add a column indicating the original data source so we can also get some stats by datasource, specifically focusing on EOL since we know licensing for BIOSCAN-1M and iNat21." + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [], + "source": [ + "# Add data_source column for easier slicing\n", + "df.loc[df['inat21_filename'].notna(), 'data_source'] = 'iNat21'\n", + "df.loc[df['bioscan_filename'].notna(), 'data_source'] = 'BIOSCAN'\n", + "df.loc[df['eol_content_id'].notna(), 'data_source'] = 'EOL'" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### Get just EOL CSV for license addition" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [], + "source": [ + "eol_df = df.loc[df['data_source'] == 'EOL']" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
splittreeoflife_ideol_content_ideol_page_idbioscan_partbioscan_filenameinat21_filenameinat21_cls_nameinat21_cls_numkingdomphylumclassorderfamilygenusspeciescommondata_source
0trainf2f0aa29-e87b-469c-bf5b-51a3611ab00122131926.0269504.0NaNNaNNaNNaNNaNAnimaliaArthropodaInsectaLepidopteraLycaenidaeOrthomiellarantaizanaChinese Straight-wing BlueEOL
1train5faa4f55-32e9-4872-953d-567e5d232e5222291283.06101931.0NaNNaNNaNNaNNaNPlantaeTracheophytaPolypodiopsidaPolypodialesWoodsiaceaeWoodsiasubcordataWoodsia subcordataEOL
2train2282f2bf-2b52-4522-b588-dd6f356d5fd621802775.045513632.0NaNNaNNaNNaNNaNAnimaliaChordataAvesPasseriformesLaniidaeLaniusminorLesser Grey ShrikeEOL
3train76b57c36-2181-4e6d-a5c4-b40e22a0944912784812.051655800.0NaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNtenuisTenuisEOL
4trainf57d3ab6-2cf5-484b-a590-e2a3d49a3ca229713643.045515896.0NaNNaNNaNNaNNaNAnimaliaChordataAvesCasuariiformesCasuariidaeCasuariuscasuariusSouthern CassowaryEOL
\n", + "
" + ], + "text/plain": [ + " split treeoflife_id eol_content_id eol_page_id \\\n", + "0 train f2f0aa29-e87b-469c-bf5b-51a3611ab001 22131926.0 269504.0 \n", + "1 train 5faa4f55-32e9-4872-953d-567e5d232e52 22291283.0 6101931.0 \n", + "2 train 2282f2bf-2b52-4522-b588-dd6f356d5fd6 21802775.0 45513632.0 \n", + "3 train 76b57c36-2181-4e6d-a5c4-b40e22a09449 12784812.0 51655800.0 \n", + "4 train f57d3ab6-2cf5-484b-a590-e2a3d49a3ca2 29713643.0 45515896.0 \n", + "\n", + " bioscan_part bioscan_filename inat21_filename inat21_cls_name \\\n", + "0 NaN NaN NaN NaN \n", + "1 NaN NaN NaN NaN \n", + "2 NaN NaN NaN NaN \n", + "3 NaN NaN NaN NaN \n", + "4 NaN NaN NaN NaN \n", + "\n", + " inat21_cls_num kingdom phylum class order \\\n", + "0 NaN Animalia Arthropoda Insecta Lepidoptera \n", + "1 NaN Plantae Tracheophyta Polypodiopsida Polypodiales \n", + "2 NaN Animalia Chordata Aves Passeriformes \n", + "3 NaN NaN NaN NaN NaN \n", + "4 NaN Animalia Chordata Aves Casuariiformes \n", + "\n", + " family genus species common \\\n", + "0 Lycaenidae Orthomiella rantaizana Chinese Straight-wing Blue \n", + "1 Woodsiaceae Woodsia subcordata Woodsia subcordata \n", + "2 Laniidae Lanius minor Lesser Grey Shrike \n", + "3 NaN NaN tenuis Tenuis \n", + "4 Casuariidae Casuarius casuarius Southern Cassowary \n", + "\n", + " data_source \n", + "0 EOL \n", + "1 EOL \n", + "2 EOL \n", + "3 EOL \n", + "4 EOL " + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "eol_df.head()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "We don't need the BIOSCAN or iNat21 columns, nor the taxa columns." + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "Index(['treeoflife_id', 'eol_content_id', 'eol_page_id'], dtype='object')" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "eol_license_cols = eol_df.columns[1:4]\n", + "eol_license_cols" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, + "outputs": [], + "source": [ + "eol_license_df = eol_df[eol_license_cols]\n", + "#eol_license_df[\"license\"] = None" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "eol_license_df.head()" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": {}, + "outputs": [], + "source": [ + "#eol_license_df.to_csv(\"../data/eol_files/eol_licenses.csv\", index = False)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Merge with Media Manifest to Check for Licenses\n", + "Previous license files (retained below) are missing files, let's merge with the [media manifest](https://huggingface.co/datasets/imageomics/eol/blob/be7b7e6c372f6547e30030e9576d9cc638320099/data/interim/media_manifest.csv) all these images should have been downloaded from to see if there are any here that don't exist in it. From there we'll check licensing info." + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "RangeIndex: 6574224 entries, 0 to 6574223\n", + "Data columns (total 6 columns):\n", + " # Column Non-Null Count Dtype \n", + "--- ------ -------------- ----- \n", + " 0 EOL content ID 6574224 non-null int64 \n", + " 1 EOL page ID 6574224 non-null int64 \n", + " 2 Medium Source URL 6574222 non-null object\n", + " 3 EOL Full-Size Copy URL 6574224 non-null object\n", + " 4 License Name 6574224 non-null object\n", + " 5 Copyright Owner 5942181 non-null object\n", + "dtypes: int64(2), object(4)\n", + "memory usage: 300.9+ MB\n" + ] + } + ], + "source": [ + "media = pd.read_csv(\"../data/media_manifest (july 26).csv\", dtype = {\"EOL content ID\": \"int64\", \"EOL page ID\": \"int64\"}, low_memory = False)\n", + "media.info(show_counts = True)" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": {}, + "outputs": [], + "source": [ + "# Read eol license df back in with type int64 for ID columns\n", + "eol_license_df = pd.read_csv(\"../data/eol_files/eol_licenses.csv\", \n", + " dtype = {\"eol_content_id\": \"int64\", \"eol_page_id\": \"int64\"}, \n", + " low_memory = False)" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "(6020135, 5)" + ] + }, + "execution_count": 13, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "eol_license_df.shape" + ] + }, + { + "cell_type": "code", + "execution_count": 24, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "Index: 6277374 entries, 0 to 6277373\n", + "Data columns (total 18 columns):\n", + " # Column Dtype \n", + "--- ------ ----- \n", + " 0 split object \n", + " 1 treeoflife_id object \n", + " 2 eol_content_id int64 \n", + " 3 eol_page_id int64 \n", + " 4 bioscan_part float64\n", + " 5 bioscan_filename object \n", + " 6 inat21_filename object \n", + " 7 inat21_cls_name object \n", + " 8 inat21_cls_num float64\n", + " 9 kingdom object \n", + " 10 phylum object \n", + " 11 class object \n", + " 12 order object \n", + " 13 family object \n", + " 14 genus object \n", + " 15 species object \n", + " 16 common object \n", + " 17 data_source object \n", + "dtypes: float64(2), int64(2), object(14)\n", + "memory usage: 910.0+ MB\n" + ] + } + ], + "source": [ + "eol_df = eol_df.astype({\"eol_content_id\": \"int64\", \"eol_page_id\": \"int64\"})\n", + "eol_df.info()" + ] + }, + { + "cell_type": "code", + "execution_count": 25, + "metadata": {}, + "outputs": [], + "source": [ + "eol_license_df = eol_df[eol_license_cols]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Notice that we have about 300K more entries in the media manifest, which is about expected from the [comparison of predicted-catalog to the original full list](https://huggingface.co/datasets/imageomics/ToL-EDA/blob/main/notebooks/ToL_predicted-catalog_EDA.ipynb)." + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": {}, + "outputs": [], + "source": [ + "media.rename(columns = {\"EOL content ID\": \"eol_content_id\"}, inplace = True)" + ] + }, + { + "cell_type": "code", + "execution_count": 26, + "metadata": {}, + "outputs": [], + "source": [ + "eol_df_media = pd.merge(eol_license_df, media, how = \"left\", on = \"eol_content_id\")" + ] + }, + { + "cell_type": "code", + "execution_count": 27, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "RangeIndex: 6277374 entries, 0 to 6277373\n", + "Data columns (total 8 columns):\n", + " # Column Non-Null Count Dtype \n", + "--- ------ -------------- ----- \n", + " 0 treeoflife_id 6277374 non-null object \n", + " 1 eol_content_id 6277374 non-null int64 \n", + " 2 eol_page_id_x 6277374 non-null int64 \n", + " 3 eol_page_id_y 6163903 non-null float64\n", + " 4 Medium Source URL 6163903 non-null object \n", + " 5 EOL Full-Size Copy URL 6163903 non-null object \n", + " 6 License Name 6163903 non-null object \n", + " 7 Copyright Owner 5549428 non-null object \n", + "dtypes: float64(1), int64(2), object(5)\n", + "memory usage: 383.1+ MB\n" + ] + } + ], + "source": [ + "eol_df_media.info(show_counts = True)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "We have about 620K images missing copyright owner." + ] + }, + { + "cell_type": "code", + "execution_count": 28, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
treeoflife_ideol_content_ideol_page_id_xeol_page_id_yMedium Source URLEOL Full-Size Copy URLLicense NameCopyright Owner
0f2f0aa29-e87b-469c-bf5b-51a3611ab00122131926269504269504.0https://inaturalist-open-data.s3.amazonaws.com...https://content.eol.org/data/media/6a/ed/7a/18...cc-by-nc-4.0洪廷維
15faa4f55-32e9-4872-953d-567e5d232e522229128361019316101931.0https://inaturalist-open-data.s3.amazonaws.com...https://content.eol.org/data/media/7b/bc/92/18...cc-by-nc-4.0Игорь Поспелов
22282f2bf-2b52-4522-b588-dd6f356d5fd6218027754551363245513632.0https://inaturalist-open-data.s3.amazonaws.com...https://content.eol.org/data/media/66/be/16/18...cc-by-nc-4.0Marina Gorbunova
376b57c36-2181-4e6d-a5c4-b40e22a09449127848125165580051655800.0http://www.femorale.com/shellphotos/photos15/3...https://content.eol.org/data/media/c4/79/dc/14...cc-by-ncFemorale
4f57d3ab6-2cf5-484b-a590-e2a3d49a3ca2297136434551589645515896.0https://upload.wikimedia.org/wikipedia/commons...https://content.eol.org/data/media/5f/ef/95/50...cc-by-sa-3.0NaN
\n", + "
" + ], + "text/plain": [ + " treeoflife_id eol_content_id eol_page_id_x \\\n", + "0 f2f0aa29-e87b-469c-bf5b-51a3611ab001 22131926 269504 \n", + "1 5faa4f55-32e9-4872-953d-567e5d232e52 22291283 6101931 \n", + "2 2282f2bf-2b52-4522-b588-dd6f356d5fd6 21802775 45513632 \n", + "3 76b57c36-2181-4e6d-a5c4-b40e22a09449 12784812 51655800 \n", + "4 f57d3ab6-2cf5-484b-a590-e2a3d49a3ca2 29713643 45515896 \n", + "\n", + " eol_page_id_y Medium Source URL \\\n", + "0 269504.0 https://inaturalist-open-data.s3.amazonaws.com... \n", + "1 6101931.0 https://inaturalist-open-data.s3.amazonaws.com... \n", + "2 45513632.0 https://inaturalist-open-data.s3.amazonaws.com... \n", + "3 51655800.0 http://www.femorale.com/shellphotos/photos15/3... \n", + "4 45515896.0 https://upload.wikimedia.org/wikipedia/commons... \n", + "\n", + " EOL Full-Size Copy URL License Name \\\n", + "0 https://content.eol.org/data/media/6a/ed/7a/18... cc-by-nc-4.0 \n", + "1 https://content.eol.org/data/media/7b/bc/92/18... cc-by-nc-4.0 \n", + "2 https://content.eol.org/data/media/66/be/16/18... cc-by-nc-4.0 \n", + "3 https://content.eol.org/data/media/c4/79/dc/14... cc-by-nc \n", + "4 https://content.eol.org/data/media/5f/ef/95/50... cc-by-sa-3.0 \n", + "\n", + " Copyright Owner \n", + "0 洪廷維 \n", + "1 Игорь Поспелов \n", + "2 Marina Gorbunova \n", + "3 Femorale \n", + "4 NaN " + ] + }, + "execution_count": 28, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "eol_df_media.head()" + ] + }, + { + "cell_type": "code", + "execution_count": 29, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "treeoflife_id 727946\n", + "eol_content_id 727946\n", + "eol_page_id_x 119376\n", + "eol_page_id_y 115564\n", + "Medium Source URL 614089\n", + "EOL Full-Size Copy URL 614475\n", + "License Name 10\n", + "Copyright Owner 0\n", + "dtype: int64" + ] + }, + "execution_count": 29, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "eol_df_media.loc[eol_df_media[\"Copyright Owner\"].isna()].nunique()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The missing info is distributed across 116,609 pages.\n", + "\n", + "There also seems to be a discrepancy in the number of page IDs between these. This lead to duplicated records...definitely something's off." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Check consistency of merge when matching both `eol_content_id` and `eol_page_id`." + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "metadata": {}, + "outputs": [], + "source": [ + "media.rename(columns = {\"EOL page ID\": \"eol_page_id\"}, inplace = True)" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "metadata": {}, + "outputs": [], + "source": [ + "merge_cols = [\"eol_content_id\", \"eol_page_id\"]" + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "RangeIndex: 6163903 entries, 0 to 6163902\n", + "Data columns (total 7 columns):\n", + " # Column Non-Null Count Dtype \n", + "--- ------ -------------- ----- \n", + " 0 treeoflife_id 6163903 non-null object\n", + " 1 eol_content_id 6163903 non-null int64 \n", + " 2 eol_page_id 6163903 non-null int64 \n", + " 3 Medium Source URL 6163903 non-null object\n", + " 4 EOL Full-Size Copy URL 6163903 non-null object\n", + " 5 License Name 6163903 non-null object\n", + " 6 Copyright Owner 5549428 non-null object\n", + "dtypes: int64(2), object(5)\n", + "memory usage: 329.2+ MB\n" + ] + } + ], + "source": [ + "eol_df_media_cp = pd.merge(eol_license_df, media, how = \"inner\", left_on = merge_cols, right_on = merge_cols)\n", + "eol_df_media_cp.info(show_counts = True)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Okay, so we do have a mis-match of about 113K images where the content IDs and page IDs don't both match." + ] + }, + { + "cell_type": "code", + "execution_count": 32, + "metadata": {}, + "outputs": [], + "source": [ + "eol_df_media_cp.to_csv(\"../data/eol_files/eol_cp_match_media.csv\", index = False)" + ] + }, + { + "cell_type": "code", + "execution_count": 33, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['f2f0aa29-e87b-469c-bf5b-51a3611ab001',\n", + " '5faa4f55-32e9-4872-953d-567e5d232e52',\n", + " '2282f2bf-2b52-4522-b588-dd6f356d5fd6',\n", + " '76b57c36-2181-4e6d-a5c4-b40e22a09449',\n", + " 'f57d3ab6-2cf5-484b-a590-e2a3d49a3ca2']" + ] + }, + "execution_count": 33, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "tol_ids_in_media = list(eol_df_media_cp.treeoflife_id)\n", + "tol_ids_in_media[:5]" + ] + }, + { + "cell_type": "code", + "execution_count": 34, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
treeoflife_ideol_content_ideol_page_id
0f2f0aa29-e87b-469c-bf5b-51a3611ab00122131926269504
15faa4f55-32e9-4872-953d-567e5d232e52222912836101931
22282f2bf-2b52-4522-b588-dd6f356d5fd62180277545513632
376b57c36-2181-4e6d-a5c4-b40e22a094491278481251655800
4f57d3ab6-2cf5-484b-a590-e2a3d49a3ca22971364345515896
\n", + "
" + ], + "text/plain": [ + " treeoflife_id eol_content_id eol_page_id\n", + "0 f2f0aa29-e87b-469c-bf5b-51a3611ab001 22131926 269504\n", + "1 5faa4f55-32e9-4872-953d-567e5d232e52 22291283 6101931\n", + "2 2282f2bf-2b52-4522-b588-dd6f356d5fd6 21802775 45513632\n", + "3 76b57c36-2181-4e6d-a5c4-b40e22a09449 12784812 51655800\n", + "4 f57d3ab6-2cf5-484b-a590-e2a3d49a3ca2 29713643 45515896" + ] + }, + "execution_count": 34, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "eol_license_df.head()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Let's save a copy of the EOL section with content and page IDs that are mismatched." + ] + }, + { + "cell_type": "code", + "execution_count": 35, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "Index: 113471 entries, 126 to 6277290\n", + "Data columns (total 3 columns):\n", + " # Column Non-Null Count Dtype \n", + "--- ------ -------------- ----- \n", + " 0 treeoflife_id 113471 non-null object\n", + " 1 eol_content_id 113471 non-null int64 \n", + " 2 eol_page_id 113471 non-null int64 \n", + "dtypes: int64(2), object(1)\n", + "memory usage: 3.5+ MB\n" + ] + } + ], + "source": [ + "eol_df_missing_media = eol_license_df.loc[~eol_license_df.treeoflife_id.isin(tol_ids_in_media)]\n", + "eol_df_missing_media.info(show_counts = True)" + ] + }, + { + "cell_type": "code", + "execution_count": 36, + "metadata": {}, + "outputs": [], + "source": [ + "eol_df_missing_media.to_csv(\"../data/eol_files/eol_cp_not_media.csv\", index = False)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Save Record of Missing Content IDs & Compare to Older Media Manifest\n", + "Let's save a record of the missing content IDs, then we'll compare them to the [July 6 media manifest](https://huggingface.co/datasets/imageomics/eol/blob/eaa00a48fa188f12906c5b8074d60aa8e67eb135/data/interim/media_manifest.csv) to see if any are in there. The July 6 media manifest is smaller, but we'll still check." + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
treeoflife_ideol_content_ideol_page_idEOL page IDMedium Source URLEOL Full-Size Copy URLLicense NameCopyright Owner
1264b56e165-c4d5-49f9-a321-ac9474d099f32753529.01225965.0NaNNaNNaNNaNNaN
174421678a0-c8ec-43c8-815c-fc588883506816288.045514264.0NaNNaNNaNNaNNaN
177be81bd8c-16a7-4911-8279-431245d671952730639.01034220.0NaNNaNNaNNaNNaN
259fc765c82-84e6-437e-b9a5-1c7601c5be812717906.01052077.0NaNNaNNaNNaNNaN
3228c1e6878-47ac-4f7b-8475-73e71c0e99c32836995.0957074.0NaNNaNNaNNaNNaN
\n", + "
" + ], + "text/plain": [ + " treeoflife_id eol_content_id eol_page_id \\\n", + "126 4b56e165-c4d5-49f9-a321-ac9474d099f3 2753529.0 1225965.0 \n", + "174 421678a0-c8ec-43c8-815c-fc5888835068 16288.0 45514264.0 \n", + "177 be81bd8c-16a7-4911-8279-431245d67195 2730639.0 1034220.0 \n", + "259 fc765c82-84e6-437e-b9a5-1c7601c5be81 2717906.0 1052077.0 \n", + "322 8c1e6878-47ac-4f7b-8475-73e71c0e99c3 2836995.0 957074.0 \n", + "\n", + " EOL page ID Medium Source URL EOL Full-Size Copy URL License Name \\\n", + "126 NaN NaN NaN NaN \n", + "174 NaN NaN NaN NaN \n", + "177 NaN NaN NaN NaN \n", + "259 NaN NaN NaN NaN \n", + "322 NaN NaN NaN NaN \n", + "\n", + " Copyright Owner \n", + "126 NaN \n", + "174 NaN \n", + "177 NaN \n", + "259 NaN \n", + "322 NaN " + ] + }, + "execution_count": 11, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "eol_missing_content_ids = eol_df_media.loc[eol_df_media[\"Medium Source URL\"].isna()]\n", + "eol_missing_content_ids.head()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The pages exist (`eol.org/pages/`), but the content IDs do not (`eol.org/media/` produces 404)." + ] + }, + { + "cell_type": "code", + "execution_count": 24, + "metadata": {}, + "outputs": [], + "source": [ + "#eol_missing_content_ids.to_csv(\"../data/eol_files/eol_missing_content_ids.csv\", index = False)" + ] + }, + { + "cell_type": "code", + "execution_count": 47, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/var/folders/nv/f0fq1p1n1_3b11x579py_0q80000gq/T/ipykernel_23442/610094471.py:1: DtypeWarning: Columns (0,1) have mixed types. Specify dtype option on import or set low_memory=False.\n", + " media_old = pd.read_csv(\"../data/media_manifest.csv\")\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "RangeIndex: 5712231 entries, 0 to 5712230\n", + "Data columns (total 6 columns):\n", + " # Column Non-Null Count Dtype \n", + "--- ------ -------------- ----- \n", + " 0 EOL content ID 5712231 non-null object\n", + " 1 EOL page ID 5712163 non-null object\n", + " 2 Medium Source URL 5712163 non-null object\n", + " 3 EOL Full-Size Copy URL 5709587 non-null object\n", + " 4 License Name 5709587 non-null object\n", + " 5 Copyright Owner 4921801 non-null object\n", + "dtypes: object(6)\n", + "memory usage: 261.5+ MB\n" + ] + } + ], + "source": [ + "media_old = pd.read_csv(\"../data/media_manifest.csv\", dtype = {\"EOL content ID\": \"int64\", \"EOL page ID\": \"int64\"}, low_memory = False)\n", + "media_old.info(show_counts = True)" + ] + }, + { + "cell_type": "code", + "execution_count": 48, + "metadata": {}, + "outputs": [], + "source": [ + "media_old.rename(columns = {\"EOL content ID\": \"eol_content_id\"}, inplace = True)" + ] + }, + { + "cell_type": "code", + "execution_count": 27, + "metadata": {}, + "outputs": [], + "source": [ + "eol_df_media_old = pd.merge(eol_missing_content_ids[eol_license_cols], media_old, how = \"left\", on = \"eol_content_id\")" + ] + }, + { + "cell_type": "code", + "execution_count": 28, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "RangeIndex: 113471 entries, 0 to 113470\n", + "Data columns (total 8 columns):\n", + " # Column Non-Null Count Dtype \n", + "--- ------ -------------- ----- \n", + " 0 treeoflife_id 113471 non-null object \n", + " 1 eol_content_id 113471 non-null object \n", + " 2 eol_page_id 113471 non-null float64\n", + " 3 EOL page ID 0 non-null object \n", + " 4 Medium Source URL 0 non-null object \n", + " 5 EOL Full-Size Copy URL 0 non-null object \n", + " 6 License Name 0 non-null object \n", + " 7 Copyright Owner 0 non-null object \n", + "dtypes: float64(1), object(7)\n", + "memory usage: 6.9+ MB\n" + ] + } + ], + "source": [ + "eol_df_media_old.info(show_counts = True)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "No, we do not have any of the missing ones in the older media manifest." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Check how this compares to Catalog \n", + "Let's see if these are all images in TreeOfLife-10M, or a mix between it and Rare Species." + ] + }, + { + "cell_type": "code", + "execution_count": 28, + "metadata": {}, + "outputs": [], + "source": [ + "cat_df = pd.read_csv(\"../data/catalog.csv\", low_memory = False)\n", + "# Remove duplicates in train_small\n", + "cat_df = cat_df.loc[cat_df.split != 'train_small']" + ] + }, + { + "cell_type": "code", + "execution_count": 29, + "metadata": {}, + "outputs": [], + "source": [ + "# Add data_source column for easier slicing\n", + "cat_df.loc[cat_df['inat21_filename'].notna(), 'data_source'] = 'iNat21'\n", + "cat_df.loc[cat_df['bioscan_filename'].notna(), 'data_source'] = 'BIOSCAN'\n", + "cat_df.loc[cat_df['eol_content_id'].notna(), 'data_source'] = 'EOL'" + ] + }, + { + "cell_type": "code", + "execution_count": 30, + "metadata": {}, + "outputs": [], + "source": [ + "eol_cat_df = cat_df.loc[cat_df.data_source == \"EOL\"]" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "RangeIndex: 6250420 entries, 0 to 6250419\n", + "Data columns (total 8 columns):\n", + " # Column Non-Null Count Dtype \n", + "--- ------ -------------- ----- \n", + " 0 treeoflife_id 6250420 non-null object \n", + " 1 eol_content_id 6250420 non-null float64\n", + " 2 eol_page_id 6250420 non-null float64\n", + " 3 EOL page ID 6137845 non-null float64\n", + " 4 Medium Source URL 6137845 non-null object \n", + " 5 EOL Full-Size Copy URL 6137845 non-null object \n", + " 6 License Name 6137845 non-null object \n", + " 7 Copyright Owner 5527063 non-null object \n", + "dtypes: float64(3), object(5)\n", + "memory usage: 381.5+ MB\n" + ] + } + ], + "source": [ + "eol_cat_df_media = pd.merge(eol_cat_df[eol_license_cols], media, how = \"left\", on = \"eol_content_id\")\n", + "eol_cat_df_media.info(show_counts = True)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Looks like the problem is distributed across both datasets." + ] + }, + { + "cell_type": "code", + "execution_count": 33, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "treeoflife_id 112575\n", + "eol_content_id 112575\n", + "eol_page_id 9634\n", + "EOL page ID 0\n", + "Medium Source URL 0\n", + "EOL Full-Size Copy URL 0\n", + "License Name 0\n", + "Copyright Owner 0\n", + "dtype: int64" + ] + }, + "execution_count": 33, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "eol_cat_df_media.loc[eol_cat_df_media[\"Medium Source URL\"].isna()].nunique()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "For `catalog` the missing information is distributed across 9,634 pages, so that's 128 pages (of 400) in the Rare Species dataset that we can't currently match." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### What are the taxa of the missing images?\n", + "\n", + "Let's bring back a version with the taxa and see what we're dealing with on that end without needing to open the pages." + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [], + "source": [ + "cols_of_interest = ['treeoflife_id', 'eol_content_id', 'eol_page_id', \n", + " 'kingdom', 'phylum', 'class', 'order', 'family', \n", + " 'genus', 'species', 'common']" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": {}, + "outputs": [], + "source": [ + "taxa_cols = ['kingdom', 'phylum', 'class', 'order', 'family', \n", + " 'genus', 'species', 'common']" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": {}, + "outputs": [], + "source": [ + "eol_taxa_df_media = pd.merge(eol_df[cols_of_interest], media, how = \"left\", on = \"eol_content_id\")" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "treeoflife_id 113471\n", + "eol_content_id 113471\n", + "eol_page_id 9762\n", + "kingdom 5\n", + "phylum 28\n", + "class 77\n", + "order 390\n", + "family 1483\n", + "genus 5090\n", + "species 6348\n", + "common 9612\n", + "EOL page ID 0\n", + "Medium Source URL 0\n", + "EOL Full-Size Copy URL 0\n", + "License Name 0\n", + "Copyright Owner 0\n", + "dtype: int64" + ] + }, + "execution_count": 13, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "eol_taxa_df_media.loc[eol_taxa_df_media[\"Medium Source URL\"].isna()].nunique()" + ] + }, + { + "cell_type": "code", + "execution_count": 44, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "Index: 113471 entries, 126 to 6277290\n", + "Data columns (total 16 columns):\n", + " # Column Non-Null Count Dtype \n", + "--- ------ -------------- ----- \n", + " 0 treeoflife_id 113471 non-null object \n", + " 1 eol_content_id 113471 non-null float64\n", + " 2 eol_page_id 113471 non-null float64\n", + " 3 kingdom 113405 non-null object \n", + " 4 phylum 113405 non-null object \n", + " 5 class 113372 non-null object \n", + " 6 order 113338 non-null object \n", + " 7 family 113405 non-null object \n", + " 8 genus 113406 non-null object \n", + " 9 species 113457 non-null object \n", + " 10 common 113471 non-null object \n", + " 11 EOL page ID 0 non-null float64\n", + " 12 Medium Source URL 0 non-null object \n", + " 13 EOL Full-Size Copy URL 0 non-null object \n", + " 14 License Name 0 non-null object \n", + " 15 Copyright Owner 0 non-null object \n", + "dtypes: float64(3), object(13)\n", + "memory usage: 14.7+ MB\n" + ] + } + ], + "source": [ + "eol_taxa_df_media.loc[eol_taxa_df_media[\"Medium Source URL\"].isna()].info(show_counts = True)" + ] + }, + { + "cell_type": "code", + "execution_count": 45, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
treeoflife_ideol_content_ideol_page_idkingdomphylumclassorderfamilygenusspeciescommonEOL page IDMedium Source URLEOL Full-Size Copy URLLicense NameCopyright Owner
5025819b5866260-3ec8-4adf-8da6-da093f1e92012771132.046549987.0AnimaliaCnidariaHydrozoaSiphonophoraePhysaliidaePhysaliaphysalisPortuguese man o' warNaNNaNNaNNaNNaN
4258867ae71e91b-7071-4fbf-8d56-ff0559ca81b07285.0582102.0PlantaeTracheophytaMagnoliopsidaMalvalesThymelaeaceaeDircapalustriseastern leatherwoodNaNNaNNaNNaNNaN
2449505ada964c6-8afb-4e05-b5c7-460e8dd6834d2799571.045511466.0AnimaliaChordataAvesPasseriformesHirundinidaeHirundorusticaBarn SwallowNaNNaNNaNNaNNaN
5240810aff0b65c-2610-4706-9b3d-b65237a7f00e2748751.0131100.0AnimaliaArthropodaInsectaOdonataLibellulidaeSympetruminternumCherry-faced MeadowhawkNaNNaNNaNNaNNaN
4893709cabdd720-d556-464f-b396-747caabc67e72722669.045511162.0AnimaliaChordataAvesPasseriformesIcteridaeEuphaguscyanocephalusBrewer's BlackbirdNaNNaNNaNNaNNaN
5294957e1dd97d8-9aab-46c3-8f9b-4dd85ec10a672764262.045509079.0AnimaliaChordataAvesAccipitriformesPandionidaePandionhaliaetusOspreyNaNNaNNaNNaNNaN
1686233cdc48e2a-a0ac-4974-bf06-2bc807f027292730603.01034199.0AnimaliaArthropodaInsectaOdonataLestidaeLestesinaequalisElegant SpreadwingNaNNaNNaNNaNNaN
\n", + "
" + ], + "text/plain": [ + " treeoflife_id eol_content_id eol_page_id \n", + "5025819 b5866260-3ec8-4adf-8da6-da093f1e9201 2771132.0 46549987.0 \\\n", + "4258867 ae71e91b-7071-4fbf-8d56-ff0559ca81b0 7285.0 582102.0 \n", + "2449505 ada964c6-8afb-4e05-b5c7-460e8dd6834d 2799571.0 45511466.0 \n", + "5240810 aff0b65c-2610-4706-9b3d-b65237a7f00e 2748751.0 131100.0 \n", + "4893709 cabdd720-d556-464f-b396-747caabc67e7 2722669.0 45511162.0 \n", + "5294957 e1dd97d8-9aab-46c3-8f9b-4dd85ec10a67 2764262.0 45509079.0 \n", + "1686233 cdc48e2a-a0ac-4974-bf06-2bc807f02729 2730603.0 1034199.0 \n", + "\n", + " kingdom phylum class order \n", + "5025819 Animalia Cnidaria Hydrozoa Siphonophorae \\\n", + "4258867 Plantae Tracheophyta Magnoliopsida Malvales \n", + "2449505 Animalia Chordata Aves Passeriformes \n", + "5240810 Animalia Arthropoda Insecta Odonata \n", + "4893709 Animalia Chordata Aves Passeriformes \n", + "5294957 Animalia Chordata Aves Accipitriformes \n", + "1686233 Animalia Arthropoda Insecta Odonata \n", + "\n", + " family genus species common \n", + "5025819 Physaliidae Physalia physalis Portuguese man o' war \\\n", + "4258867 Thymelaeaceae Dirca palustris eastern leatherwood \n", + "2449505 Hirundinidae Hirundo rustica Barn Swallow \n", + "5240810 Libellulidae Sympetrum internum Cherry-faced Meadowhawk \n", + "4893709 Icteridae Euphagus cyanocephalus Brewer's Blackbird \n", + "5294957 Pandionidae Pandion haliaetus Osprey \n", + "1686233 Lestidae Lestes inaequalis Elegant Spreadwing \n", + "\n", + " EOL page ID Medium Source URL EOL Full-Size Copy URL License Name \n", + "5025819 NaN NaN NaN NaN \\\n", + "4258867 NaN NaN NaN NaN \n", + "2449505 NaN NaN NaN NaN \n", + "5240810 NaN NaN NaN NaN \n", + "4893709 NaN NaN NaN NaN \n", + "5294957 NaN NaN NaN NaN \n", + "1686233 NaN NaN NaN NaN \n", + "\n", + " Copyright Owner \n", + "5025819 NaN \n", + "4258867 NaN \n", + "2449505 NaN \n", + "5240810 NaN \n", + "4893709 NaN \n", + "5294957 NaN \n", + "1686233 NaN " + ] + }, + "execution_count": 45, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "eol_taxa_df_media.loc[eol_taxa_df_media[\"Medium Source URL\"].isna()].sample(7)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Save a copy of the missing content IDs with taxa info as well." + ] + }, + { + "cell_type": "code", + "execution_count": 49, + "metadata": {}, + "outputs": [], + "source": [ + "#eol_taxa_df_media.loc[eol_taxa_df_media[\"Medium Source URL\"].isna()].to_csv(\"../data/eol_files/eol_taxa_missing_content_ids.csv\", index = False)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "And in `catalog`..." + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "treeoflife_id 112575\n", + "eol_content_id 112575\n", + "eol_page_id 9634\n", + "kingdom 5\n", + "phylum 28\n", + "class 77\n", + "order 388\n", + "family 1475\n", + "genus 5037\n", + "species 6279\n", + "common 9486\n", + "EOL page ID 0\n", + "Medium Source URL 0\n", + "EOL Full-Size Copy URL 0\n", + "License Name 0\n", + "Copyright Owner 0\n", + "dtype: int64" + ] + }, + "execution_count": 17, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "eol_cat_df_taxa_media = pd.merge(eol_cat_df[cols_of_interest], media, how = \"left\", on = \"eol_content_id\")\n", + "eol_cat_df_taxa_media.loc[eol_cat_df_taxa_media[\"Medium Source URL\"].isna()].nunique()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Alright, so it's 2 orders in Rare species." + ] + }, + { + "cell_type": "code", + "execution_count": 46, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "Index: 112575 entries, 46 to 6250267\n", + "Data columns (total 16 columns):\n", + " # Column Non-Null Count Dtype \n", + "--- ------ -------------- ----- \n", + " 0 treeoflife_id 112575 non-null object \n", + " 1 eol_content_id 112575 non-null float64\n", + " 2 eol_page_id 112575 non-null float64\n", + " 3 kingdom 112509 non-null object \n", + " 4 phylum 112509 non-null object \n", + " 5 class 112476 non-null object \n", + " 6 order 112442 non-null object \n", + " 7 family 112509 non-null object \n", + " 8 genus 112510 non-null object \n", + " 9 species 112561 non-null object \n", + " 10 common 112575 non-null object \n", + " 11 EOL page ID 0 non-null float64\n", + " 12 Medium Source URL 0 non-null object \n", + " 13 EOL Full-Size Copy URL 0 non-null object \n", + " 14 License Name 0 non-null object \n", + " 15 Copyright Owner 0 non-null object \n", + "dtypes: float64(3), object(13)\n", + "memory usage: 14.6+ MB\n" + ] + } + ], + "source": [ + "eol_cat_df_taxa_media.loc[eol_cat_df_taxa_media[\"Medium Source URL\"].isna()].info(show_counts = True)" + ] + }, + { + "cell_type": "code", + "execution_count": 48, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
treeoflife_ideol_content_ideol_page_idkingdomphylumclassorderfamilygenusspeciescommonEOL page IDMedium Source URLEOL Full-Size Copy URLLicense NameCopyright Owner
5178613b04e0405-7730-4dcf-8779-68362fa834712770531.0600011.0AnimaliaArthropodaInsectaHymenopteraMutillidaeDasymutillaoccidentalisCommon Eastern Velvet AntNaNNaNNaNNaNNaN
41263638523ccaa-9663-478c-a7b3-f9ab5cbf5b736547.046561653.0AnimaliaChordataActinopterygiiAnguilliformesMuraenidaeGymnothoraxfavagineusHoneycomb MorayNaNNaNNaNNaNNaN
3014219e3b54c94-4cb3-4e6f-85d8-eca8954f7d262756222.047044692.0AnimaliaChordataReptiliaSquamataDactyloidaeAnolissagreiBrown AnoleNaNNaNNaNNaNNaN
5830687a00c0349-4521-4e10-b111-902a5e6daee12744723.046581146.0AnimaliaChordataTeleosteiPerciformesPomacanthidaePomacanthussexstriatussixbanded angelfishNaNNaNNaNNaNNaN
\n", + "
" + ], + "text/plain": [ + " treeoflife_id eol_content_id eol_page_id \n", + "5178613 b04e0405-7730-4dcf-8779-68362fa83471 2770531.0 600011.0 \\\n", + "4126363 8523ccaa-9663-478c-a7b3-f9ab5cbf5b73 6547.0 46561653.0 \n", + "3014219 e3b54c94-4cb3-4e6f-85d8-eca8954f7d26 2756222.0 47044692.0 \n", + "5830687 a00c0349-4521-4e10-b111-902a5e6daee1 2744723.0 46581146.0 \n", + "\n", + " kingdom phylum class order family \n", + "5178613 Animalia Arthropoda Insecta Hymenoptera Mutillidae \\\n", + "4126363 Animalia Chordata Actinopterygii Anguilliformes Muraenidae \n", + "3014219 Animalia Chordata Reptilia Squamata Dactyloidae \n", + "5830687 Animalia Chordata Teleostei Perciformes Pomacanthidae \n", + "\n", + " genus species common EOL page ID \n", + "5178613 Dasymutilla occidentalis Common Eastern Velvet Ant NaN \\\n", + "4126363 Gymnothorax favagineus Honeycomb Moray NaN \n", + "3014219 Anolis sagrei Brown Anole NaN \n", + "5830687 Pomacanthus sexstriatus sixbanded angelfish NaN \n", + "\n", + " Medium Source URL EOL Full-Size Copy URL License Name Copyright Owner \n", + "5178613 NaN NaN NaN NaN \n", + "4126363 NaN NaN NaN NaN \n", + "3014219 NaN NaN NaN NaN \n", + "5830687 NaN NaN NaN NaN " + ] + }, + "execution_count": 48, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "eol_cat_df_taxa_media.loc[eol_cat_df_taxa_media[\"Medium Source URL\"].isna()].sample(4)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Compare Media Cargo\n", + "Media cargo is all images we downloaded from EOL 29 July 2023, so should match to `predicted-catalog`." + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "RangeIndex: 6724838 entries, 0 to 6724837\n", + "Data columns (total 3 columns):\n", + " # Column Non-Null Count Dtype \n", + "--- ------ -------------- ----- \n", + " 0 EOL content ID 6724838 non-null int64 \n", + " 1 EOL page ID 6724838 non-null int64 \n", + " 2 URL Type 6724838 non-null object\n", + "dtypes: int64(2), object(1)\n", + "memory usage: 153.9+ MB\n" + ] + } + ], + "source": [ + "cargo = pd.read_csv(\"../data/eol_media_cargo_names.csv\", dtype = {\"EOL content ID\": \"int64\", \"EOL page ID\": \"int64\"})\n", + "cargo.info(show_counts = True)" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "EOL content ID 6724838\n", + "EOL page ID 580866\n", + "URL Type 1\n", + "dtype: int64" + ] + }, + "execution_count": 20, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "cargo.nunique()" + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
EOL content IDEOL page IDURL Type
02953837465414274eol-full-size-copy
127793900888015eol-full-size-copy
2291216415618956eol-full-size-copy
327596176607817eol-full-size-copy
420300703267922eol-full-size-copy
\n", + "
" + ], + "text/plain": [ + " EOL content ID EOL page ID URL Type\n", + "0 29538374 65414274 eol-full-size-copy\n", + "1 27793900 888015 eol-full-size-copy\n", + "2 29121641 5618956 eol-full-size-copy\n", + "3 27596176 607817 eol-full-size-copy\n", + "4 20300703 267922 eol-full-size-copy" + ] + }, + "execution_count": 21, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "cargo.head()" + ] + }, + { + "cell_type": "code", + "execution_count": 24, + "metadata": {}, + "outputs": [], + "source": [ + "cargo.rename(columns = {\"EOL content ID\": \"eol_content_id\"}, inplace = True)\n", + "eol_df_cargo = pd.merge(eol_license_df, cargo, how = \"left\", on = \"eol_content_id\")" + ] + }, + { + "cell_type": "code", + "execution_count": 25, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "RangeIndex: 6277374 entries, 0 to 6277373\n", + "Data columns (total 5 columns):\n", + " # Column Non-Null Count Dtype \n", + "--- ------ -------------- ----- \n", + " 0 treeoflife_id 6277374 non-null object \n", + " 1 eol_content_id 6277374 non-null float64\n", + " 2 eol_page_id 6277374 non-null float64\n", + " 3 EOL page ID 6276741 non-null float64\n", + " 4 URL Type 6276741 non-null object \n", + "dtypes: float64(3), object(2)\n", + "memory usage: 239.5+ MB\n" + ] + } + ], + "source": [ + "eol_df_cargo.info(show_counts = True)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "There seem to be 633 images here that aren't listed in the media cargo.\n", + "\n", + "What about in catalog?" + ] + }, + { + "cell_type": "code", + "execution_count": 27, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "RangeIndex: 6250420 entries, 0 to 6250419\n", + "Data columns (total 5 columns):\n", + " # Column Non-Null Count Dtype \n", + "--- ------ -------------- ----- \n", + " 0 treeoflife_id 6250420 non-null object \n", + " 1 eol_content_id 6250420 non-null float64\n", + " 2 eol_page_id 6250420 non-null float64\n", + " 3 EOL page ID 6249787 non-null float64\n", + " 4 URL Type 6249787 non-null object \n", + "dtypes: float64(3), object(2)\n", + "memory usage: 238.4+ MB\n" + ] + } + ], + "source": [ + "eol_cat_cargo = pd.merge(eol_cat_df[eol_license_cols], cargo, how = \"left\", on = \"eol_content_id\")\n", + "eol_cat_cargo.info(show_counts = True)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Still missing 633 images...so we know it's not part of the Rare Species dataset, but is TreeOfLife-10M..." + ] + }, + { + "cell_type": "code", + "execution_count": 26, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "RangeIndex: 6574224 entries, 0 to 6574223\n", + "Data columns (total 8 columns):\n", + " # Column Non-Null Count Dtype \n", + "--- ------ -------------- ----- \n", + " 0 eol_content_id 6574224 non-null int64 \n", + " 1 EOL page ID_x 6547356 non-null float64\n", + " 2 URL Type 6547356 non-null object \n", + " 3 EOL page ID_y 6574224 non-null int64 \n", + " 4 Medium Source URL 6574222 non-null object \n", + " 5 EOL Full-Size Copy URL 6574224 non-null object \n", + " 6 License Name 6574224 non-null object \n", + " 7 Copyright Owner 5942181 non-null object \n", + "dtypes: float64(1), int64(2), object(5)\n", + "memory usage: 401.3+ MB\n" + ] + } + ], + "source": [ + "media_in_cargo = pd.merge(cargo, media, how = \"right\", on = \"eol_content_id\")\n", + "media_in_cargo.info(show_counts = True)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "But there are 26,868 images in media manifest that are not in cargo (or at least the content ID's aren't), despite the media cargo having 154K more images listed." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Compare to Newer Media Manifest\n", + "\n", + "We will load in a [new media manifest](https://huggingface.co/datasets/imageomics/eol/blob/3aa274067fc4a18877fb394b1d49a92962c57ed8/data/interim/media_manifest_Dec6.csv) (downloaded Dec. 6) to match up `page_id`s for the missing `content_id`s. This way we can download the images and compare via MD5 checksums to hopefully map the new `content_id`s to the old. (See [discussion #18](https://huggingface.co/datasets/imageomics/eol/discussions/18) in [EOL Repo](https://huggingface.co/datasets/imageomics/eol).)" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "RangeIndex: 6576247 entries, 0 to 6576246\n", + "Data columns (total 6 columns):\n", + " # Column Non-Null Count Dtype \n", + "--- ------ -------------- ----- \n", + " 0 EOL content ID 6576247 non-null int64 \n", + " 1 EOL page ID 6576247 non-null int64 \n", + " 2 Medium Source URL 6576245 non-null object\n", + " 3 EOL Full-Size Copy URL 6576247 non-null object\n", + " 4 License Name 6576247 non-null object\n", + " 5 Copyright Owner 5944184 non-null object\n", + "dtypes: int64(2), object(4)\n", + "memory usage: 301.0+ MB\n" + ] + } + ], + "source": [ + "media_new = pd.read_csv(\"../data/media_manifest_Dec6.csv\", dtype = {\"EOL content ID\": \"int64\", \"EOL page ID\": \"int64\"}, low_memory = False)\n", + "media_new.info(show_counts = True)" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
EOL content IDEOL page IDMedium Source URLEOL Full-Size Copy URLLicense NameCopyright Owner
05470022500901http://entnemdept.ufl.edu/walker/buzz/487dmj.gifhttps://content.eol.org/data/media/54/67/bb/80...cc-by-nc-sa-3.0Susan A. Wineriter/Singing Insects of North Am...
15470023858799http://entnemdept.ufl.edu/walker/buzz/291pm.jpghttps://content.eol.org/data/media/54/67/6a/80...cc-by-nc-sa-3.0Thomas J. Walker/Singing Insects of North America
25470024598702http://entnemdept.ufl.edu/walker/buzz/539pm.jpghttps://content.eol.org/data/media/54/67/d9/80...cc-by-nc-sa-3.0Thomas J. Walker/Singing Insects of North America
35470025598703http://entnemdept.ufl.edu/walker/buzz/540pm.jpghttps://content.eol.org/data/media/54/67/da/80...cc-by-nc-sa-3.0Thomas J. Walker/Singing Insects of North America
45470026598703http://entnemdept.ufl.edu/walker/buzz/540pm2.jpghttps://content.eol.org/data/media/54/67/db/80...cc-by-nc-sa-3.0Thomas J. Walker/Singing Insects of North America
\n", + "
" + ], + "text/plain": [ + " EOL content ID EOL page ID \\\n", + "0 5470022 500901 \n", + "1 5470023 858799 \n", + "2 5470024 598702 \n", + "3 5470025 598703 \n", + "4 5470026 598703 \n", + "\n", + " Medium Source URL \\\n", + "0 http://entnemdept.ufl.edu/walker/buzz/487dmj.gif \n", + "1 http://entnemdept.ufl.edu/walker/buzz/291pm.jpg \n", + "2 http://entnemdept.ufl.edu/walker/buzz/539pm.jpg \n", + "3 http://entnemdept.ufl.edu/walker/buzz/540pm.jpg \n", + "4 http://entnemdept.ufl.edu/walker/buzz/540pm2.jpg \n", + "\n", + " EOL Full-Size Copy URL License Name \\\n", + "0 https://content.eol.org/data/media/54/67/bb/80... cc-by-nc-sa-3.0 \n", + "1 https://content.eol.org/data/media/54/67/6a/80... cc-by-nc-sa-3.0 \n", + "2 https://content.eol.org/data/media/54/67/d9/80... cc-by-nc-sa-3.0 \n", + "3 https://content.eol.org/data/media/54/67/da/80... cc-by-nc-sa-3.0 \n", + "4 https://content.eol.org/data/media/54/67/db/80... cc-by-nc-sa-3.0 \n", + "\n", + " Copyright Owner \n", + "0 Susan A. Wineriter/Singing Insects of North Am... \n", + "1 Thomas J. Walker/Singing Insects of North America \n", + "2 Thomas J. Walker/Singing Insects of North America \n", + "3 Thomas J. Walker/Singing Insects of North America \n", + "4 Thomas J. Walker/Singing Insects of North America " + ] + }, + "execution_count": 15, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "media_new.head()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "To allow for easier sanity-check on the matches, we'll use the version of missing info list with taxa included." + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
treeoflife_ideol_content_ideol_page_idkingdomphylumclassorderfamilygenusspeciescommonEOL page IDMedium Source URLEOL Full-Size Copy URLLicense NameCopyright Owner
1264b56e165-c4d5-49f9-a321-ac9474d099f32753529.01225965.0AnimaliaChordataReptiliaSquamataColubridaeOpheodrysaestivusNorthern Rough GreensnakeNaNNaNNaNNaNNaN
174421678a0-c8ec-43c8-815c-fc588883506816288.045514264.0AnimaliaChordataAvesPasseriformesLaniidaeLaniusexcubitorGreat Grey ShrikeNaNNaNNaNNaNNaN
177be81bd8c-16a7-4911-8279-431245d671952730639.01034220.0AnimaliaArthropodaInsectaOdonataLestidaeLestesrectangularisSlender SpreadwingNaNNaNNaNNaNNaN
259fc765c82-84e6-437e-b9a5-1c7601c5be812717906.01052077.0AnimaliaChordataAvesPasseriformesCardinalidaePheucticusmelanocephalusBlack-headed GrosbeakNaNNaNNaNNaNNaN
3228c1e6878-47ac-4f7b-8475-73e71c0e99c32836995.0957074.0AnimaliaArthropodaInsectaLepidopteraPsychidaeThyridopteryxephemeraeformisEvergreen BagwormNaNNaNNaNNaNNaN
\n", + "
" + ], + "text/plain": [ + " treeoflife_id eol_content_id eol_page_id \\\n", + "126 4b56e165-c4d5-49f9-a321-ac9474d099f3 2753529.0 1225965.0 \n", + "174 421678a0-c8ec-43c8-815c-fc5888835068 16288.0 45514264.0 \n", + "177 be81bd8c-16a7-4911-8279-431245d67195 2730639.0 1034220.0 \n", + "259 fc765c82-84e6-437e-b9a5-1c7601c5be81 2717906.0 1052077.0 \n", + "322 8c1e6878-47ac-4f7b-8475-73e71c0e99c3 2836995.0 957074.0 \n", + "\n", + " kingdom phylum class order family \\\n", + "126 Animalia Chordata Reptilia Squamata Colubridae \n", + "174 Animalia Chordata Aves Passeriformes Laniidae \n", + "177 Animalia Arthropoda Insecta Odonata Lestidae \n", + "259 Animalia Chordata Aves Passeriformes Cardinalidae \n", + "322 Animalia Arthropoda Insecta Lepidoptera Psychidae \n", + "\n", + " genus species common EOL page ID \\\n", + "126 Opheodrys aestivus Northern Rough Greensnake NaN \n", + "174 Lanius excubitor Great Grey Shrike NaN \n", + "177 Lestes rectangularis Slender Spreadwing NaN \n", + "259 Pheucticus melanocephalus Black-headed Grosbeak NaN \n", + "322 Thyridopteryx ephemeraeformis Evergreen Bagworm NaN \n", + "\n", + " Medium Source URL EOL Full-Size Copy URL License Name Copyright Owner \n", + "126 NaN NaN NaN NaN \n", + "174 NaN NaN NaN NaN \n", + "177 NaN NaN NaN NaN \n", + "259 NaN NaN NaN NaN \n", + "322 NaN NaN NaN NaN " + ] + }, + "execution_count": 16, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "eol_taxa_df_missing_media = eol_taxa_df_media.loc[eol_taxa_df_media[\"Medium Source URL\"].isna()]\n", + "eol_taxa_df_missing_media.head()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Rename `EOL content ID` and `EOL page ID` columns to match our `eol_taxa_df_missing_media` for easier merging." + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "metadata": {}, + "outputs": [], + "source": [ + "media_new.rename(columns = {\"EOL content ID\": \"eol_content_id\", \"EOL page ID\": \"eol_page_id\"}, inplace = True)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "First check for any matching content IDs" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "RangeIndex: 113471 entries, 0 to 113470\n", + "Data columns (total 16 columns):\n", + " # Column Non-Null Count Dtype \n", + "--- ------ -------------- ----- \n", + " 0 treeoflife_id 113471 non-null object \n", + " 1 eol_content_id 113471 non-null float64\n", + " 2 eol_page_id_x 113471 non-null float64\n", + " 3 kingdom 113405 non-null object \n", + " 4 phylum 113405 non-null object \n", + " 5 class 113372 non-null object \n", + " 6 order 113338 non-null object \n", + " 7 family 113405 non-null object \n", + " 8 genus 113406 non-null object \n", + " 9 species 113457 non-null object \n", + " 10 common 113471 non-null object \n", + " 11 eol_page_id_y 0 non-null float64\n", + " 12 Medium Source URL 0 non-null object \n", + " 13 EOL Full-Size Copy URL 0 non-null object \n", + " 14 License Name 0 non-null object \n", + " 15 Copyright Owner 0 non-null object \n", + "dtypes: float64(3), object(13)\n", + "memory usage: 13.9+ MB\n" + ] + } + ], + "source": [ + "eol_taxa_df_missing_media_new_check = pd.merge(eol_taxa_df_missing_media[cols_of_interest], media_new, how = \"left\", on = \"eol_content_id\")\n", + "eol_taxa_df_missing_media_new_check.info(show_counts = True)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Yes, there are no matching content IDs here.\n", + "\n", + "Now, let's get our match on page IDs to check they are all listed still for download." + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "There are 9762 unique page ids that have missing content ids, and there are 577900 total page ids in the new media manifest.\n" + ] + } + ], + "source": [ + "pg_ids_missing_content = set(eol_taxa_df_missing_media.eol_page_id)\n", + "pg_ids_media_new = set(media_new.eol_page_id)\n", + "\n", + "print(f\"There are {len(pg_ids_missing_content)} unique page ids that have missing content ids, and there are {len(pg_ids_media_new)} total page ids in the new media manifest.\")\n", + " " + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "152\n" + ] + } + ], + "source": [ + "missing_pgs = []\n", + "for pg in pg_ids_missing_content:\n", + " if pg not in pg_ids_media_new:\n", + " missing_pgs.append(pg)\n", + "print(len(missing_pgs))" + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "There are 577732 total page ids in the July 26 media manifest.\n", + "152\n" + ] + } + ], + "source": [ + "media.rename(columns = {\"EOL page ID\": \"eol_page_id\"}, inplace = True)\n", + "pg_ids_media = set(media.eol_page_id)\n", + "\n", + "print(f\"There are {len(pg_ids_media)} total page ids in the July 26 media manifest.\")\n", + "\n", + "missing_pgs_jul26 = []\n", + "for pg in pg_ids_missing_content:\n", + " if pg not in pg_ids_media:\n", + " missing_pgs_jul26.append(pg)\n", + "print(len(missing_pgs_jul26))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "There seem to be 152 page IDs that don't match to either manifest." + ] + }, + { + "cell_type": "code", + "execution_count": 22, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[47186210.0,\n", + " 47186225.0,\n", + " 46334362.0,\n", + " 47186380.0,\n", + " 47121005.0,\n", + " 1082047.0,\n", + " 5341906.0,\n", + " 131804.0,\n", + " 47187121.0,\n", + " 5015679.0]" + ] + }, + "execution_count": 22, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "missing_pgs[:10]" + ] + }, + { + "cell_type": "code", + "execution_count": 27, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "152\n", + "[47186210, 47186225, 46334362, 47186380, 47121005]\n" + ] + } + ], + "source": [ + "# Why are these floats...does it matter?\n", + "missing_pgs_int = [int(pg) for pg in missing_pgs]\n", + "\n", + "int_missing_pgs = []\n", + "for pg in missing_pgs_int:\n", + " if pg not in pg_ids_media_new:\n", + " int_missing_pgs.append(pg)\n", + "print(len(int_missing_pgs))\n", + "print(int_missing_pgs[:5])" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "It does not matter. There seem to be 152 missing pages, let's try making a couple into URLs...\n", + "\n", + "The first has a page (https://eol.org/pages/47186210) without images. Let's compare these 152 page IDs to our `category.csv` page IDs. Maybe these were not added because there were no images (still odd they exist in `predicted-category.csv`, but not in the manifest)." + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "There are 503589 total page ids in the July 26 media manifest.\n", + "0\n" + ] + } + ], + "source": [ + "cat_pgs = set(eol_cat_df.eol_page_id)\n", + "\n", + "print(f\"There are {len(cat_pgs)} total page ids in the July 26 media manifest.\")\n", + "\n", + "missing_cat_pgs = []\n", + "for pg in missing_pgs:\n", + " if pg not in cat_pgs:\n", + " missing_cat_pgs.append(pg)\n", + "print(len(missing_cat_pgs))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Nope, these are all in `category.csv`.\n", + "\n", + "Another no image page (https://eol.org/pages/47186225), [this](https://eol.org/pages/46334362) has more data, but still no images. https://eol.org/pages/47186380 & https://eol.org/pages/47121005 also don't show any images.\n", + "\n", + "Seems the images for all of these were removed or moved to other pages...\n", + "\n", + "Let's make a CSV for the missing pages to check that we do indeed have the images (sanity check), and we can compare the taxa!" + ] + }, + { + "cell_type": "code", + "execution_count": 34, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "Index: 577 entries, 4850 to 6260647\n", + "Data columns (total 11 columns):\n", + " # Column Non-Null Count Dtype \n", + "--- ------ -------------- ----- \n", + " 0 treeoflife_id 577 non-null object \n", + " 1 eol_content_id 577 non-null float64\n", + " 2 eol_page_id 577 non-null float64\n", + " 3 kingdom 514 non-null object \n", + " 4 phylum 514 non-null object \n", + " 5 class 508 non-null object \n", + " 6 order 508 non-null object \n", + " 7 family 514 non-null object \n", + " 8 genus 515 non-null object \n", + " 9 species 577 non-null object \n", + " 10 common 577 non-null object \n", + "dtypes: float64(2), object(9)\n", + "memory usage: 54.1+ KB\n" + ] + } + ], + "source": [ + "missing_pgs_df = eol_taxa_df_missing_media.loc[eol_taxa_df_missing_media[\"eol_page_id\"].isin(missing_pgs)]\n", + "missing_pgs_df = missing_pgs_df[cols_of_interest]\n", + "missing_pgs_df.info()" + ] + }, + { + "cell_type": "code", + "execution_count": 35, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
treeoflife_ideol_content_ideol_page_idkingdomphylumclassorderfamilygenusspeciescommon
1777659fee72f98-0e52-407d-9b95-2c423dba24ca7745.047188355.0PlantaeTracheophytaMagnoliopsidaAsteralesAsteraceaeErigeronacernarrowleaf fleabane
4173487d2a6ccaa-da99-464c-85e5-ff08a17f2dac2779265.04446364.0AnimaliaChordataMammaliaArtiodactylaCervidaeCervuselaphusYarkand deer
4495906ff5dc70d-6816-4f4d-b7e4-207bc16622c12779346.04446364.0AnimaliaChordataMammaliaArtiodactylaCervidaeCervuselaphusYarkand deer
1594880bd322026-611d-4187-a2c4-c3c3cf43c2f614802.047043911.0AnimaliaChordataNaNNaNCeratopsidaeTriceratopsserratusTriceratops serratus
5128557f36325a0-c815-40f4-ad3d-188389897ae82740131.047364113.0AnimaliaChordataActinopterygiiLabriformesLabridaeNotolabrustetricusRotfish
2698612bc4df6ef-0176-47d9-9c83-e91478a67c692779357.04446364.0AnimaliaChordataMammaliaArtiodactylaCervidaeCervuselaphusYarkand deer
10524888aaf93d1-0b47-475c-b7f2-ce6227b002072800926.047370127.0NaNNaNNaNNaNNaNNaNnipponicaNipponica
378312609cbab95-760d-4175-b495-82a38d6a865a7955.05523149.0PlantaeTracheophytaMagnoliopsidaRanunculalesRanunculaceaeRanunculusacutilobusRanunculus acutilobus
2211057869f72dd-5640-417a-9278-5d5719505bd02779220.04446364.0AnimaliaChordataMammaliaArtiodactylaCervidaeCervuselaphusYarkand deer
604305a9555b8e-d52f-4bcb-aee2-38354de6e92e2779222.04446364.0AnimaliaChordataMammaliaArtiodactylaCervidaeCervuselaphusYarkand deer
\n", + "
" + ], + "text/plain": [ + " treeoflife_id eol_content_id eol_page_id \\\n", + "1777659 fee72f98-0e52-407d-9b95-2c423dba24ca 7745.0 47188355.0 \n", + "4173487 d2a6ccaa-da99-464c-85e5-ff08a17f2dac 2779265.0 4446364.0 \n", + "4495906 ff5dc70d-6816-4f4d-b7e4-207bc16622c1 2779346.0 4446364.0 \n", + "1594880 bd322026-611d-4187-a2c4-c3c3cf43c2f6 14802.0 47043911.0 \n", + "5128557 f36325a0-c815-40f4-ad3d-188389897ae8 2740131.0 47364113.0 \n", + "2698612 bc4df6ef-0176-47d9-9c83-e91478a67c69 2779357.0 4446364.0 \n", + "1052488 8aaf93d1-0b47-475c-b7f2-ce6227b00207 2800926.0 47370127.0 \n", + "3783126 09cbab95-760d-4175-b495-82a38d6a865a 7955.0 5523149.0 \n", + "2211057 869f72dd-5640-417a-9278-5d5719505bd0 2779220.0 4446364.0 \n", + "604305 a9555b8e-d52f-4bcb-aee2-38354de6e92e 2779222.0 4446364.0 \n", + "\n", + " kingdom phylum class order family \\\n", + "1777659 Plantae Tracheophyta Magnoliopsida Asterales Asteraceae \n", + "4173487 Animalia Chordata Mammalia Artiodactyla Cervidae \n", + "4495906 Animalia Chordata Mammalia Artiodactyla Cervidae \n", + "1594880 Animalia Chordata NaN NaN Ceratopsidae \n", + "5128557 Animalia Chordata Actinopterygii Labriformes Labridae \n", + "2698612 Animalia Chordata Mammalia Artiodactyla Cervidae \n", + "1052488 NaN NaN NaN NaN NaN \n", + "3783126 Plantae Tracheophyta Magnoliopsida Ranunculales Ranunculaceae \n", + "2211057 Animalia Chordata Mammalia Artiodactyla Cervidae \n", + "604305 Animalia Chordata Mammalia Artiodactyla Cervidae \n", + "\n", + " genus species common \n", + "1777659 Erigeron acer narrowleaf fleabane \n", + "4173487 Cervus elaphus Yarkand deer \n", + "4495906 Cervus elaphus Yarkand deer \n", + "1594880 Triceratops serratus Triceratops serratus \n", + "5128557 Notolabrus tetricus Rotfish \n", + "2698612 Cervus elaphus Yarkand deer \n", + "1052488 NaN nipponica Nipponica \n", + "3783126 Ranunculus acutilobus Ranunculus acutilobus \n", + "2211057 Cervus elaphus Yarkand deer \n", + "604305 Cervus elaphus Yarkand deer " + ] + }, + "execution_count": 35, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "missing_pgs_df.sample(10)" + ] + }, + { + "cell_type": "code", + "execution_count": 39, + "metadata": {}, + "outputs": [], + "source": [ + "#missing_pgs_df.to_csv(\"../data/eol_files/catalog_missing_media_pages.csv\", index = False)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Save File with EOL Page IDs & Number of missing content IDs associated with each" + ] + }, + { + "cell_type": "code", + "execution_count": 43, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
treeoflife_ideol_content_ideol_page_idkingdomphylumclassorderfamilygenusspeciescommonnum_content_ids_missing
1264b56e165-c4d5-49f9-a321-ac9474d099f32753529.01225965.0AnimaliaChordataReptiliaSquamataColubridaeOpheodrysaestivusNorthern Rough Greensnake24
174421678a0-c8ec-43c8-815c-fc588883506816288.045514264.0AnimaliaChordataAvesPasseriformesLaniidaeLaniusexcubitorGreat Grey Shrike23
177be81bd8c-16a7-4911-8279-431245d671952730639.01034220.0AnimaliaArthropodaInsectaOdonataLestidaeLestesrectangularisSlender Spreadwing141
259fc765c82-84e6-437e-b9a5-1c7601c5be812717906.01052077.0AnimaliaChordataAvesPasseriformesCardinalidaePheucticusmelanocephalusBlack-headed Grosbeak818
3228c1e6878-47ac-4f7b-8475-73e71c0e99c32836995.0957074.0AnimaliaArthropodaInsectaLepidopteraPsychidaeThyridopteryxephemeraeformisEvergreen Bagworm30
\n", + "
" + ], + "text/plain": [ + " treeoflife_id eol_content_id eol_page_id \\\n", + "126 4b56e165-c4d5-49f9-a321-ac9474d099f3 2753529.0 1225965.0 \n", + "174 421678a0-c8ec-43c8-815c-fc5888835068 16288.0 45514264.0 \n", + "177 be81bd8c-16a7-4911-8279-431245d67195 2730639.0 1034220.0 \n", + "259 fc765c82-84e6-437e-b9a5-1c7601c5be81 2717906.0 1052077.0 \n", + "322 8c1e6878-47ac-4f7b-8475-73e71c0e99c3 2836995.0 957074.0 \n", + "\n", + " kingdom phylum class order family \\\n", + "126 Animalia Chordata Reptilia Squamata Colubridae \n", + "174 Animalia Chordata Aves Passeriformes Laniidae \n", + "177 Animalia Arthropoda Insecta Odonata Lestidae \n", + "259 Animalia Chordata Aves Passeriformes Cardinalidae \n", + "322 Animalia Arthropoda Insecta Lepidoptera Psychidae \n", + "\n", + " genus species common \\\n", + "126 Opheodrys aestivus Northern Rough Greensnake \n", + "174 Lanius excubitor Great Grey Shrike \n", + "177 Lestes rectangularis Slender Spreadwing \n", + "259 Pheucticus melanocephalus Black-headed Grosbeak \n", + "322 Thyridopteryx ephemeraeformis Evergreen Bagworm \n", + "\n", + " num_content_ids_missing \n", + "126 24 \n", + "174 23 \n", + "177 141 \n", + "259 818 \n", + "322 30 " + ] + }, + "execution_count": 43, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Count and record number of content IDs for each page ID\n", + "for pg_id in pg_ids_missing_content:\n", + " content_id_list = ['{}'.format(i) for i in eol_taxa_df_missing_media.loc[eol_taxa_df_missing_media['eol_page_id'] == pg_id]['eol_content_id'].unique()]\n", + " eol_taxa_df_missing_media.loc[eol_taxa_df_missing_media['eol_page_id'] == pg_id, \"num_content_ids_missing\"] = len(content_id_list)\n", + "\n", + "cols_of_interest.append(\"num_content_ids_missing\")\n", + "eol_taxa_df_missing_media[cols_of_interest].head()" + ] + }, + { + "cell_type": "code", + "execution_count": 44, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "Index: 9762 entries, 126 to 6276743\n", + "Data columns (total 18 columns):\n", + " # Column Non-Null Count Dtype \n", + "--- ------ -------------- ----- \n", + " 0 treeoflife_id 9762 non-null object \n", + " 1 eol_content_id 9762 non-null float64\n", + " 2 eol_page_id 9762 non-null float64\n", + " 3 kingdom 9737 non-null object \n", + " 4 phylum 9737 non-null object \n", + " 5 class 9729 non-null object \n", + " 6 order 9728 non-null object \n", + " 7 family 9737 non-null object \n", + " 8 genus 9738 non-null object \n", + " 9 species 9749 non-null object \n", + " 10 common 9762 non-null object \n", + " 11 EOL page ID 0 non-null float64\n", + " 12 Medium Source URL 0 non-null object \n", + " 13 EOL Full-Size Copy URL 0 non-null object \n", + " 14 License Name 0 non-null object \n", + " 15 Copyright Owner 0 non-null object \n", + " 16 num_content_ids_missing 9762 non-null object \n", + " 17 duplicate 9762 non-null bool \n", + "dtypes: bool(1), float64(3), object(14)\n", + "memory usage: 1.3+ MB\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/var/folders/nv/f0fq1p1n1_3b11x579py_0q80000gq/T/ipykernel_23442/4119024090.py:2: SettingWithCopyWarning: \n", + "A value is trying to be set on a copy of a slice from a DataFrame.\n", + "Try using .loc[row_indexer,col_indexer] = value instead\n", + "\n", + "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n", + " eol_taxa_df_missing_media['duplicate'] = eol_taxa_df_missing_media.duplicated(subset = \"eol_page_id\", keep = 'first')\n" + ] + } + ], + "source": [ + "#unique page_ids\n", + "eol_taxa_df_missing_media['duplicate'] = eol_taxa_df_missing_media.duplicated(subset = \"eol_page_id\", keep = 'first')\n", + "eol_taxa_df_num_missing_pg = eol_taxa_df_missing_media.loc[~eol_taxa_df_missing_media['duplicate']]\n", + "eol_taxa_df_num_missing_pg.info()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "This file has the relevant info relating to number of missing content IDs per page id, content ID included is just the first instance of such a content ID." + ] + }, + { + "cell_type": "code", + "execution_count": 46, + "metadata": {}, + "outputs": [], + "source": [ + "#eol_taxa_df_num_missing_pg[cols_of_interest].to_csv(\"../data/eol_files/eol_taxa_df_num_missing_pg.csv\", index = False)" + ] + }, + { + "cell_type": "code", + "execution_count": 64, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "Index: 625101 entries, 158 to 6574052\n", + "Data columns (total 6 columns):\n", + " # Column Non-Null Count Dtype \n", + "--- ------ -------------- ----- \n", + " 0 eol_content_id 625101 non-null int64 \n", + " 1 eol_page_id 625101 non-null int64 \n", + " 2 Medium Source URL 625101 non-null object\n", + " 3 EOL Full-Size Copy URL 625101 non-null object\n", + " 4 License Name 625101 non-null object\n", + " 5 Copyright Owner 548916 non-null object\n", + "dtypes: int64(2), object(4)\n", + "memory usage: 33.4+ MB\n" + ] + } + ], + "source": [ + "jul26_page_df = media.loc[media.eol_page_id.isin(pg_ids_missing_content)]\n", + "jul26_page_df.info()" + ] + }, + { + "cell_type": "code", + "execution_count": 65, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "eol_content_id 625101\n", + "eol_page_id 9610\n", + "Medium Source URL 624653\n", + "EOL Full-Size Copy URL 625101\n", + "License Name 16\n", + "Copyright Owner 87833\n", + "dtype: int64" + ] + }, + "execution_count": 65, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "jul26_page_df.nunique()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Yes, that's the expected number of unique page IDs. Let's save to CSV for download." + ] + }, + { + "cell_type": "code", + "execution_count": 66, + "metadata": {}, + "outputs": [], + "source": [ + "#jul26_page_df.to_csv(\"../data/eol_files/jul26_pages.csv\", index = False)" + ] + }, + { + "cell_type": "code", + "execution_count": 67, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "Index: 625106 entries, 158 to 6575355\n", + "Data columns (total 6 columns):\n", + " # Column Non-Null Count Dtype \n", + "--- ------ -------------- ----- \n", + " 0 eol_content_id 625106 non-null int64 \n", + " 1 eol_page_id 625106 non-null int64 \n", + " 2 Medium Source URL 625106 non-null object\n", + " 3 EOL Full-Size Copy URL 625106 non-null object\n", + " 4 License Name 625106 non-null object\n", + " 5 Copyright Owner 548921 non-null object\n", + "dtypes: int64(2), object(4)\n", + "memory usage: 33.4+ MB\n" + ] + } + ], + "source": [ + "dec6_page_df = media_new.loc[media_new.eol_page_id.isin(pg_ids_missing_content)]\n", + "dec6_page_df.info()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Okay, we have 5 more entries here, so let's compare unique counts and consider this one." + ] + }, + { + "cell_type": "code", + "execution_count": 68, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "eol_content_id 625106\n", + "eol_page_id 9610\n", + "Medium Source URL 624658\n", + "EOL Full-Size Copy URL 625106\n", + "License Name 16\n", + "Copyright Owner 87833\n", + "dtype: int64" + ] + }, + "execution_count": 68, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "dec6_page_df.nunique()" + ] + }, + { + "cell_type": "code", + "execution_count": 69, + "metadata": {}, + "outputs": [], + "source": [ + "#dec6_page_df.to_csv(\"../data/eol_files/dec6_pages.csv\", index = False)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### Check Older Media Manifest for Missing Pages\n", + "\n", + "Let's take a look at the July 6th media manifest to see if these pages are there." + ] + }, + { + "cell_type": "code", + "execution_count": 49, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "There are 443898 total page ids in the July 6 media manifest.\n", + "0\n" + ] + } + ], + "source": [ + "media_old.rename(columns = {\"EOL page ID\": \"eol_page_id\"}, inplace = True)\n", + "pg_ids_media_old = set(media_old.eol_page_id)\n", + "\n", + "print(f\"There are {len(pg_ids_media_old)} total page ids in the July 6 media manifest.\")\n", + "\n", + "missing_pgs_jul6 = []\n", + "for pg in missing_pgs:\n", + " if pg not in pg_ids_media_old:\n", + " missing_pgs_jul6.append(pg)\n", + "print(len(missing_pgs_jul6))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "It seems the missing pages are in the _older_ media manifest!\n", + "\n", + "Let's merge this with the `missing_pgs_df`, so we can get URLs to download from the pages there." + ] + }, + { + "cell_type": "code", + "execution_count": 51, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
treeoflife_ideol_content_ideol_page_idkingdomphylumclassorderfamilygenusspeciescommonnum_content_ids_missing
4850e5a7255b-14c0-45eb-b404-09562425e03d2779195.04446364.0AnimaliaChordataMammaliaArtiodactylaCervidaeCervuselaphusYarkand deer252.0
987597b26264-4d17-4c25-ba11-ee1d130387872740143.047364113.0AnimaliaChordataActinopterygiiLabriformesLabridaeNotolabrustetricusRotfish20.0
4672788b70cf5-29eb-47ec-b342-d948d17eb75b2779236.04446364.0AnimaliaChordataMammaliaArtiodactylaCervidaeCervuselaphusYarkand deer252.0
51799f18ffd83-1f37-4196-9508-9d5a6170d18f2779349.04446364.0AnimaliaChordataMammaliaArtiodactylaCervidaeCervuselaphusYarkand deer252.0
532439d3f201f-84fd-4552-89a6-3d87184bd3e12779324.04446364.0AnimaliaChordataMammaliaArtiodactylaCervidaeCervuselaphusYarkand deer252.0
\n", + "
" + ], + "text/plain": [ + " treeoflife_id eol_content_id eol_page_id \\\n", + "4850 e5a7255b-14c0-45eb-b404-09562425e03d 2779195.0 4446364.0 \n", + "9875 97b26264-4d17-4c25-ba11-ee1d13038787 2740143.0 47364113.0 \n", + "46727 88b70cf5-29eb-47ec-b342-d948d17eb75b 2779236.0 4446364.0 \n", + "51799 f18ffd83-1f37-4196-9508-9d5a6170d18f 2779349.0 4446364.0 \n", + "53243 9d3f201f-84fd-4552-89a6-3d87184bd3e1 2779324.0 4446364.0 \n", + "\n", + " kingdom phylum class order family genus \\\n", + "4850 Animalia Chordata Mammalia Artiodactyla Cervidae Cervus \n", + "9875 Animalia Chordata Actinopterygii Labriformes Labridae Notolabrus \n", + "46727 Animalia Chordata Mammalia Artiodactyla Cervidae Cervus \n", + "51799 Animalia Chordata Mammalia Artiodactyla Cervidae Cervus \n", + "53243 Animalia Chordata Mammalia Artiodactyla Cervidae Cervus \n", + "\n", + " species common num_content_ids_missing \n", + "4850 elaphus Yarkand deer 252.0 \n", + "9875 tetricus Rotfish 20.0 \n", + "46727 elaphus Yarkand deer 252.0 \n", + "51799 elaphus Yarkand deer 252.0 \n", + "53243 elaphus Yarkand deer 252.0 " + ] + }, + "execution_count": 51, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Count and record number of content IDs for each page ID\n", + "for pg_id in missing_pgs:\n", + " content_id_list_mp = ['{}'.format(i) for i in missing_pgs_df.loc[missing_pgs_df['eol_page_id'] == pg_id]['eol_content_id'].unique()]\n", + " missing_pgs_df.loc[missing_pgs_df['eol_page_id'] == pg_id, \"num_content_ids_missing\"] = len(content_id_list_mp)\n", + "\n", + "missing_pgs_df.head()" + ] + }, + { + "cell_type": "code", + "execution_count": 52, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "Index: 152 entries, 4850 to 6257217\n", + "Data columns (total 13 columns):\n", + " # Column Non-Null Count Dtype \n", + "--- ------ -------------- ----- \n", + " 0 treeoflife_id 152 non-null object \n", + " 1 eol_content_id 152 non-null float64\n", + " 2 eol_page_id 152 non-null float64\n", + " 3 kingdom 130 non-null object \n", + " 4 phylum 130 non-null object \n", + " 5 class 128 non-null object \n", + " 6 order 128 non-null object \n", + " 7 family 130 non-null object \n", + " 8 genus 131 non-null object \n", + " 9 species 152 non-null object \n", + " 10 common 152 non-null object \n", + " 11 num_content_ids_missing 152 non-null float64\n", + " 12 duplicate 152 non-null bool \n", + "dtypes: bool(1), float64(3), object(9)\n", + "memory usage: 15.6+ KB\n" + ] + } + ], + "source": [ + "#unique page_ids\n", + "missing_pgs_df['duplicate'] = missing_pgs_df.duplicated(subset = \"eol_page_id\", keep = 'first')\n", + "eol_taxa_num_missing_pgs_df = missing_pgs_df.loc[~missing_pgs_df['duplicate']]\n", + "eol_taxa_num_missing_pgs_df.info()" + ] + }, + { + "cell_type": "code", + "execution_count": 58, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "Index: 629 entries, 330 to 5701753\n", + "Data columns (total 6 columns):\n", + " # Column Non-Null Count Dtype \n", + "--- ------ -------------- ----- \n", + " 0 eol_content_id 629 non-null object\n", + " 1 eol_page_id 629 non-null object\n", + " 2 Medium Source URL 629 non-null object\n", + " 3 EOL Full-Size Copy URL 629 non-null object\n", + " 4 License Name 629 non-null object\n", + " 5 Copyright Owner 628 non-null object\n", + "dtypes: object(6)\n", + "memory usage: 34.4+ KB\n" + ] + } + ], + "source": [ + "older_page_df = media_old.loc[media_old.eol_page_id.isin(missing_pgs)]\n", + "older_page_df.info()" + ] + }, + { + "cell_type": "code", + "execution_count": 62, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
eol_content_ideol_page_idMedium Source URLEOL Full-Size Copy URLLicense NameCopyright Owner
9827927791844446364.0https://static.inaturalist.org/photos/1056942/...https://content.eol.org/data/media/28/50/cf/18...cc-by-nc-4.0Tony Iwane
9828027791854446364.0https://static.inaturalist.org/photos/1110278/...https://content.eol.org/data/media/28/98/57/18...cc-by-nc-4.0Kenneth Bader
9828127791864446364.0https://static.inaturalist.org/photos/1314173/...https://content.eol.org/data/media/29/96/fc/18...cc-by-nc-4.0parobbert
9828227791874446364.0https://static.inaturalist.org/photos/1314707/...https://content.eol.org/data/media/29/97/db/18...cc-by-nc-4.0jriddell
9828327791884446364.0https://static.inaturalist.org/photos/1320107/...https://content.eol.org/data/media/29/9f/67/18...cc-by-nc-4.0Daniel George
.....................
9852627794314446364.0https://static.inaturalist.org/photos/810701/o...https://content.eol.org/data/media/4c/10/a6/18...cc-by-nc-4.0john_peyton_anderson
9852727794324446364.0https://static.inaturalist.org/photos/810703/o...https://content.eol.org/data/media/4c/10/a8/18...cc-by-nc-4.0john_peyton_anderson
9852827794334446364.0https://static.inaturalist.org/photos/810704/o...https://content.eol.org/data/media/4c/10/a9/18...cc-by-nc-4.0john_peyton_anderson
9852927794344446364.0https://static.inaturalist.org/photos/814016/o...https://content.eol.org/data/media/4c/16/0d/18...cc-by-nc-4.0JK Johnson
9853027794354446364.0https://static.inaturalist.org/photos/828800/o...https://content.eol.org/data/media/4c/28/09/18...cc-by-nc-4.0Liam O'Brien
\n", + "

252 rows × 6 columns

\n", + "
" + ], + "text/plain": [ + " eol_content_id eol_page_id \\\n", + "98279 2779184 4446364.0 \n", + "98280 2779185 4446364.0 \n", + "98281 2779186 4446364.0 \n", + "98282 2779187 4446364.0 \n", + "98283 2779188 4446364.0 \n", + "... ... ... \n", + "98526 2779431 4446364.0 \n", + "98527 2779432 4446364.0 \n", + "98528 2779433 4446364.0 \n", + "98529 2779434 4446364.0 \n", + "98530 2779435 4446364.0 \n", + "\n", + " Medium Source URL \\\n", + "98279 https://static.inaturalist.org/photos/1056942/... \n", + "98280 https://static.inaturalist.org/photos/1110278/... \n", + "98281 https://static.inaturalist.org/photos/1314173/... \n", + "98282 https://static.inaturalist.org/photos/1314707/... \n", + "98283 https://static.inaturalist.org/photos/1320107/... \n", + "... ... \n", + "98526 https://static.inaturalist.org/photos/810701/o... \n", + "98527 https://static.inaturalist.org/photos/810703/o... \n", + "98528 https://static.inaturalist.org/photos/810704/o... \n", + "98529 https://static.inaturalist.org/photos/814016/o... \n", + "98530 https://static.inaturalist.org/photos/828800/o... \n", + "\n", + " EOL Full-Size Copy URL License Name \\\n", + "98279 https://content.eol.org/data/media/28/50/cf/18... cc-by-nc-4.0 \n", + "98280 https://content.eol.org/data/media/28/98/57/18... cc-by-nc-4.0 \n", + "98281 https://content.eol.org/data/media/29/96/fc/18... cc-by-nc-4.0 \n", + "98282 https://content.eol.org/data/media/29/97/db/18... cc-by-nc-4.0 \n", + "98283 https://content.eol.org/data/media/29/9f/67/18... cc-by-nc-4.0 \n", + "... ... ... \n", + "98526 https://content.eol.org/data/media/4c/10/a6/18... cc-by-nc-4.0 \n", + "98527 https://content.eol.org/data/media/4c/10/a8/18... cc-by-nc-4.0 \n", + "98528 https://content.eol.org/data/media/4c/10/a9/18... cc-by-nc-4.0 \n", + "98529 https://content.eol.org/data/media/4c/16/0d/18... cc-by-nc-4.0 \n", + "98530 https://content.eol.org/data/media/4c/28/09/18... cc-by-nc-4.0 \n", + "\n", + " Copyright Owner \n", + "98279 Tony Iwane \n", + "98280 Kenneth Bader \n", + "98281 parobbert \n", + "98282 jriddell \n", + "98283 Daniel George \n", + "... ... \n", + "98526 john_peyton_anderson \n", + "98527 john_peyton_anderson \n", + "98528 john_peyton_anderson \n", + "98529 JK Johnson \n", + "98530 Liam O'Brien \n", + "\n", + "[252 rows x 6 columns]" + ] + }, + "execution_count": 62, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "older_page_df.loc[older_page_df.eol_page_id.astype(str) == \"4446364.0\"]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Looks good, let's save to CSV." + ] + }, + { + "cell_type": "code", + "execution_count": 63, + "metadata": {}, + "outputs": [], + "source": [ + "#older_page_df.to_csv(\"../data/eol_files/media_old_pages.csv\", index = False)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Check EOL License file(s) \n", + "\n", + "First we'll look at `eol_licenses.csv` from Sam, which only covers `catalog.csv`, so load both these in to make sure we've got full coverage for all included images (Matt's first match attempt from file created above couldn't find ~113K based on `eol_content_id`)." + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [], + "source": [ + "cat_df = pd.read_csv(\"../data/catalog.csv\", dtype = {\"eol_content_id\": \"int64\", \"eol_page_id\": \"int64\"}, low_memory = False)\n", + "license_df = pd.read_csv(\"../data/eol_files/eol_licenses.csv\", \n", + " dtype = {\"eol_content_id\": \"int64\", \"eol_page_id\": \"int64\"}, \n", + " low_memory = False)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The `train_small` is duplicates of `train`, so we will drop those to analyze the full training set plus val." + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "metadata": {}, + "outputs": [], + "source": [ + "cat_df = cat_df.loc[cat_df.split != 'train_small']" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "metadata": {}, + "outputs": [], + "source": [ + "# Add data_source column for easier slicing\n", + "cat_df.loc[cat_df['inat21_filename'].notna(), 'data_source'] = 'iNat21'\n", + "cat_df.loc[cat_df['bioscan_filename'].notna(), 'data_source'] = 'BIOSCAN'\n", + "cat_df.loc[cat_df['eol_content_id'].notna(), 'data_source'] = 'EOL'" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "metadata": {}, + "outputs": [], + "source": [ + "eol_df = cat_df.loc[cat_df.data_source == \"EOL\"]" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
treeoflife10m_ideol_content_ideol_page_idlicenseowner
05a1daf92-60b2-4d23-9916-4c45ec7961675470022500901cc-by-nc-sa-3.0Susan A. Wineriter/Singing Insects of North Am...
1de10bc79-c46c-4b5b-bc75-64d569b9bf4a5470023858799cc-by-nc-sa-3.0Thomas J. Walker/Singing Insects of North America
2b68e1a7b-b294-4cfd-b423-1eed359f7c945470024598702cc-by-nc-sa-3.0Thomas J. Walker/Singing Insects of North America
3dcc46822-ffa6-46de-a639-bc5e296f50cf5470025598703cc-by-nc-sa-3.0Thomas J. Walker/Singing Insects of North America
4112d0571-c2dc-442b-9b2e-6665226b09425470026598703cc-by-nc-sa-3.0Thomas J. Walker/Singing Insects of North America
\n", + "
" + ], + "text/plain": [ + " treeoflife10m_id eol_content_id eol_page_id \n", + "0 5a1daf92-60b2-4d23-9916-4c45ec796167 5470022 500901 \\\n", + "1 de10bc79-c46c-4b5b-bc75-64d569b9bf4a 5470023 858799 \n", + "2 b68e1a7b-b294-4cfd-b423-1eed359f7c94 5470024 598702 \n", + "3 dcc46822-ffa6-46de-a639-bc5e296f50cf 5470025 598703 \n", + "4 112d0571-c2dc-442b-9b2e-6665226b0942 5470026 598703 \n", + "\n", + " license owner \n", + "0 cc-by-nc-sa-3.0 Susan A. Wineriter/Singing Insects of North Am... \n", + "1 cc-by-nc-sa-3.0 Thomas J. Walker/Singing Insects of North America \n", + "2 cc-by-nc-sa-3.0 Thomas J. Walker/Singing Insects of North America \n", + "3 cc-by-nc-sa-3.0 Thomas J. Walker/Singing Insects of North America \n", + "4 cc-by-nc-sa-3.0 Thomas J. Walker/Singing Insects of North America " + ] + }, + "execution_count": 20, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "license_df.head()" + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "(6020135, 5)" + ] + }, + "execution_count": 21, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "license_df.shape" + ] + }, + { + "cell_type": "code", + "execution_count": 22, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "(6250420, 18)" + ] + }, + "execution_count": 22, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "eol_df.shape" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Yeah, we're missing about 23K images in the license file." + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "RangeIndex: 6020135 entries, 0 to 6020134\n", + "Data columns (total 5 columns):\n", + " # Column Non-Null Count Dtype \n", + "--- ------ -------------- ----- \n", + " 0 treeoflife10m_id 6020135 non-null object\n", + " 1 eol_content_id 6020135 non-null int64 \n", + " 2 eol_page_id 6020135 non-null int64 \n", + " 3 license 6020135 non-null object\n", + " 4 owner 5402786 non-null object\n", + "dtypes: int64(2), object(3)\n", + "memory usage: 229.7+ MB\n" + ] + } + ], + "source": [ + "license_df.info(show_counts = True)" + ] + }, + { + "cell_type": "code", + "execution_count": 24, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "license\n", + "cc-0-1.0 282812\n", + "cc-publicdomain 172641\n", + "cc-by-nc-sa-3.0 130678\n", + "cc-by-nc 14160\n", + "cc-by-sa-3.0 11622\n", + "cc-by-3.0 5430\n", + "cc-by-nc-2.0 2\n", + "No known copyright restrictions 2\n", + "cc-by-nc-sa 1\n", + "cc-by 1\n", + "Name: count, dtype: int64" + ] + }, + "execution_count": 24, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "license_df.loc[license_df[\"owner\"].isna(), \"license\"].value_counts()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "CC BY licenses without `owner` indicated is rather problematic." + ] + }, + { + "cell_type": "code", + "execution_count": 25, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
treeoflife10m_ideol_content_ideol_page_idlicenseowner
4383662e2c812eb-9d42-4a18-abbc-3ccd8d55deca2833861165277845cc-0-1.0NaN
58237449bae6c3e-13e1-4253-8679-2609579a011d29932816581955cc-publicdomainNaN
56965849f668264-9bac-4931-95bc-d98b57788b5a29805194548324cc-publicdomainNaN
438962145977175-d60b-489e-8549-a3b512c51429283445741065138cc-0-1.0NaN
4412074ac2ba464-67a0-4f1f-a659-58525de63d3d28367105131254cc-0-1.0NaN
\n", + "
" + ], + "text/plain": [ + " treeoflife10m_id eol_content_id eol_page_id \n", + "4383662 e2c812eb-9d42-4a18-abbc-3ccd8d55deca 28338611 65277845 \\\n", + "5823744 9bae6c3e-13e1-4253-8679-2609579a011d 29932816 581955 \n", + "5696584 9f668264-9bac-4931-95bc-d98b57788b5a 29805194 548324 \n", + "4389621 45977175-d60b-489e-8549-a3b512c51429 28344574 1065138 \n", + "4412074 ac2ba464-67a0-4f1f-a659-58525de63d3d 28367105 131254 \n", + "\n", + " license owner \n", + "4383662 cc-0-1.0 NaN \n", + "5823744 cc-publicdomain NaN \n", + "5696584 cc-publicdomain NaN \n", + "4389621 cc-0-1.0 NaN \n", + "4412074 cc-0-1.0 NaN " + ] + }, + "execution_count": 25, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "license_df.loc[license_df[\"owner\"].isna()].sample(5)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Tracked down `eol_content_id` [14796160](https://eol.org/media/14796160), original source is [BioImages](https://www.bioimages.org.uk/image.php?id=79950) with copyright Malcolm Storey (like 99% of the images on the site (see their [conditions of use](https://www.bioimages.org.uk/cright.htm))). He is listed as \"compiler\" on the EOL media page." + ] + }, + { + "cell_type": "code", + "execution_count": 26, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "license\n", + "cc-by-nc-4.0 2431101\n", + "cc-by-sa-3.0 776696\n", + "cc-by-nc-sa-3.0 559160\n", + "cc-by-3.0 428137\n", + "cc-by-4.0 379862\n", + "cc-by-nc 327467\n", + "cc-publicdomain 299235\n", + "cc-0-1.0 299119\n", + "cc-by-nc-sa-4.0 191967\n", + "cc-by-nc-sa 153033\n", + "cc-by-sa-4.0 66743\n", + "cc-by 47300\n", + "cc-by-sa-2.0 31019\n", + "cc-by-nc-2.0 28175\n", + "No known copyright restrictions 801\n", + "cc-by-nc-sa-2.5 315\n", + "public domain 5\n", + "Name: count, dtype: int64" + ] + }, + "execution_count": 26, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "license_df.license.value_counts()" + ] + }, + { + "cell_type": "code", + "execution_count": 27, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
treeoflife10m_ideol_content_ideol_page_idlicenseowner
507806733a9ec77-3000-49f7-b1da-7b4945a8880f2918430223770363No known copyright restrictionsOSU Special Collections & Archives : Commons
571553220f00222-7a9f-4676-8a4d-0bbfe4b89bf52982420165420112No known copyright restrictionsAbel, Othenio, 1875-1946
526221656091877-5f02-4ce0-8720-58da312250a529369066969529No known copyright restrictionsBiologicheskii institut (Akademiia nauk SSSR);...
5580837be6b6fbb-a7b0-4a4b-9c1a-495a8994de0c2968908046562368No known copyright restrictionsState Archives of North Carolina
5049267cdff7740-7d84-427b-bd77-c5ec72899a12291554401142979No known copyright restrictionsAustralian War Memorial collection
\n", + "
" + ], + "text/plain": [ + " treeoflife10m_id eol_content_id eol_page_id \n", + "5078067 33a9ec77-3000-49f7-b1da-7b4945a8880f 29184302 23770363 \\\n", + "5715532 20f00222-7a9f-4676-8a4d-0bbfe4b89bf5 29824201 65420112 \n", + "5262216 56091877-5f02-4ce0-8720-58da312250a5 29369066 969529 \n", + "5580837 be6b6fbb-a7b0-4a4b-9c1a-495a8994de0c 29689080 46562368 \n", + "5049267 cdff7740-7d84-427b-bd77-c5ec72899a12 29155440 1142979 \n", + "\n", + " license \n", + "5078067 No known copyright restrictions \\\n", + "5715532 No known copyright restrictions \n", + "5262216 No known copyright restrictions \n", + "5580837 No known copyright restrictions \n", + "5049267 No known copyright restrictions \n", + "\n", + " owner \n", + "5078067 OSU Special Collections & Archives : Commons \n", + "5715532 Abel, Othenio, 1875-1946 \n", + "5262216 Biologicheskii institut (Akademiia nauk SSSR);... \n", + "5580837 State Archives of North Carolina \n", + "5049267 Australian War Memorial collection " + ] + }, + "execution_count": 27, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "license_df.loc[license_df[\"license\"] == \"No known copyright restrictions\"].sample(5)" + ] + }, + { + "cell_type": "code", + "execution_count": 28, + "metadata": {}, + "outputs": [], + "source": [ + "#license_df.loc[license_df[\"owner\"].isna()].to_csv(\"../data/eol_files/eol_licenses_missing_owner.csv\", index = False)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "jupytext": { + "formats": "ipynb,py:percent" + }, + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.11.3" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +}