"
+ ],
+ "text/plain": [
+ " data_source kingdom phylum class order family \n",
+ "7525562 BIOSCAN Animalia Arthropoda Insecta Diptera Drosophilidae \\\n",
+ "5454948 BIOSCAN Animalia Arthropoda Insecta Diptera Empididae \n",
+ "2006286 BIOSCAN Animalia Arthropoda Insecta Diptera Sciaridae \n",
+ "1299754 BIOSCAN Animalia Arthropoda Insecta Diptera Sciaridae \n",
+ "7595135 BIOSCAN Animalia Arthropoda Insecta Diptera Sciaridae \n",
+ "3850263 BIOSCAN Animalia Arthropoda Insecta Diptera Sciaridae \n",
+ "10366847 BIOSCAN Animalia Arthropoda Insecta Diptera Sciaridae \n",
+ "6253262 BIOSCAN Animalia Arthropoda Insecta Diptera Drosophilidae \n",
+ "4624702 BIOSCAN Animalia Arthropoda Insecta Diptera Empididae \n",
+ "6143519 BIOSCAN Animalia Arthropoda Insecta Diptera Sciaridae \n",
+ "\n",
+ " genus species \n",
+ "7525562 Mycodrosophila projectans affinis 2 \\\n",
+ "5454948 Porphyrochroa sp. 6 bkc- \n",
+ "2006286 Cosmosciara sp. saevg morph \n",
+ "1299754 Cosmosciara sp. saevg morph \n",
+ "7595135 Cosmosciara sp. saevg morph \n",
+ "3850263 Cosmosciara sp. saevg morph \n",
+ "10366847 Cosmosciara sp. saevg morph \n",
+ "6253262 Hirtodrosophila subflavohalterata affinis 4 \n",
+ "4624702 Porphyrochroa sp. 6 bkc- \n",
+ "6143519 Cosmosciara sp. saevg morph \n",
+ "\n",
+ " common duplicate len_species \n",
+ "7525562 Mycodrosophila projectans affinis 2 True 3 \n",
+ "5454948 Porphyrochroa sp. 6 bkc- True 3 \n",
+ "2006286 Cosmosciara sp. saevg morph True 3 \n",
+ "1299754 Cosmosciara sp. saevg morph False 3 \n",
+ "7595135 Cosmosciara sp. saevg morph True 3 \n",
+ "3850263 Cosmosciara sp. saevg morph True 3 \n",
+ "10366847 Cosmosciara sp. saevg morph True 3 \n",
+ "6253262 Hirtodrosophila subflavohalterata affinis 4 True 3 \n",
+ "4624702 Porphyrochroa sp. 6 bkc- True 3 \n",
+ "6143519 Cosmosciara sp. saevg morph True 3 "
+ ]
+ },
+ "execution_count": 45,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "bioscan_long_species.loc[bioscan_long_species['len_species'] > 2].sample(10)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "This looks like about what we expected."
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "It would seem the \"sp. ...\" is used to indicate they are likely the same species, though the actual species is not designated (either unnamed or undetermined). This is information we should retain, but the duplicated genus can be removed."
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "### EOL"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 46,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "\n",
+ "Index: 6250689 entries, 957254 to 10998645\n",
+ "Data columns (total 9 columns):\n",
+ " # Column Non-Null Count Dtype \n",
+ "--- ------ -------------- ----- \n",
+ " 0 data_source 6250689 non-null object\n",
+ " 1 kingdom 5868540 non-null object\n",
+ " 2 phylum 5878322 non-null object\n",
+ " 3 class 5854358 non-null object\n",
+ " 4 order 5851858 non-null object\n",
+ " 5 family 5835842 non-null object\n",
+ " 6 genus 5940575 non-null object\n",
+ " 7 species 5951882 non-null object\n",
+ " 8 common 6250689 non-null object\n",
+ "dtypes: object(9)\n",
+ "memory usage: 476.9+ MB\n"
+ ]
+ }
+ ],
+ "source": [
+ "eol_df.info(show_counts = True)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 47,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "data_source 1\n",
+ "kingdom 7\n",
+ "phylum 90\n",
+ "class 280\n",
+ "order 1321\n",
+ "family 7735\n",
+ "genus 73065\n",
+ "species 163378\n",
+ "common 440892\n",
+ "dtype: int64"
+ ]
+ },
+ "execution_count": 47,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "eol_df.nunique()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 48,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "data_source 1\n",
+ "kingdom 7\n",
+ "phylum 88\n",
+ "class 259\n",
+ "order 1149\n",
+ "family 5926\n",
+ "genus 34501\n",
+ "species 0\n",
+ "common 39233\n",
+ "dtype: int64"
+ ]
+ },
+ "execution_count": 48,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "eol_df.loc[eol_df.species.isna()].nunique()"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "There are 503,595 unique page IDs from EOL in this dataset, which clearly represent varying levels of taxa. \n",
+ "\n",
+ "Unique species + unique common where species is null (39,233) does not reach this number. But we have added SO many more phyla through family!"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 49,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "kingdom\n",
+ "Animalia 3410638\n",
+ "Plantae 2172010\n",
+ "Fungi 265636\n",
+ "Protozoa 10924\n",
+ "Chromista 6443\n",
+ "Bacteria 2864\n",
+ "Archaea 25\n",
+ "Name: count, dtype: int64"
+ ]
+ },
+ "execution_count": 49,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "eol_df['kingdom'].value_counts()"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "We have much greater kingdom variety here.\n",
+ "\n",
+ "We have already observed that not all ranks are filled in at the higher levels, sometimes having just one gap. This has been greatly improved from the first iteration and we'll get one more pass."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 50,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "/var/folders/nv/f0fq1p1n1_3b11x579py_0q80000gq/T/ipykernel_90984/52183210.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_df['duplicate'] = eol_df.duplicated(subset = taxa, keep = 'first')\n"
+ ]
+ }
+ ],
+ "source": [
+ "#number of unique 7-tuples in EOL\n",
+ "eol_df['duplicate'] = eol_df.duplicated(subset = taxa, keep = 'first')\n",
+ "eol_df_unique_taxa = eol_df.loc[~eol_df['duplicate']]"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 51,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "\n",
+ "Index: 449882 entries, 957254 to 10998610\n",
+ "Data columns (total 10 columns):\n",
+ " # Column Non-Null Count Dtype \n",
+ "--- ------ -------------- ----- \n",
+ " 0 data_source 449882 non-null object\n",
+ " 1 kingdom 399987 non-null object\n",
+ " 2 phylum 403692 non-null object\n",
+ " 3 class 402236 non-null object\n",
+ " 4 order 403031 non-null object\n",
+ " 5 family 403098 non-null object\n",
+ " 6 genus 423277 non-null object\n",
+ " 7 species 410316 non-null object\n",
+ " 8 common 449882 non-null object\n",
+ " 9 duplicate 449882 non-null bool \n",
+ "dtypes: bool(1), object(9)\n",
+ "memory usage: 34.8+ MB\n"
+ ]
+ }
+ ],
+ "source": [
+ "eol_df_unique_taxa.info(show_counts = True)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "This is quite a good number of unqiue taxa.\n",
+ "\n",
+ "Is `genus` labeled for all entries with `species` labeled? "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 52,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "\n",
+ "Index: 5951882 entries, 957254 to 10998645\n",
+ "Data columns (total 10 columns):\n",
+ " # Column Non-Null Count Dtype \n",
+ "--- ------ -------------- ----- \n",
+ " 0 data_source 5951882 non-null object\n",
+ " 1 kingdom 5572904 non-null object\n",
+ " 2 phylum 5581161 non-null object\n",
+ " 3 class 5571860 non-null object\n",
+ " 4 order 5576429 non-null object\n",
+ " 5 family 5578918 non-null object\n",
+ " 6 genus 5731404 non-null object\n",
+ " 7 species 5951882 non-null object\n",
+ " 8 common 5951882 non-null object\n",
+ " 9 duplicate 5951882 non-null bool \n",
+ "dtypes: bool(1), object(9)\n",
+ "memory usage: 459.8+ MB\n"
+ ]
+ }
+ ],
+ "source": [
+ "eol_df.loc[eol_df.species.notna()].info(show_counts = True)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Not all labeled species have higher order taxa, but they do all have `common` (likely because if there is no common name, it pulls scientific name (genus-species)).\n",
+ "\n",
+ "This will hopefully be filled with the next iteration."
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Let's get a quick sample of the `common` column for images both with and without `species` labels. "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 53,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "
\n",
+ "\n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
\n",
+ "
data_source
\n",
+ "
kingdom
\n",
+ "
phylum
\n",
+ "
class
\n",
+ "
order
\n",
+ "
family
\n",
+ "
genus
\n",
+ "
species
\n",
+ "
common
\n",
+ "
duplicate
\n",
+ "
\n",
+ " \n",
+ " \n",
+ "
\n",
+ "
9270558
\n",
+ "
EOL
\n",
+ "
Plantae
\n",
+ "
Tracheophyta
\n",
+ "
Magnoliopsida
\n",
+ "
Asterales
\n",
+ "
Asteraceae
\n",
+ "
Artemisia
\n",
+ "
campestris
\n",
+ "
field sagewort
\n",
+ "
True
\n",
+ "
\n",
+ "
\n",
+ "
4817849
\n",
+ "
EOL
\n",
+ "
Plantae
\n",
+ "
Tracheophyta
\n",
+ "
Magnoliopsida
\n",
+ "
Myrtales
\n",
+ "
Onagraceae
\n",
+ "
Fuchsia
\n",
+ "
lycioides
\n",
+ "
Box-thorn Fuchsia
\n",
+ "
True
\n",
+ "
\n",
+ "
\n",
+ "
2551818
\n",
+ "
EOL
\n",
+ "
Plantae
\n",
+ "
Tracheophyta
\n",
+ "
Magnoliopsida
\n",
+ "
Fabales
\n",
+ "
Fabaceae
\n",
+ "
Aspalathus
\n",
+ "
florifera
\n",
+ "
Aspalathus florifera
\n",
+ "
True
\n",
+ "
\n",
+ "
\n",
+ "
5472692
\n",
+ "
EOL
\n",
+ "
Plantae
\n",
+ "
Tracheophyta
\n",
+ "
Magnoliopsida
\n",
+ "
Gentianales
\n",
+ "
Apocynaceae
\n",
+ "
Marsdenia
\n",
+ "
pringlei
\n",
+ "
Marsdenia pringlei
\n",
+ "
True
\n",
+ "
\n",
+ "
\n",
+ "
10934680
\n",
+ "
EOL
\n",
+ "
Animalia
\n",
+ "
Arthropoda
\n",
+ "
Insecta
\n",
+ "
Hymenoptera
\n",
+ "
Formicidae
\n",
+ "
Azteca
\n",
+ "
tonduzi
\n",
+ "
Azteca tonduzi
\n",
+ "
True
\n",
+ "
\n",
+ "
\n",
+ "
10651724
\n",
+ "
EOL
\n",
+ "
Plantae
\n",
+ "
Tracheophyta
\n",
+ "
Magnoliopsida
\n",
+ "
Ranunculales
\n",
+ "
Papaveraceae
\n",
+ "
Ehrendorferia
\n",
+ "
chrysantha
\n",
+ "
golden eardrops
\n",
+ "
True
\n",
+ "
\n",
+ "
\n",
+ "
1338761
\n",
+ "
EOL
\n",
+ "
Animalia
\n",
+ "
Arthropoda
\n",
+ "
Insecta
\n",
+ "
Hemiptera
\n",
+ "
Aphalaridae
\n",
+ "
Aphalara
\n",
+ "
rumicis
\n",
+ "
whitefly
\n",
+ "
False
\n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " data_source kingdom phylum class order \n",
+ "9270558 EOL Plantae Tracheophyta Magnoliopsida Asterales \\\n",
+ "4817849 EOL Plantae Tracheophyta Magnoliopsida Myrtales \n",
+ "2551818 EOL Plantae Tracheophyta Magnoliopsida Fabales \n",
+ "5472692 EOL Plantae Tracheophyta Magnoliopsida Gentianales \n",
+ "10934680 EOL Animalia Arthropoda Insecta Hymenoptera \n",
+ "10651724 EOL Plantae Tracheophyta Magnoliopsida Ranunculales \n",
+ "1338761 EOL Animalia Arthropoda Insecta Hemiptera \n",
+ "\n",
+ " family genus species common \n",
+ "9270558 Asteraceae Artemisia campestris field sagewort \\\n",
+ "4817849 Onagraceae Fuchsia lycioides Box-thorn Fuchsia \n",
+ "2551818 Fabaceae Aspalathus florifera Aspalathus florifera \n",
+ "5472692 Apocynaceae Marsdenia pringlei Marsdenia pringlei \n",
+ "10934680 Formicidae Azteca tonduzi Azteca tonduzi \n",
+ "10651724 Papaveraceae Ehrendorferia chrysantha golden eardrops \n",
+ "1338761 Aphalaridae Aphalara rumicis whitefly \n",
+ "\n",
+ " duplicate \n",
+ "9270558 True \n",
+ "4817849 True \n",
+ "2551818 True \n",
+ "5472692 True \n",
+ "10934680 True \n",
+ "10651724 True \n",
+ "1338761 False "
+ ]
+ },
+ "execution_count": 53,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "# existing species label\n",
+ "eol_df.loc[eol_df.species.notna()].sample(7)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Good, some of these do have common names. We could check numbers of `common` where it doesn't match the `genus-species` form for a better count, but our random sample is promising."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 54,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "
\n",
+ "\n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
\n",
+ "
data_source
\n",
+ "
kingdom
\n",
+ "
phylum
\n",
+ "
class
\n",
+ "
order
\n",
+ "
family
\n",
+ "
genus
\n",
+ "
species
\n",
+ "
common
\n",
+ "
duplicate
\n",
+ "
\n",
+ " \n",
+ " \n",
+ "
\n",
+ "
5188973
\n",
+ "
EOL
\n",
+ "
Animalia
\n",
+ "
Mollusca
\n",
+ "
Gastropoda
\n",
+ "
Neogastropoda
\n",
+ "
Mitridae
\n",
+ "
Mitra
\n",
+ "
NaN
\n",
+ "
mitras mitres
\n",
+ "
True
\n",
+ "
\n",
+ "
\n",
+ "
5995303
\n",
+ "
EOL
\n",
+ "
Plantae
\n",
+ "
Tracheophyta
\n",
+ "
Magnoliopsida
\n",
+ "
Vitales
\n",
+ "
Vitaceae
\n",
+ "
Vitis
\n",
+ "
NaN
\n",
+ "
champin's grape
\n",
+ "
True
\n",
+ "
\n",
+ "
\n",
+ "
3906456
\n",
+ "
EOL
\n",
+ "
Fungi
\n",
+ "
Basidiomycota
\n",
+ "
Agaricomycetes
\n",
+ "
Agaricales
\n",
+ "
Agaricaceae
\n",
+ "
Agaricus
\n",
+ "
NaN
\n",
+ "
Agaricus
\n",
+ "
True
\n",
+ "
\n",
+ "
\n",
+ "
7978418
\n",
+ "
EOL
\n",
+ "
Animalia
\n",
+ "
Chordata
\n",
+ "
Aves
\n",
+ "
Galliformes
\n",
+ "
NaN
\n",
+ "
NaN
\n",
+ "
NaN
\n",
+ "
Animalia Chordata Aves Galliformes
\n",
+ "
True
\n",
+ "
\n",
+ "
\n",
+ "
5606824
\n",
+ "
EOL
\n",
+ "
Animalia
\n",
+ "
Mollusca
\n",
+ "
Gastropoda
\n",
+ "
Littorinimorpha
\n",
+ "
Cassidae
\n",
+ "
Phalium
\n",
+ "
NaN
\n",
+ "
Phalium
\n",
+ "
True
\n",
+ "
\n",
+ "
\n",
+ "
3243158
\n",
+ "
EOL
\n",
+ "
Plantae
\n",
+ "
Tracheophyta
\n",
+ "
Magnoliopsida
\n",
+ "
Gentianales
\n",
+ "
Apocynaceae
\n",
+ "
Aspidoglossum
\n",
+ "
NaN
\n",
+ "
Aspidoglossum
\n",
+ "
True
\n",
+ "
\n",
+ "
\n",
+ "
5087076
\n",
+ "
EOL
\n",
+ "
Animalia
\n",
+ "
Chordata
\n",
+ "
Aves
\n",
+ "
Passeriformes
\n",
+ "
Turdidae
\n",
+ "
Cochoa
\n",
+ "
NaN
\n",
+ "
Cochoa
\n",
+ "
False
\n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " data_source kingdom phylum class order \n",
+ "5188973 EOL Animalia Mollusca Gastropoda Neogastropoda \\\n",
+ "5995303 EOL Plantae Tracheophyta Magnoliopsida Vitales \n",
+ "3906456 EOL Fungi Basidiomycota Agaricomycetes Agaricales \n",
+ "7978418 EOL Animalia Chordata Aves Galliformes \n",
+ "5606824 EOL Animalia Mollusca Gastropoda Littorinimorpha \n",
+ "3243158 EOL Plantae Tracheophyta Magnoliopsida Gentianales \n",
+ "5087076 EOL Animalia Chordata Aves Passeriformes \n",
+ "\n",
+ " family genus species \n",
+ "5188973 Mitridae Mitra NaN \\\n",
+ "5995303 Vitaceae Vitis NaN \n",
+ "3906456 Agaricaceae Agaricus NaN \n",
+ "7978418 NaN NaN NaN \n",
+ "5606824 Cassidae Phalium NaN \n",
+ "3243158 Apocynaceae Aspidoglossum NaN \n",
+ "5087076 Turdidae Cochoa NaN \n",
+ "\n",
+ " common duplicate \n",
+ "5188973 mitras mitres True \n",
+ "5995303 champin's grape True \n",
+ "3906456 Agaricus True \n",
+ "7978418 Animalia Chordata Aves Galliformes True \n",
+ "5606824 Phalium True \n",
+ "3243158 Aspidoglossum True \n",
+ "5087076 Cochoa False "
+ ]
+ },
+ "execution_count": 54,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "# No species label\n",
+ "eol_df.loc[eol_df.species.isna()].sample(7)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Let's check the `species` length in EOL as well, we know there are some that have genus-species. And others with hybrids that get VERY long."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 55,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "/var/folders/nv/f0fq1p1n1_3b11x579py_0q80000gq/T/ipykernel_90984/2529943378.py:16: 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",
+ " df[\"len_species\"] = 1\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "\n",
+ "Index: 6250689 entries, 957254 to 10998645\n",
+ "Data columns (total 11 columns):\n",
+ " # Column Non-Null Count Dtype \n",
+ "--- ------ -------------- ----- \n",
+ " 0 data_source 6250689 non-null object\n",
+ " 1 kingdom 5868540 non-null object\n",
+ " 2 phylum 5878322 non-null object\n",
+ " 3 class 5854358 non-null object\n",
+ " 4 order 5851858 non-null object\n",
+ " 5 family 5835842 non-null object\n",
+ " 6 genus 5940575 non-null object\n",
+ " 7 species 5951882 non-null object\n",
+ " 8 common 6250689 non-null object\n",
+ " 9 duplicate 6250689 non-null bool \n",
+ " 10 len_species 6250689 non-null int64 \n",
+ "dtypes: bool(1), int64(1), object(9)\n",
+ "memory usage: 530.5+ MB\n"
+ ]
+ }
+ ],
+ "source": [
+ "eol_species_len = check_sci_name(eol_df)\n",
+ "eol_species_len.info(show_counts = True)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 56,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "\n",
+ "Index: 145301 entries, 957254 to 10998622\n",
+ "Data columns (total 11 columns):\n",
+ " # Column Non-Null Count Dtype \n",
+ "--- ------ -------------- ----- \n",
+ " 0 data_source 145301 non-null object\n",
+ " 1 kingdom 22 non-null object\n",
+ " 2 phylum 22 non-null object\n",
+ " 3 class 22 non-null object\n",
+ " 4 order 582 non-null object\n",
+ " 5 family 631 non-null object\n",
+ " 6 genus 145301 non-null object\n",
+ " 7 species 145301 non-null object\n",
+ " 8 common 145301 non-null object\n",
+ " 9 duplicate 145301 non-null bool \n",
+ " 10 len_species 145301 non-null int64 \n",
+ "dtypes: bool(1), int64(1), object(9)\n",
+ "memory usage: 12.3+ MB\n"
+ ]
+ }
+ ],
+ "source": [
+ "eol_long_species = eol_species_len.loc[eol_species_len[\"len_species\"] > 1]\n",
+ "eol_long_species.info(show_counts = True)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "That's quite a lot with species name longer than 1 word."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 57,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "len_species\n",
+ "2 121046\n",
+ "3 19652\n",
+ "4 3948\n",
+ "5 316\n",
+ "6 264\n",
+ "8 26\n",
+ "7 14\n",
+ "16 13\n",
+ "10 6\n",
+ "18 4\n",
+ "9 4\n",
+ "21 3\n",
+ "17 2\n",
+ "15 1\n",
+ "26 1\n",
+ "11 1\n",
+ "Name: count, dtype: int64"
+ ]
+ },
+ "execution_count": 57,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "eol_long_species.len_species.value_counts()"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "We have length 2 all the way to 26. \n",
+ "\n",
+ "Why are some more than 10 words long?\n",
+ "- Seem to be hybrids, getting genus added now\n",
+ "- We have one that says \"Bee\"... it was \"bee bees ntomology apoidea extrememarco insects...\""
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 58,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "
\n",
+ "\n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
\n",
+ "
data_source
\n",
+ "
kingdom
\n",
+ "
phylum
\n",
+ "
class
\n",
+ "
order
\n",
+ "
family
\n",
+ "
genus
\n",
+ "
species
\n",
+ "
common
\n",
+ "
duplicate
\n",
+ "
len_species
\n",
+ "
\n",
+ " \n",
+ " \n",
+ "
\n",
+ "
2602723
\n",
+ "
EOL
\n",
+ "
NaN
\n",
+ "
NaN
\n",
+ "
NaN
\n",
+ "
NaN
\n",
+ "
NaN
\n",
+ "
Photinia
\n",
+ "
japonica benth. & hook.f. ex asch. & schweinf.
\n",
+ "
Photinia japonica benth. & hook.f. ex asch. & ...
\n",
+ "
False
\n",
+ "
8
\n",
+ "
\n",
+ "
\n",
+ "
1735249
\n",
+ "
EOL
\n",
+ "
NaN
\n",
+ "
NaN
\n",
+ "
NaN
\n",
+ "
NaN
\n",
+ "
NaN
\n",
+ "
Bee
\n",
+ "
bees entomology apoidea extrememacro insects i...
\n",
+ "
Bee bees entomology apoidea extrememacro insec...
\n",
+ "
False
\n",
+ "
15
\n",
+ "
\n",
+ "
\n",
+ "
4389838
\n",
+ "
EOL
\n",
+ "
NaN
\n",
+ "
NaN
\n",
+ "
NaN
\n",
+ "
NaN
\n",
+ "
NaN
\n",
+ "
Alepidoscelis
\n",
+ "
pollen biml usgs usgsbiml droege female макрос...
\n",
+ "
Alepidoscelis pollen biml usgs usgsbiml droege...
\n",
+ "
False
\n",
+ "
21
\n",
+ "
\n",
+ "
\n",
+ "
9658690
\n",
+ "
EOL
\n",
+ "
NaN
\n",
+ "
NaN
\n",
+ "
NaN
\n",
+ "
NaN
\n",
+ "
NaN
\n",
+ "
Malacostraca
\n",
+ "
taxonomy:order=decapoda decapoda taxonomy:fami...
\n",
+ "
Malacostraca taxonomy:order=decapoda decapoda ...
\n",
+ "
False
\n",
+ "
8
\n",
+ "
\n",
+ "
\n",
+ "
3427215
\n",
+ "
EOL
\n",
+ "
NaN
\n",
+ "
NaN
\n",
+ "
NaN
\n",
+ "
NaN
\n",
+ "
NaN
\n",
+ "
Cupressus
\n",
+ "
macrocarpa x xanthocyparis nootkatensis = x cu...
\n",
+ "
Cupressus macrocarpa x xanthocyparis nootkaten...
\n",
+ "
True
\n",
+ "
8
\n",
+ "
\n",
+ "
\n",
+ "
5137227
\n",
+ "
EOL
\n",
+ "
NaN
\n",
+ "
NaN
\n",
+ "
NaN
\n",
+ "
NaN
\n",
+ "
NaN
\n",
+ "
Cupressus
\n",
+ "
macrocarpa x xanthocyparis nootkatensis = x cu...
\n",
+ "
Cupressus macrocarpa x xanthocyparis nootkaten...
\n",
+ "
True
\n",
+ "
8
\n",
+ "
\n",
+ "
\n",
+ "
10327866
\n",
+ "
EOL
\n",
+ "
NaN
\n",
+ "
NaN
\n",
+ "
NaN
\n",
+ "
NaN
\n",
+ "
NaN
\n",
+ "
Cupressus
\n",
+ "
macrocarpa x xanthocyparis nootkatensis = x cu...
\n",
+ "
Cupressus macrocarpa x xanthocyparis nootkaten...
\n",
+ "
True
\n",
+ "
8
\n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " data_source kingdom phylum class order family genus \n",
+ "2602723 EOL NaN NaN NaN NaN NaN Photinia \\\n",
+ "1735249 EOL NaN NaN NaN NaN NaN Bee \n",
+ "4389838 EOL NaN NaN NaN NaN NaN Alepidoscelis \n",
+ "9658690 EOL NaN NaN NaN NaN NaN Malacostraca \n",
+ "3427215 EOL NaN NaN NaN NaN NaN Cupressus \n",
+ "5137227 EOL NaN NaN NaN NaN NaN Cupressus \n",
+ "10327866 EOL NaN NaN NaN NaN NaN Cupressus \n",
+ "\n",
+ " species \n",
+ "2602723 japonica benth. & hook.f. ex asch. & schweinf. \\\n",
+ "1735249 bees entomology apoidea extrememacro insects i... \n",
+ "4389838 pollen biml usgs usgsbiml droege female макрос... \n",
+ "9658690 taxonomy:order=decapoda decapoda taxonomy:fami... \n",
+ "3427215 macrocarpa x xanthocyparis nootkatensis = x cu... \n",
+ "5137227 macrocarpa x xanthocyparis nootkatensis = x cu... \n",
+ "10327866 macrocarpa x xanthocyparis nootkatensis = x cu... \n",
+ "\n",
+ " common duplicate \n",
+ "2602723 Photinia japonica benth. & hook.f. ex asch. & ... False \\\n",
+ "1735249 Bee bees entomology apoidea extrememacro insec... False \n",
+ "4389838 Alepidoscelis pollen biml usgs usgsbiml droege... False \n",
+ "9658690 Malacostraca taxonomy:order=decapoda decapoda ... False \n",
+ "3427215 Cupressus macrocarpa x xanthocyparis nootkaten... True \n",
+ "5137227 Cupressus macrocarpa x xanthocyparis nootkaten... True \n",
+ "10327866 Cupressus macrocarpa x xanthocyparis nootkaten... True \n",
+ "\n",
+ " len_species \n",
+ "2602723 8 \n",
+ "1735249 15 \n",
+ "4389838 21 \n",
+ "9658690 8 \n",
+ "3427215 8 \n",
+ "5137227 8 \n",
+ "10327866 8 "
+ ]
+ },
+ "execution_count": 58,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "eol_long_species.loc[eol_long_species[\"len_species\"] > 7].sample(7)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 59,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "data_source 1\n",
+ "kingdom 1\n",
+ "phylum 1\n",
+ "class 1\n",
+ "order 20\n",
+ "family 34\n",
+ "genus 8587\n",
+ "species 22759\n",
+ "common 23241\n",
+ "duplicate 2\n",
+ "len_species 16\n",
+ "dtype: int64"
+ ]
+ },
+ "execution_count": 59,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "eol_long_species.nunique()"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Genus was filled out much more from the last iteration (from only 47 to 8,587 unique instances), also doesn't have any nulls now (pulling that first word from species column)."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 60,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "
\n",
+ "\n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
\n",
+ "
data_source
\n",
+ "
kingdom
\n",
+ "
phylum
\n",
+ "
class
\n",
+ "
order
\n",
+ "
family
\n",
+ "
genus
\n",
+ "
species
\n",
+ "
common
\n",
+ "
duplicate
\n",
+ "
len_species
\n",
+ "
\n",
+ " \n",
+ " \n",
+ "
\n",
+ "
7514898
\n",
+ "
EOL
\n",
+ "
NaN
\n",
+ "
NaN
\n",
+ "
NaN
\n",
+ "
NaN
\n",
+ "
NaN
\n",
+ "
Harmonia
\n",
+ "
axyridis form conspicua
\n",
+ "
Harmonia axyridis form conspicua
\n",
+ "
True
\n",
+ "
3
\n",
+ "
\n",
+ "
\n",
+ "
5396591
\n",
+ "
EOL
\n",
+ "
NaN
\n",
+ "
NaN
\n",
+ "
NaN
\n",
+ "
NaN
\n",
+ "
NaN
\n",
+ "
Coelomycete
\n",
+ "
sp. indesc.
\n",
+ "
Coelomycete sp. indesc.
\n",
+ "
True
\n",
+ "
2
\n",
+ "
\n",
+ "
\n",
+ "
1903947
\n",
+ "
EOL
\n",
+ "
NaN
\n",
+ "
NaN
\n",
+ "
NaN
\n",
+ "
NaN
\n",
+ "
NaN
\n",
+ "
Endotricha
\n",
+ "
dentiprocessa li
\n",
+ "
Endotricha dentiprocessa li
\n",
+ "
False
\n",
+ "
2
\n",
+ "
\n",
+ "
\n",
+ "
8774963
\n",
+ "
EOL
\n",
+ "
NaN
\n",
+ "
NaN
\n",
+ "
NaN
\n",
+ "
NaN
\n",
+ "
NaN
\n",
+ "
Ypthima
\n",
+ "
pandocus corticaria
\n",
+ "
Ypthima pandocus corticaria
\n",
+ "
True
\n",
+ "
2
\n",
+ "
\n",
+ "
\n",
+ "
1621291
\n",
+ "
EOL
\n",
+ "
NaN
\n",
+ "
NaN
\n",
+ "
NaN
\n",
+ "
NaN
\n",
+ "
NaN
\n",
+ "
Allopora
\n",
+ "
campyleca tylota fisher
\n",
+ "
Allopora campyleca tylota fisher
\n",
+ "
False
\n",
+ "
3
\n",
+ "
\n",
+ "
\n",
+ "
3601676
\n",
+ "
EOL
\n",
+ "
NaN
\n",
+ "
NaN
\n",
+ "
NaN
\n",
+ "
NaN
\n",
+ "
NaN
\n",
+ "
Silene
\n",
+ "
wahlbergella chowdhuri
\n",
+ "
Silene wahlbergella chowdhuri
\n",
+ "
True
\n",
+ "
2
\n",
+ "
\n",
+ "
\n",
+ "
5636041
\n",
+ "
EOL
\n",
+ "
NaN
\n",
+ "
NaN
\n",
+ "
NaN
\n",
+ "
NaN
\n",
+ "
NaN
\n",
+ "
Penstemon
\n",
+ "
brevisepalus pennell
\n",
+ "
Penstemon brevisepalus pennell
\n",
+ "
True
\n",
+ "
2
\n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " data_source kingdom phylum class order family genus \n",
+ "7514898 EOL NaN NaN NaN NaN NaN Harmonia \\\n",
+ "5396591 EOL NaN NaN NaN NaN NaN Coelomycete \n",
+ "1903947 EOL NaN NaN NaN NaN NaN Endotricha \n",
+ "8774963 EOL NaN NaN NaN NaN NaN Ypthima \n",
+ "1621291 EOL NaN NaN NaN NaN NaN Allopora \n",
+ "3601676 EOL NaN NaN NaN NaN NaN Silene \n",
+ "5636041 EOL NaN NaN NaN NaN NaN Penstemon \n",
+ "\n",
+ " species common duplicate \n",
+ "7514898 axyridis form conspicua Harmonia axyridis form conspicua True \\\n",
+ "5396591 sp. indesc. Coelomycete sp. indesc. True \n",
+ "1903947 dentiprocessa li Endotricha dentiprocessa li False \n",
+ "8774963 pandocus corticaria Ypthima pandocus corticaria True \n",
+ "1621291 campyleca tylota fisher Allopora campyleca tylota fisher False \n",
+ "3601676 wahlbergella chowdhuri Silene wahlbergella chowdhuri True \n",
+ "5636041 brevisepalus pennell Penstemon brevisepalus pennell True \n",
+ "\n",
+ " len_species \n",
+ "7514898 3 \n",
+ "5396591 2 \n",
+ "1903947 2 \n",
+ "8774963 2 \n",
+ "1621291 3 \n",
+ "3601676 2 \n",
+ "5636041 2 "
+ ]
+ },
+ "execution_count": 60,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "eol_long_species.loc[eol_long_species[\"len_species\"] < 7].sample(7)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "There are inconsistencies we likely can't resolve, some have names following the species (in the scientific name standard format of genus-species-namer-year) while others have \"sp. __ \" which is often used to indicate unknown species (pronounced \"spa\"), but the following bit may be used to indicate multiple images with unknown species are likely of the same species. \n",
+ "\n",
+ "\n",
+ "Ex from earlier: \"Adelpha godmani\" is a butterfly with species name given by Fruhstorfer in 1913 ([source](https://butterfliesofamerica.com/L/t/Adelpha_godmani_a.htm)), it was listed as \"adelpha godmani fruhstorfer\"."
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "### Label Overlap Check"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Checking for overlap between the three data sources should give pretty good results, now that most inconsistencies have been addressed.\n",
+ "\n",
+ "For now, let's just take a quick look at genera across the datasets since they are more standardized (and listed more often in BIOSCAN)."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 61,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "there are 73065 genera in EOL\n",
+ "there are 4884 genera in inat21\n",
+ "there are 3444 genera in bioscan\n"
+ ]
+ }
+ ],
+ "source": [
+ "eol_genera = list(eol_df.loc[eol_df['genus'].notna(), 'genus'].unique())\n",
+ "inat21_genera = list(inat21_df.loc[inat21_df['genus'].notna(), 'genus'].unique())\n",
+ "bioscan_genera = list(bioscan_df.loc[bioscan_df['genus'].notna(), 'genus'].unique())\n",
+ "\n",
+ "print(f\"there are {len(eol_genera)} genera in EOL\")\n",
+ "print(f\"there are {len(inat21_genera)} genera in inat21\")\n",
+ "print(f\"there are {len(bioscan_genera)} genera in bioscan\")"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 62,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "There are 4771 genera shared between EOL and iNat21.\n",
+ "There are 2760 genera shared between EOL and BIOSCAN.\n",
+ "There are 212 genera shared between iNat21 and BIOSCAN.\n",
+ "There are 207 genera shared between all three data sources.\n"
+ ]
+ }
+ ],
+ "source": [
+ "gen_overlap = list(set(eol_genera) & set(inat21_genera))\n",
+ "print(f\"There are {len(gen_overlap)} genera shared between EOL and iNat21.\")\n",
+ "print(f\"There are {len(list(set(eol_genera) & set(bioscan_genera)))} genera shared between EOL and BIOSCAN.\")\n",
+ "print(f\"There are {len(list(set(inat21_genera) & set(bioscan_genera)))} genera shared between iNat21 and BIOSCAN.\")\n",
+ "print(f\"There are {len(list(set(gen_overlap) & set(bioscan_genera)))} genera shared between all three data sources.\")"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "BIOSCAN and iNat21's overlap of genera is completely contained in EOL."
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Overall Stats\n",
+ "\n",
+ "Keep in mind, this is without fixing remaining inconsistencies observed above."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 63,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "import numpy as np"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 64,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "avgs_all_images = []\n",
+ "std_all_images = []\n",
+ "avgs_labeled_images = []\n",
+ "std_labeled_images = []\n",
+ "for taxon in taxa_com[1:]: #taxa + common\n",
+ " num_taxon = df[taxon].nunique()\n",
+ " num_img_taxon = len(df.loc[df[taxon].notna()])\n",
+ " avg_all = 10436521/num_taxon\n",
+ " std_all = np.sqrt(10436521/num_taxon)\n",
+ " avg_labeled = num_img_taxon/num_taxon\n",
+ " std_labeled = np.sqrt(num_img_taxon/num_taxon)\n",
+ " avgs_all_images.append(avg_all)\n",
+ " std_all_images.append(std_all)\n",
+ " avgs_labeled_images.append(avg_labeled)\n",
+ " std_labeled_images.append(std_labeled)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 65,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "