Update catalog for TreeOfLife-10M
Browse filesCatalog with all entries we could realign, corresponding license file, and manifest with full information for the realigned entries.
- .gitattributes +1 -0
- data/catalog.csv +2 -2
- data/licenses.csv +3 -0
- eol_realign/data/full_owner_manifest.csv +2 -2
- eol_realign/notebooks/re-gen_tol_catalog.ipynb +926 -0
.gitattributes
CHANGED
|
@@ -74,3 +74,4 @@ eol_realign/data/full_owner_manifest.csv filter=lfs diff=lfs merge=lfs -text
|
|
| 74 |
rare_species/data/rarespecies-catalog.csv filter=lfs diff=lfs merge=lfs -text
|
| 75 |
eol_realign/data/combined_manifest.csv filter=lfs diff=lfs merge=lfs -text
|
| 76 |
eol_realign/data/combined-manifest-licenses.csv filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 74 |
rare_species/data/rarespecies-catalog.csv filter=lfs diff=lfs merge=lfs -text
|
| 75 |
eol_realign/data/combined_manifest.csv filter=lfs diff=lfs merge=lfs -text
|
| 76 |
eol_realign/data/combined-manifest-licenses.csv filter=lfs diff=lfs merge=lfs -text
|
| 77 |
+
data/licenses.csv filter=lfs diff=lfs merge=lfs -text
|
data/catalog.csv
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:215d0080ebf9016e0f471aa037b4201b5a611c2675c85dfec02a23dae03bbaee
|
| 3 |
+
size 2043627688
|
data/licenses.csv
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0486ac72f6c2654913bf81b187b34c466a6e13ef8db036b583c286bb9845e2f4
|
| 3 |
+
size 2216478840
|
eol_realign/data/full_owner_manifest.csv
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"cells": [
|
| 3 |
+
{
|
| 4 |
+
"cell_type": "code",
|
| 5 |
+
"execution_count": 2,
|
| 6 |
+
"metadata": {},
|
| 7 |
+
"outputs": [],
|
| 8 |
+
"source": [
|
| 9 |
+
"import pandas as pd"
|
| 10 |
+
]
|
| 11 |
+
},
|
| 12 |
+
{
|
| 13 |
+
"cell_type": "code",
|
| 14 |
+
"execution_count": 3,
|
| 15 |
+
"metadata": {},
|
| 16 |
+
"outputs": [],
|
| 17 |
+
"source": [
|
| 18 |
+
"TOL_FILEPATH = \"../../data/\""
|
| 19 |
+
]
|
| 20 |
+
},
|
| 21 |
+
{
|
| 22 |
+
"cell_type": "markdown",
|
| 23 |
+
"metadata": {},
|
| 24 |
+
"source": [
|
| 25 |
+
"### Read in Complete EOL TreeOfLife-10M Manifest\n",
|
| 26 |
+
"\n",
|
| 27 |
+
"[`combined-manifest-licenses.csv`](https://huggingface.co/datasets/imageomics/ToL-EDA/blob/48af9b74b7a05a03b9a807a5b7b591fbf574eaec/eol_realign/data/combined-manifest-licenses.csv) is [`eol-cargo-archive_catalog_combined-manifest-checksums_links.csv`](https://huggingface.co/datasets/imageomics/ToL-EDA/blob/48af9b74b7a05a03b9a807a5b7b591fbf574eaec/eol_realign/data/eol-cargo-archive_catalog_combined-manifest-checksums_links.csv) run through the `owner_match` and `make_licenses` scripts."
|
| 28 |
+
]
|
| 29 |
+
},
|
| 30 |
+
{
|
| 31 |
+
"cell_type": "code",
|
| 32 |
+
"execution_count": 4,
|
| 33 |
+
"metadata": {},
|
| 34 |
+
"outputs": [
|
| 35 |
+
{
|
| 36 |
+
"name": "stdout",
|
| 37 |
+
"output_type": "stream",
|
| 38 |
+
"text": [
|
| 39 |
+
"<class 'pandas.core.frame.DataFrame'>\n",
|
| 40 |
+
"RangeIndex: 6841202 entries, 0 to 6841201\n",
|
| 41 |
+
"Data columns (total 32 columns):\n",
|
| 42 |
+
" # Column Non-Null Count Dtype \n",
|
| 43 |
+
"--- ------ -------------- ----- \n",
|
| 44 |
+
" 0 filename_archive 6841202 non-null object \n",
|
| 45 |
+
" 1 md5 6841202 non-null object \n",
|
| 46 |
+
" 2 combined_id_archive 6841202 non-null object \n",
|
| 47 |
+
" 3 split 6841202 non-null object \n",
|
| 48 |
+
" 4 treeoflife_id 6841202 non-null object \n",
|
| 49 |
+
" 5 bioscan_part 0 non-null float64\n",
|
| 50 |
+
" 6 bioscan_filename 0 non-null float64\n",
|
| 51 |
+
" 7 inat21_filename 0 non-null float64\n",
|
| 52 |
+
" 8 inat21_cls_name 0 non-null float64\n",
|
| 53 |
+
" 9 inat21_cls_num 0 non-null float64\n",
|
| 54 |
+
" 10 kingdom 6551473 non-null object \n",
|
| 55 |
+
" 11 phylum 6553206 non-null object \n",
|
| 56 |
+
" 12 class 6532009 non-null object \n",
|
| 57 |
+
" 13 order 6525621 non-null object \n",
|
| 58 |
+
" 14 family 6506076 non-null object \n",
|
| 59 |
+
" 15 genus 6486130 non-null object \n",
|
| 60 |
+
" 16 species 6406307 non-null object \n",
|
| 61 |
+
" 17 common 6841202 non-null object \n",
|
| 62 |
+
" 18 combined_id_catalog 6841202 non-null object \n",
|
| 63 |
+
" 19 filename_manifest 6841202 non-null object \n",
|
| 64 |
+
" 20 combined_id_manifest_redownload 6841202 non-null object \n",
|
| 65 |
+
" 21 medium_source_url 6841202 non-null object \n",
|
| 66 |
+
" 22 eol_full_size_copy_url 6841202 non-null object \n",
|
| 67 |
+
" 23 license_name 6841202 non-null object \n",
|
| 68 |
+
" 24 copyright_owner 6841202 non-null object \n",
|
| 69 |
+
" 25 expected_image_filename 6841202 non-null object \n",
|
| 70 |
+
" 26 source_0706 6841202 non-null bool \n",
|
| 71 |
+
" 27 source_0726 6841202 non-null bool \n",
|
| 72 |
+
" 28 source_1206 6841202 non-null bool \n",
|
| 73 |
+
" 29 combined_id_full_manifest 6841202 non-null object \n",
|
| 74 |
+
" 30 title 6841202 non-null object \n",
|
| 75 |
+
" 31 license_link 6809751 non-null object \n",
|
| 76 |
+
"dtypes: bool(3), float64(5), object(24)\n",
|
| 77 |
+
"memory usage: 1.5+ GB\n"
|
| 78 |
+
]
|
| 79 |
+
}
|
| 80 |
+
],
|
| 81 |
+
"source": [
|
| 82 |
+
"manifest = pd.read_csv(\"../data/combined-manifest-licenses.csv\",\n",
|
| 83 |
+
" low_memory=False,\n",
|
| 84 |
+
" dtype = {\"eol_content_id\": \"int64\", \"eol_page_id\": \"int64\"})\n",
|
| 85 |
+
"manifest.info(show_counts = True)"
|
| 86 |
+
]
|
| 87 |
+
},
|
| 88 |
+
{
|
| 89 |
+
"cell_type": "code",
|
| 90 |
+
"execution_count": 5,
|
| 91 |
+
"metadata": {},
|
| 92 |
+
"outputs": [
|
| 93 |
+
{
|
| 94 |
+
"data": {
|
| 95 |
+
"text/plain": [
|
| 96 |
+
"treeoflife_id 6219674\n",
|
| 97 |
+
"md5 6146917\n",
|
| 98 |
+
"filename_archive 6219674\n",
|
| 99 |
+
"filename_manifest 6608194\n",
|
| 100 |
+
"expected_image_filename 6608194\n",
|
| 101 |
+
"combined_id_full_manifest 6608194\n",
|
| 102 |
+
"dtype: int64"
|
| 103 |
+
]
|
| 104 |
+
},
|
| 105 |
+
"execution_count": 5,
|
| 106 |
+
"metadata": {},
|
| 107 |
+
"output_type": "execute_result"
|
| 108 |
+
}
|
| 109 |
+
],
|
| 110 |
+
"source": [
|
| 111 |
+
"manifest[[\"treeoflife_id\", \"md5\", \"filename_archive\", \"filename_manifest\",\"expected_image_filename\", \"combined_id_full_manifest\"]].nunique()"
|
| 112 |
+
]
|
| 113 |
+
},
|
| 114 |
+
{
|
| 115 |
+
"cell_type": "markdown",
|
| 116 |
+
"metadata": {},
|
| 117 |
+
"source": [
|
| 118 |
+
"## Read in TreeOfLife-10M Catalog"
|
| 119 |
+
]
|
| 120 |
+
},
|
| 121 |
+
{
|
| 122 |
+
"cell_type": "markdown",
|
| 123 |
+
"metadata": {},
|
| 124 |
+
"source": [
|
| 125 |
+
"Note that we will use [`catalog`](https://huggingface.co/datasets/imageomics/ToL-EDA/blob/main/data/catalog.csv) from v3.3 EDA update [commit](https://huggingface.co/datasets/imageomics/ToL-EDA/commit/5260e84802d2910eedc2a206e7be035cf28f64d4). This is the version reported in the paper and in visualizations that will be included with the initial dataset publication; the patch will have updated visuals to match with this version.\n",
|
| 126 |
+
"(renamed locally to `catalog-orig-v3-3.csv`)."
|
| 127 |
+
]
|
| 128 |
+
},
|
| 129 |
+
{
|
| 130 |
+
"cell_type": "code",
|
| 131 |
+
"execution_count": 6,
|
| 132 |
+
"metadata": {},
|
| 133 |
+
"outputs": [
|
| 134 |
+
{
|
| 135 |
+
"name": "stdout",
|
| 136 |
+
"output_type": "stream",
|
| 137 |
+
"text": [
|
| 138 |
+
"<class 'pandas.core.frame.DataFrame'>\n",
|
| 139 |
+
"RangeIndex: 11021779 entries, 0 to 11021778\n",
|
| 140 |
+
"Data columns (total 17 columns):\n",
|
| 141 |
+
" # Column Non-Null Count Dtype \n",
|
| 142 |
+
"--- ------ -------------- ----- \n",
|
| 143 |
+
" 0 split 11021779 non-null object \n",
|
| 144 |
+
" 1 treeoflife_id 11021779 non-null object \n",
|
| 145 |
+
" 2 eol_content_id 6844184 non-null float64\n",
|
| 146 |
+
" 3 eol_page_id 6844184 non-null float64\n",
|
| 147 |
+
" 4 bioscan_part 1235502 non-null float64\n",
|
| 148 |
+
" 5 bioscan_filename 1235502 non-null object \n",
|
| 149 |
+
" 6 inat21_filename 2942093 non-null object \n",
|
| 150 |
+
" 7 inat21_cls_name 2942093 non-null object \n",
|
| 151 |
+
" 8 inat21_cls_num 2942093 non-null float64\n",
|
| 152 |
+
" 9 kingdom 10736334 non-null object \n",
|
| 153 |
+
" 10 phylum 10738087 non-null object \n",
|
| 154 |
+
" 11 class 10716389 non-null object \n",
|
| 155 |
+
" 12 order 10709733 non-null object \n",
|
| 156 |
+
" 13 family 10674746 non-null object \n",
|
| 157 |
+
" 14 genus 9725443 non-null object \n",
|
| 158 |
+
" 15 species 9551602 non-null object \n",
|
| 159 |
+
" 16 common 11021779 non-null object \n",
|
| 160 |
+
"dtypes: float64(4), object(13)\n",
|
| 161 |
+
"memory usage: 1.4+ GB\n"
|
| 162 |
+
]
|
| 163 |
+
}
|
| 164 |
+
],
|
| 165 |
+
"source": [
|
| 166 |
+
"catalog_orig = pd.read_csv(TOL_FILEPATH + \"catalog-orig-v3-3.csv\",\n",
|
| 167 |
+
" low_memory=False\n",
|
| 168 |
+
" )\n",
|
| 169 |
+
"catalog_orig.info(show_counts = True)"
|
| 170 |
+
]
|
| 171 |
+
},
|
| 172 |
+
{
|
| 173 |
+
"cell_type": "markdown",
|
| 174 |
+
"metadata": {},
|
| 175 |
+
"source": [
|
| 176 |
+
"Separate out the EOL portion from the BIOSCAN & iNat21 portion, that way we can merge the EOL part with the manifest (requires casting the EOL content & page IDs to `int64` and combining them with an underscore to merge on the `combined_id_full_manifest`) to get the licenses and create a clear `ToL_manifest` like with rarespecies. Then we can concatenate the adjusted EOL portion with the BIOSCAN & iNat21 portion to reconstruct the catalog."
|
| 177 |
+
]
|
| 178 |
+
},
|
| 179 |
+
{
|
| 180 |
+
"cell_type": "code",
|
| 181 |
+
"execution_count": 7,
|
| 182 |
+
"metadata": {},
|
| 183 |
+
"outputs": [],
|
| 184 |
+
"source": [
|
| 185 |
+
"# EOL portion of the catalog\n",
|
| 186 |
+
"eol_catalog = catalog_orig.loc[catalog_orig[\"eol_content_id\"].notna()]\n",
|
| 187 |
+
"\n",
|
| 188 |
+
"# BIOSCAN & iNat portion of the catalog\n",
|
| 189 |
+
"bin_catalog = catalog_orig.loc[catalog_orig[\"eol_content_id\"].isna()]"
|
| 190 |
+
]
|
| 191 |
+
},
|
| 192 |
+
{
|
| 193 |
+
"cell_type": "markdown",
|
| 194 |
+
"metadata": {},
|
| 195 |
+
"source": [
|
| 196 |
+
"Recast EOL content and page IDs as `int64` in combined ID generation. Need to leave them as they are for re-concatenating with the other portion of the catalog."
|
| 197 |
+
]
|
| 198 |
+
},
|
| 199 |
+
{
|
| 200 |
+
"cell_type": "code",
|
| 201 |
+
"execution_count": 8,
|
| 202 |
+
"metadata": {},
|
| 203 |
+
"outputs": [
|
| 204 |
+
{
|
| 205 |
+
"name": "stderr",
|
| 206 |
+
"output_type": "stream",
|
| 207 |
+
"text": [
|
| 208 |
+
"/var/folders/nv/f0fq1p1n1_3b11x579py_0q80000gq/T/ipykernel_59366/112309718.py:1: SettingWithCopyWarning: \n",
|
| 209 |
+
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
| 210 |
+
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
| 211 |
+
"\n",
|
| 212 |
+
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
| 213 |
+
" eol_catalog[\"combined_id_catalog\"] = eol_catalog[\"eol_content_id\"].astype(int).astype(str) + \"_\" + eol_catalog[\"eol_page_id\"].astype(int).astype(str)\n"
|
| 214 |
+
]
|
| 215 |
+
},
|
| 216 |
+
{
|
| 217 |
+
"data": {
|
| 218 |
+
"text/html": [
|
| 219 |
+
"<div>\n",
|
| 220 |
+
"<style scoped>\n",
|
| 221 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
| 222 |
+
" vertical-align: middle;\n",
|
| 223 |
+
" }\n",
|
| 224 |
+
"\n",
|
| 225 |
+
" .dataframe tbody tr th {\n",
|
| 226 |
+
" vertical-align: top;\n",
|
| 227 |
+
" }\n",
|
| 228 |
+
"\n",
|
| 229 |
+
" .dataframe thead th {\n",
|
| 230 |
+
" text-align: right;\n",
|
| 231 |
+
" }\n",
|
| 232 |
+
"</style>\n",
|
| 233 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
| 234 |
+
" <thead>\n",
|
| 235 |
+
" <tr style=\"text-align: right;\">\n",
|
| 236 |
+
" <th></th>\n",
|
| 237 |
+
" <th>split</th>\n",
|
| 238 |
+
" <th>treeoflife_id</th>\n",
|
| 239 |
+
" <th>eol_content_id</th>\n",
|
| 240 |
+
" <th>eol_page_id</th>\n",
|
| 241 |
+
" <th>bioscan_part</th>\n",
|
| 242 |
+
" <th>bioscan_filename</th>\n",
|
| 243 |
+
" <th>inat21_filename</th>\n",
|
| 244 |
+
" <th>inat21_cls_name</th>\n",
|
| 245 |
+
" <th>inat21_cls_num</th>\n",
|
| 246 |
+
" <th>kingdom</th>\n",
|
| 247 |
+
" <th>phylum</th>\n",
|
| 248 |
+
" <th>class</th>\n",
|
| 249 |
+
" <th>order</th>\n",
|
| 250 |
+
" <th>family</th>\n",
|
| 251 |
+
" <th>genus</th>\n",
|
| 252 |
+
" <th>species</th>\n",
|
| 253 |
+
" <th>common</th>\n",
|
| 254 |
+
" <th>combined_id_catalog</th>\n",
|
| 255 |
+
" </tr>\n",
|
| 256 |
+
" </thead>\n",
|
| 257 |
+
" <tbody>\n",
|
| 258 |
+
" <tr>\n",
|
| 259 |
+
" <th>0</th>\n",
|
| 260 |
+
" <td>train_small</td>\n",
|
| 261 |
+
" <td>a87c78c0-eb7c-45ee-9a98-681f61292d6b</td>\n",
|
| 262 |
+
" <td>29586132.0</td>\n",
|
| 263 |
+
" <td>65441690.0</td>\n",
|
| 264 |
+
" <td>NaN</td>\n",
|
| 265 |
+
" <td>NaN</td>\n",
|
| 266 |
+
" <td>NaN</td>\n",
|
| 267 |
+
" <td>NaN</td>\n",
|
| 268 |
+
" <td>NaN</td>\n",
|
| 269 |
+
" <td>Animalia</td>\n",
|
| 270 |
+
" <td>Arthropoda</td>\n",
|
| 271 |
+
" <td>Insecta</td>\n",
|
| 272 |
+
" <td>Lepidoptera</td>\n",
|
| 273 |
+
" <td>Nymphalidae</td>\n",
|
| 274 |
+
" <td>Acraea</td>\n",
|
| 275 |
+
" <td>terpsicore</td>\n",
|
| 276 |
+
" <td>Tawny Coster</td>\n",
|
| 277 |
+
" <td>29586132_65441690</td>\n",
|
| 278 |
+
" </tr>\n",
|
| 279 |
+
" <tr>\n",
|
| 280 |
+
" <th>1</th>\n",
|
| 281 |
+
" <td>train_small</td>\n",
|
| 282 |
+
" <td>f8158395-d663-4f0f-b38d-1c6ecb16a8ca</td>\n",
|
| 283 |
+
" <td>29811010.0</td>\n",
|
| 284 |
+
" <td>45510040.0</td>\n",
|
| 285 |
+
" <td>NaN</td>\n",
|
| 286 |
+
" <td>NaN</td>\n",
|
| 287 |
+
" <td>NaN</td>\n",
|
| 288 |
+
" <td>NaN</td>\n",
|
| 289 |
+
" <td>NaN</td>\n",
|
| 290 |
+
" <td>Animalia</td>\n",
|
| 291 |
+
" <td>Chordata</td>\n",
|
| 292 |
+
" <td>Aves</td>\n",
|
| 293 |
+
" <td>Passeriformes</td>\n",
|
| 294 |
+
" <td>Pycnonotidae</td>\n",
|
| 295 |
+
" <td>Pycnonotus</td>\n",
|
| 296 |
+
" <td>cafer</td>\n",
|
| 297 |
+
" <td>Red-vented Bulbul</td>\n",
|
| 298 |
+
" <td>29811010_45510040</td>\n",
|
| 299 |
+
" </tr>\n",
|
| 300 |
+
" <tr>\n",
|
| 301 |
+
" <th>2</th>\n",
|
| 302 |
+
" <td>train_small</td>\n",
|
| 303 |
+
" <td>63aab6e3-b01d-4259-be13-9dd41becaf29</td>\n",
|
| 304 |
+
" <td>28563112.0</td>\n",
|
| 305 |
+
" <td>736062.0</td>\n",
|
| 306 |
+
" <td>NaN</td>\n",
|
| 307 |
+
" <td>NaN</td>\n",
|
| 308 |
+
" <td>NaN</td>\n",
|
| 309 |
+
" <td>NaN</td>\n",
|
| 310 |
+
" <td>NaN</td>\n",
|
| 311 |
+
" <td>Animalia</td>\n",
|
| 312 |
+
" <td>Arthropoda</td>\n",
|
| 313 |
+
" <td>Insecta</td>\n",
|
| 314 |
+
" <td>Diptera</td>\n",
|
| 315 |
+
" <td>Empididae</td>\n",
|
| 316 |
+
" <td>Rhamphomyia</td>\n",
|
| 317 |
+
" <td>limbata</td>\n",
|
| 318 |
+
" <td>Rhamphomyia limbata</td>\n",
|
| 319 |
+
" <td>28563112_736062</td>\n",
|
| 320 |
+
" </tr>\n",
|
| 321 |
+
" <tr>\n",
|
| 322 |
+
" <th>3</th>\n",
|
| 323 |
+
" <td>train_small</td>\n",
|
| 324 |
+
" <td>cf2d58e1-d504-489c-80dd-e99407f8c13d</td>\n",
|
| 325 |
+
" <td>29002118.0</td>\n",
|
| 326 |
+
" <td>349296.0</td>\n",
|
| 327 |
+
" <td>NaN</td>\n",
|
| 328 |
+
" <td>NaN</td>\n",
|
| 329 |
+
" <td>NaN</td>\n",
|
| 330 |
+
" <td>NaN</td>\n",
|
| 331 |
+
" <td>NaN</td>\n",
|
| 332 |
+
" <td>Animalia</td>\n",
|
| 333 |
+
" <td>Arthropoda</td>\n",
|
| 334 |
+
" <td>Insecta</td>\n",
|
| 335 |
+
" <td>Lepidoptera</td>\n",
|
| 336 |
+
" <td>Geometridae</td>\n",
|
| 337 |
+
" <td>Exelis</td>\n",
|
| 338 |
+
" <td>pyrolaria</td>\n",
|
| 339 |
+
" <td>Fine Lined Gray</td>\n",
|
| 340 |
+
" <td>29002118_349296</td>\n",
|
| 341 |
+
" </tr>\n",
|
| 342 |
+
" </tbody>\n",
|
| 343 |
+
"</table>\n",
|
| 344 |
+
"</div>"
|
| 345 |
+
],
|
| 346 |
+
"text/plain": [
|
| 347 |
+
" split treeoflife_id eol_content_id \\\n",
|
| 348 |
+
"0 train_small a87c78c0-eb7c-45ee-9a98-681f61292d6b 29586132.0 \n",
|
| 349 |
+
"1 train_small f8158395-d663-4f0f-b38d-1c6ecb16a8ca 29811010.0 \n",
|
| 350 |
+
"2 train_small 63aab6e3-b01d-4259-be13-9dd41becaf29 28563112.0 \n",
|
| 351 |
+
"3 train_small cf2d58e1-d504-489c-80dd-e99407f8c13d 29002118.0 \n",
|
| 352 |
+
"\n",
|
| 353 |
+
" eol_page_id bioscan_part bioscan_filename inat21_filename inat21_cls_name \\\n",
|
| 354 |
+
"0 65441690.0 NaN NaN NaN NaN \n",
|
| 355 |
+
"1 45510040.0 NaN NaN NaN NaN \n",
|
| 356 |
+
"2 736062.0 NaN NaN NaN NaN \n",
|
| 357 |
+
"3 349296.0 NaN NaN NaN NaN \n",
|
| 358 |
+
"\n",
|
| 359 |
+
" inat21_cls_num kingdom phylum class order family \\\n",
|
| 360 |
+
"0 NaN Animalia Arthropoda Insecta Lepidoptera Nymphalidae \n",
|
| 361 |
+
"1 NaN Animalia Chordata Aves Passeriformes Pycnonotidae \n",
|
| 362 |
+
"2 NaN Animalia Arthropoda Insecta Diptera Empididae \n",
|
| 363 |
+
"3 NaN Animalia Arthropoda Insecta Lepidoptera Geometridae \n",
|
| 364 |
+
"\n",
|
| 365 |
+
" genus species common combined_id_catalog \n",
|
| 366 |
+
"0 Acraea terpsicore Tawny Coster 29586132_65441690 \n",
|
| 367 |
+
"1 Pycnonotus cafer Red-vented Bulbul 29811010_45510040 \n",
|
| 368 |
+
"2 Rhamphomyia limbata Rhamphomyia limbata 28563112_736062 \n",
|
| 369 |
+
"3 Exelis pyrolaria Fine Lined Gray 29002118_349296 "
|
| 370 |
+
]
|
| 371 |
+
},
|
| 372 |
+
"execution_count": 8,
|
| 373 |
+
"metadata": {},
|
| 374 |
+
"output_type": "execute_result"
|
| 375 |
+
}
|
| 376 |
+
],
|
| 377 |
+
"source": [
|
| 378 |
+
"eol_catalog[\"combined_id_catalog\"] = eol_catalog[\"eol_content_id\"].astype(int).astype(str) + \"_\" + eol_catalog[\"eol_page_id\"].astype(int).astype(str)\n",
|
| 379 |
+
"eol_catalog.head(4)"
|
| 380 |
+
]
|
| 381 |
+
},
|
| 382 |
+
{
|
| 383 |
+
"cell_type": "markdown",
|
| 384 |
+
"metadata": {},
|
| 385 |
+
"source": [
|
| 386 |
+
"Keep in mind, we will have some repeated entries due to the `train_small` split, so we will merge on just `split != \"train_small\"`"
|
| 387 |
+
]
|
| 388 |
+
},
|
| 389 |
+
{
|
| 390 |
+
"cell_type": "code",
|
| 391 |
+
"execution_count": 9,
|
| 392 |
+
"metadata": {},
|
| 393 |
+
"outputs": [],
|
| 394 |
+
"source": [
|
| 395 |
+
"train_val_eol_catalog = eol_catalog.loc[eol_catalog[\"split\"] != \"train_small\"]"
|
| 396 |
+
]
|
| 397 |
+
},
|
| 398 |
+
{
|
| 399 |
+
"cell_type": "code",
|
| 400 |
+
"execution_count": 10,
|
| 401 |
+
"metadata": {},
|
| 402 |
+
"outputs": [
|
| 403 |
+
{
|
| 404 |
+
"name": "stdout",
|
| 405 |
+
"output_type": "stream",
|
| 406 |
+
"text": [
|
| 407 |
+
"We should have 6250420 entries in our merge, minus the approximately 30K we couldn't match.\n"
|
| 408 |
+
]
|
| 409 |
+
}
|
| 410 |
+
],
|
| 411 |
+
"source": [
|
| 412 |
+
"print(f\"We should have {train_val_eol_catalog.shape[0]} entries in our merge, minus the approximately 30K we couldn't match.\")"
|
| 413 |
+
]
|
| 414 |
+
},
|
| 415 |
+
{
|
| 416 |
+
"cell_type": "markdown",
|
| 417 |
+
"metadata": {},
|
| 418 |
+
"source": [
|
| 419 |
+
"We should have 6,250,420 entries in our merge, minus the approximately 30K we couldn't match.. The expectation is that this will be 6,219,674 entries. Details on this expectation & the `train_small` implications can be found in [`eol_realign/notebooks/links_align_reduced.ipynb`](https://huggingface.co/datasets/imageomics/ToL-EDA/blob/3438fe9a88c0f377a4d8ac4c6c0de796858a08ac/eol_realign/notebooks/links_align_reduced.ipynb)."
|
| 420 |
+
]
|
| 421 |
+
},
|
| 422 |
+
{
|
| 423 |
+
"cell_type": "code",
|
| 424 |
+
"execution_count": 11,
|
| 425 |
+
"metadata": {},
|
| 426 |
+
"outputs": [],
|
| 427 |
+
"source": [
|
| 428 |
+
"# Catalog Columns\n",
|
| 429 |
+
"id_cols = [\"treeoflife_id\", \"eol_content_id\", \"eol_page_id\", \"combined_id_catalog\"]\n",
|
| 430 |
+
"\n",
|
| 431 |
+
"# Manifest Columns\n",
|
| 432 |
+
"manifest_cols = [\"treeoflife_id\",\n",
|
| 433 |
+
" \"md5\",\n",
|
| 434 |
+
" \"medium_source_url\",\n",
|
| 435 |
+
" \"eol_full_size_copy_url\",\n",
|
| 436 |
+
" \"license_name\",\n",
|
| 437 |
+
" \"copyright_owner\",\n",
|
| 438 |
+
" \"license_link\",\n",
|
| 439 |
+
" \"title\",\n",
|
| 440 |
+
" \"filename_archive\",\n",
|
| 441 |
+
" \"filename_manifest\",\n",
|
| 442 |
+
" \"expected_image_filename\",\n",
|
| 443 |
+
" \"combined_id_full_manifest\"]"
|
| 444 |
+
]
|
| 445 |
+
},
|
| 446 |
+
{
|
| 447 |
+
"cell_type": "code",
|
| 448 |
+
"execution_count": 12,
|
| 449 |
+
"metadata": {},
|
| 450 |
+
"outputs": [
|
| 451 |
+
{
|
| 452 |
+
"name": "stdout",
|
| 453 |
+
"output_type": "stream",
|
| 454 |
+
"text": [
|
| 455 |
+
"<class 'pandas.core.frame.DataFrame'>\n",
|
| 456 |
+
"RangeIndex: 6841202 entries, 0 to 6841201\n",
|
| 457 |
+
"Data columns (total 15 columns):\n",
|
| 458 |
+
" # Column Non-Null Count Dtype \n",
|
| 459 |
+
"--- ------ -------------- ----- \n",
|
| 460 |
+
" 0 treeoflife_id 6841202 non-null object \n",
|
| 461 |
+
" 1 eol_content_id 6841202 non-null float64\n",
|
| 462 |
+
" 2 eol_page_id 6841202 non-null float64\n",
|
| 463 |
+
" 3 combined_id_catalog 6841202 non-null object \n",
|
| 464 |
+
" 4 md5 6841202 non-null object \n",
|
| 465 |
+
" 5 medium_source_url 6841202 non-null object \n",
|
| 466 |
+
" 6 eol_full_size_copy_url 6841202 non-null object \n",
|
| 467 |
+
" 7 license_name 6841202 non-null object \n",
|
| 468 |
+
" 8 copyright_owner 6841202 non-null object \n",
|
| 469 |
+
" 9 license_link 6809751 non-null object \n",
|
| 470 |
+
" 10 title 6841202 non-null object \n",
|
| 471 |
+
" 11 filename_archive 6841202 non-null object \n",
|
| 472 |
+
" 12 filename_manifest 6841202 non-null object \n",
|
| 473 |
+
" 13 expected_image_filename 6841202 non-null object \n",
|
| 474 |
+
" 14 combined_id_full_manifest 6841202 non-null object \n",
|
| 475 |
+
"dtypes: float64(2), object(13)\n",
|
| 476 |
+
"memory usage: 782.9+ MB\n"
|
| 477 |
+
]
|
| 478 |
+
}
|
| 479 |
+
],
|
| 480 |
+
"source": [
|
| 481 |
+
"tol_manifest = pd.merge(train_val_eol_catalog[id_cols],\n",
|
| 482 |
+
" manifest[manifest_cols],\n",
|
| 483 |
+
" on = \"treeoflife_id\",\n",
|
| 484 |
+
" how = \"inner\")\n",
|
| 485 |
+
"tol_manifest.info(show_counts = True)"
|
| 486 |
+
]
|
| 487 |
+
},
|
| 488 |
+
{
|
| 489 |
+
"cell_type": "code",
|
| 490 |
+
"execution_count": 13,
|
| 491 |
+
"metadata": {},
|
| 492 |
+
"outputs": [
|
| 493 |
+
{
|
| 494 |
+
"data": {
|
| 495 |
+
"text/plain": [
|
| 496 |
+
"treeoflife_id 6219674\n",
|
| 497 |
+
"eol_content_id 6219674\n",
|
| 498 |
+
"eol_page_id 501807\n",
|
| 499 |
+
"combined_id_catalog 6219674\n",
|
| 500 |
+
"md5 6146917\n",
|
| 501 |
+
"medium_source_url 6217871\n",
|
| 502 |
+
"eol_full_size_copy_url 6247692\n",
|
| 503 |
+
"license_name 16\n",
|
| 504 |
+
"copyright_owner 403215\n",
|
| 505 |
+
"license_link 11\n",
|
| 506 |
+
"title 482137\n",
|
| 507 |
+
"filename_archive 6219674\n",
|
| 508 |
+
"filename_manifest 6608194\n",
|
| 509 |
+
"expected_image_filename 6608194\n",
|
| 510 |
+
"combined_id_full_manifest 6608194\n",
|
| 511 |
+
"dtype: int64"
|
| 512 |
+
]
|
| 513 |
+
},
|
| 514 |
+
"execution_count": 13,
|
| 515 |
+
"metadata": {},
|
| 516 |
+
"output_type": "execute_result"
|
| 517 |
+
}
|
| 518 |
+
],
|
| 519 |
+
"source": [
|
| 520 |
+
"tol_manifest.nunique()"
|
| 521 |
+
]
|
| 522 |
+
},
|
| 523 |
+
{
|
| 524 |
+
"cell_type": "markdown",
|
| 525 |
+
"metadata": {},
|
| 526 |
+
"source": [
|
| 527 |
+
"Let's reduce this down to just the unique `treeoflife_id`s. All URLs are valid and the EOL content and page IDs (plus `combined_id_catalog` will match the filenames we have saved)."
|
| 528 |
+
]
|
| 529 |
+
},
|
| 530 |
+
{
|
| 531 |
+
"cell_type": "code",
|
| 532 |
+
"execution_count": 14,
|
| 533 |
+
"metadata": {},
|
| 534 |
+
"outputs": [
|
| 535 |
+
{
|
| 536 |
+
"name": "stdout",
|
| 537 |
+
"output_type": "stream",
|
| 538 |
+
"text": [
|
| 539 |
+
"(6219674, 16)\n"
|
| 540 |
+
]
|
| 541 |
+
},
|
| 542 |
+
{
|
| 543 |
+
"data": {
|
| 544 |
+
"text/plain": [
|
| 545 |
+
"treeoflife_id 6219674\n",
|
| 546 |
+
"eol_content_id 6219674\n",
|
| 547 |
+
"eol_page_id 501807\n",
|
| 548 |
+
"combined_id_catalog 6219674\n",
|
| 549 |
+
"md5 6146917\n",
|
| 550 |
+
"medium_source_url 6144920\n",
|
| 551 |
+
"eol_full_size_copy_url 6146917\n",
|
| 552 |
+
"license_name 16\n",
|
| 553 |
+
"copyright_owner 398253\n",
|
| 554 |
+
"license_link 11\n",
|
| 555 |
+
"title 475702\n",
|
| 556 |
+
"filename_archive 6219674\n",
|
| 557 |
+
"filename_manifest 6146917\n",
|
| 558 |
+
"expected_image_filename 6146917\n",
|
| 559 |
+
"combined_id_full_manifest 6146917\n",
|
| 560 |
+
"duplicate_tol_id 1\n",
|
| 561 |
+
"dtype: int64"
|
| 562 |
+
]
|
| 563 |
+
},
|
| 564 |
+
"execution_count": 14,
|
| 565 |
+
"metadata": {},
|
| 566 |
+
"output_type": "execute_result"
|
| 567 |
+
}
|
| 568 |
+
],
|
| 569 |
+
"source": [
|
| 570 |
+
"tol_manifest[\"duplicate_tol_id\"] = tol_manifest.duplicated(\"treeoflife_id\", keep = \"first\")\n",
|
| 571 |
+
"tol_manifest = tol_manifest.loc[~tol_manifest[\"duplicate_tol_id\"]]\n",
|
| 572 |
+
"\n",
|
| 573 |
+
"print(tol_manifest.shape)\n",
|
| 574 |
+
"tol_manifest.nunique()"
|
| 575 |
+
]
|
| 576 |
+
},
|
| 577 |
+
{
|
| 578 |
+
"cell_type": "markdown",
|
| 579 |
+
"metadata": {},
|
| 580 |
+
"source": [
|
| 581 |
+
"Clearly, these match with the archive filenames.\n",
|
| 582 |
+
"\n",
|
| 583 |
+
"Our numbers match the expected count. Let's check our `copyright_owner` and `title` coverage. "
|
| 584 |
+
]
|
| 585 |
+
},
|
| 586 |
+
{
|
| 587 |
+
"cell_type": "code",
|
| 588 |
+
"execution_count": 15,
|
| 589 |
+
"metadata": {},
|
| 590 |
+
"outputs": [
|
| 591 |
+
{
|
| 592 |
+
"data": {
|
| 593 |
+
"text/plain": [
|
| 594 |
+
"license_name\n",
|
| 595 |
+
"No known copyright restrictions 7389\n",
|
| 596 |
+
"cc-by-nc-sa-3.0 4247\n",
|
| 597 |
+
"cc-publicdomain 3422\n",
|
| 598 |
+
"cc-by-nc 3029\n",
|
| 599 |
+
"cc-by-3.0 470\n",
|
| 600 |
+
"cc-by-sa-3.0 171\n",
|
| 601 |
+
"cc-0-1.0 32\n",
|
| 602 |
+
"cc-by-nc-2.0 2\n",
|
| 603 |
+
"cc-by-nc-4.0 1\n",
|
| 604 |
+
"Name: count, dtype: int64"
|
| 605 |
+
]
|
| 606 |
+
},
|
| 607 |
+
"execution_count": 15,
|
| 608 |
+
"metadata": {},
|
| 609 |
+
"output_type": "execute_result"
|
| 610 |
+
}
|
| 611 |
+
],
|
| 612 |
+
"source": [
|
| 613 |
+
"tol_manifest.loc[tol_manifest[\"copyright_owner\"] == \"not provided\", \"license_name\"].value_counts()"
|
| 614 |
+
]
|
| 615 |
+
},
|
| 616 |
+
{
|
| 617 |
+
"cell_type": "code",
|
| 618 |
+
"execution_count": 16,
|
| 619 |
+
"metadata": {},
|
| 620 |
+
"outputs": [
|
| 621 |
+
{
|
| 622 |
+
"data": {
|
| 623 |
+
"text/plain": [
|
| 624 |
+
"license_name\n",
|
| 625 |
+
"cc-by-nc-4.0 2401921\n",
|
| 626 |
+
"cc-by-sa-3.0 760953\n",
|
| 627 |
+
"cc-by-nc-sa-3.0 664194\n",
|
| 628 |
+
"cc-by-3.0 439653\n",
|
| 629 |
+
"cc-by-4.0 368046\n",
|
| 630 |
+
"cc-by-nc 316103\n",
|
| 631 |
+
"cc-by-nc-sa-4.0 184204\n",
|
| 632 |
+
"cc-by-nc-sa 154761\n",
|
| 633 |
+
"cc-publicdomain 129257\n",
|
| 634 |
+
"cc-by-sa-4.0 65003\n",
|
| 635 |
+
"cc-by 58303\n",
|
| 636 |
+
"cc-by-sa-2.0 30157\n",
|
| 637 |
+
"cc-by-nc-2.0 27718\n",
|
| 638 |
+
"cc-0-1.0 20358\n",
|
| 639 |
+
"No known copyright restrictions 16042\n",
|
| 640 |
+
"cc-by-nc-sa-2.5 315\n",
|
| 641 |
+
"Name: count, dtype: int64"
|
| 642 |
+
]
|
| 643 |
+
},
|
| 644 |
+
"execution_count": 16,
|
| 645 |
+
"metadata": {},
|
| 646 |
+
"output_type": "execute_result"
|
| 647 |
+
}
|
| 648 |
+
],
|
| 649 |
+
"source": [
|
| 650 |
+
"tol_manifest.loc[tol_manifest[\"title\"] == \"not provided\", \"license_name\"].value_counts()"
|
| 651 |
+
]
|
| 652 |
+
},
|
| 653 |
+
{
|
| 654 |
+
"cell_type": "markdown",
|
| 655 |
+
"metadata": {},
|
| 656 |
+
"source": [
|
| 657 |
+
"At least most unmatched lack of copyright restrictions or are CC0; we did what we could."
|
| 658 |
+
]
|
| 659 |
+
},
|
| 660 |
+
{
|
| 661 |
+
"cell_type": "markdown",
|
| 662 |
+
"metadata": {},
|
| 663 |
+
"source": [
|
| 664 |
+
"### Save Full Owner Manifest\n"
|
| 665 |
+
]
|
| 666 |
+
},
|
| 667 |
+
{
|
| 668 |
+
"cell_type": "code",
|
| 669 |
+
"execution_count": 17,
|
| 670 |
+
"metadata": {},
|
| 671 |
+
"outputs": [],
|
| 672 |
+
"source": [
|
| 673 |
+
"tol_manifest.to_csv(\"../data/full_owner_manifest.csv\", index = False)"
|
| 674 |
+
]
|
| 675 |
+
},
|
| 676 |
+
{
|
| 677 |
+
"cell_type": "markdown",
|
| 678 |
+
"metadata": {},
|
| 679 |
+
"source": [
|
| 680 |
+
"### Make and Save License File"
|
| 681 |
+
]
|
| 682 |
+
},
|
| 683 |
+
{
|
| 684 |
+
"cell_type": "code",
|
| 685 |
+
"execution_count": 18,
|
| 686 |
+
"metadata": {},
|
| 687 |
+
"outputs": [],
|
| 688 |
+
"source": [
|
| 689 |
+
"licesne_cols = [\"treeoflife_id\",\n",
|
| 690 |
+
" \"eol_content_id\",\n",
|
| 691 |
+
" \"eol_page_id\",\n",
|
| 692 |
+
" \"md5\",\n",
|
| 693 |
+
" \"medium_source_url\",\n",
|
| 694 |
+
" \"eol_full_size_copy_url\",\n",
|
| 695 |
+
" \"license_name\",\n",
|
| 696 |
+
" \"copyright_owner\",\n",
|
| 697 |
+
" \"license_link\",\n",
|
| 698 |
+
" \"title\"]\n",
|
| 699 |
+
"\n",
|
| 700 |
+
"licenses = tol_manifest[licesne_cols]"
|
| 701 |
+
]
|
| 702 |
+
},
|
| 703 |
+
{
|
| 704 |
+
"cell_type": "code",
|
| 705 |
+
"execution_count": 19,
|
| 706 |
+
"metadata": {},
|
| 707 |
+
"outputs": [],
|
| 708 |
+
"source": [
|
| 709 |
+
"licenses.to_csv(TOL_FILEPATH + \"licenses.csv\", index = False)"
|
| 710 |
+
]
|
| 711 |
+
},
|
| 712 |
+
{
|
| 713 |
+
"cell_type": "markdown",
|
| 714 |
+
"metadata": {},
|
| 715 |
+
"source": [
|
| 716 |
+
"## Make Updated Catalog\n",
|
| 717 |
+
"\n",
|
| 718 |
+
"Reconnect the EOL portion of the catalog to the BIOSCAN and iNat21 portion."
|
| 719 |
+
]
|
| 720 |
+
},
|
| 721 |
+
{
|
| 722 |
+
"cell_type": "code",
|
| 723 |
+
"execution_count": 20,
|
| 724 |
+
"metadata": {},
|
| 725 |
+
"outputs": [
|
| 726 |
+
{
|
| 727 |
+
"data": {
|
| 728 |
+
"text/plain": [
|
| 729 |
+
"['split',\n",
|
| 730 |
+
" 'treeoflife_id',\n",
|
| 731 |
+
" 'eol_content_id',\n",
|
| 732 |
+
" 'eol_page_id',\n",
|
| 733 |
+
" 'bioscan_part',\n",
|
| 734 |
+
" 'bioscan_filename',\n",
|
| 735 |
+
" 'inat21_filename',\n",
|
| 736 |
+
" 'inat21_cls_name',\n",
|
| 737 |
+
" 'inat21_cls_num',\n",
|
| 738 |
+
" 'kingdom',\n",
|
| 739 |
+
" 'phylum',\n",
|
| 740 |
+
" 'class',\n",
|
| 741 |
+
" 'order',\n",
|
| 742 |
+
" 'family',\n",
|
| 743 |
+
" 'genus',\n",
|
| 744 |
+
" 'species',\n",
|
| 745 |
+
" 'common']"
|
| 746 |
+
]
|
| 747 |
+
},
|
| 748 |
+
"execution_count": 20,
|
| 749 |
+
"metadata": {},
|
| 750 |
+
"output_type": "execute_result"
|
| 751 |
+
}
|
| 752 |
+
],
|
| 753 |
+
"source": [
|
| 754 |
+
"cat_cols = list(catalog_orig.columns)\n",
|
| 755 |
+
"cat_cols"
|
| 756 |
+
]
|
| 757 |
+
},
|
| 758 |
+
{
|
| 759 |
+
"cell_type": "markdown",
|
| 760 |
+
"metadata": {},
|
| 761 |
+
"source": [
|
| 762 |
+
"Need to first reduce the `eol_catalog` (still has the `train_small` split we want to keep).\n",
|
| 763 |
+
"\n",
|
| 764 |
+
"BIOSCAN & iNat portion of the catalog: `bin_catalog`"
|
| 765 |
+
]
|
| 766 |
+
},
|
| 767 |
+
{
|
| 768 |
+
"cell_type": "code",
|
| 769 |
+
"execution_count": 21,
|
| 770 |
+
"metadata": {},
|
| 771 |
+
"outputs": [
|
| 772 |
+
{
|
| 773 |
+
"name": "stdout",
|
| 774 |
+
"output_type": "stream",
|
| 775 |
+
"text": [
|
| 776 |
+
"(6810437, 18)\n"
|
| 777 |
+
]
|
| 778 |
+
},
|
| 779 |
+
{
|
| 780 |
+
"data": {
|
| 781 |
+
"text/plain": [
|
| 782 |
+
"6219674"
|
| 783 |
+
]
|
| 784 |
+
},
|
| 785 |
+
"execution_count": 21,
|
| 786 |
+
"metadata": {},
|
| 787 |
+
"output_type": "execute_result"
|
| 788 |
+
}
|
| 789 |
+
],
|
| 790 |
+
"source": [
|
| 791 |
+
"matched_tol_ids = list(tol_manifest.treeoflife_id)\n",
|
| 792 |
+
"\n",
|
| 793 |
+
"reduced_eol_cat = eol_catalog.loc[eol_catalog[\"treeoflife_id\"].isin(matched_tol_ids)]\n",
|
| 794 |
+
"\n",
|
| 795 |
+
"#check we have expected numbers (6,219,674 + 590,730 = 6,810,404, still only 6,219,674 unique)\n",
|
| 796 |
+
"print(reduced_eol_cat.shape)\n",
|
| 797 |
+
"reduced_eol_cat.treeoflife_id.nunique()"
|
| 798 |
+
]
|
| 799 |
+
},
|
| 800 |
+
{
|
| 801 |
+
"cell_type": "markdown",
|
| 802 |
+
"metadata": {},
|
| 803 |
+
"source": [
|
| 804 |
+
"Looks like we recovered 33 more from the small train set than we expected. These came from the archive recovery (had we merged on `combined_id_archive` instead of `combined_id_full_manifest` in [`links_align_reduced.ipynb`](https://huggingface.co/datasets/imageomics/ToL-EDA/blob/3438fe9a88c0f377a4d8ac4c6c0de796858a08ac/eol_realign/notebooks/links_align_reduced.ipynb), would have seen that difference)."
|
| 805 |
+
]
|
| 806 |
+
},
|
| 807 |
+
{
|
| 808 |
+
"cell_type": "code",
|
| 809 |
+
"execution_count": 24,
|
| 810 |
+
"metadata": {},
|
| 811 |
+
"outputs": [
|
| 812 |
+
{
|
| 813 |
+
"name": "stdout",
|
| 814 |
+
"output_type": "stream",
|
| 815 |
+
"text": [
|
| 816 |
+
"The BIOSCAN & iNate portion have 4177595 total images, with 3815156 unique entries.\n"
|
| 817 |
+
]
|
| 818 |
+
}
|
| 819 |
+
],
|
| 820 |
+
"source": [
|
| 821 |
+
"print(f\"The BIOSCAN & iNate portion have {bin_catalog.shape[0]} total images, with {bin_catalog.treeoflife_id.nunique()} unique entries.\")"
|
| 822 |
+
]
|
| 823 |
+
},
|
| 824 |
+
{
|
| 825 |
+
"cell_type": "markdown",
|
| 826 |
+
"metadata": {},
|
| 827 |
+
"source": [
|
| 828 |
+
"We have expected 10,034,830 unique entries in the final set, 10,988,032 total entries."
|
| 829 |
+
]
|
| 830 |
+
},
|
| 831 |
+
{
|
| 832 |
+
"cell_type": "code",
|
| 833 |
+
"execution_count": 25,
|
| 834 |
+
"metadata": {},
|
| 835 |
+
"outputs": [
|
| 836 |
+
{
|
| 837 |
+
"name": "stdout",
|
| 838 |
+
"output_type": "stream",
|
| 839 |
+
"text": [
|
| 840 |
+
"(10988032, 17)\n"
|
| 841 |
+
]
|
| 842 |
+
},
|
| 843 |
+
{
|
| 844 |
+
"data": {
|
| 845 |
+
"text/plain": [
|
| 846 |
+
"split 3\n",
|
| 847 |
+
"treeoflife_id 10034830\n",
|
| 848 |
+
"eol_content_id 6219674\n",
|
| 849 |
+
"eol_page_id 501807\n",
|
| 850 |
+
"bioscan_part 113\n",
|
| 851 |
+
"bioscan_filename 1128313\n",
|
| 852 |
+
"inat21_filename 2686843\n",
|
| 853 |
+
"inat21_cls_name 10000\n",
|
| 854 |
+
"inat21_cls_num 10000\n",
|
| 855 |
+
"kingdom 12\n",
|
| 856 |
+
"phylum 108\n",
|
| 857 |
+
"class 347\n",
|
| 858 |
+
"order 1495\n",
|
| 859 |
+
"family 7954\n",
|
| 860 |
+
"genus 73687\n",
|
| 861 |
+
"species 163001\n",
|
| 862 |
+
"common 442253\n",
|
| 863 |
+
"dtype: int64"
|
| 864 |
+
]
|
| 865 |
+
},
|
| 866 |
+
"execution_count": 25,
|
| 867 |
+
"metadata": {},
|
| 868 |
+
"output_type": "execute_result"
|
| 869 |
+
}
|
| 870 |
+
],
|
| 871 |
+
"source": [
|
| 872 |
+
"updated_catalog = pd.concat([reduced_eol_cat[cat_cols], bin_catalog], ignore_index = True)\n",
|
| 873 |
+
"\n",
|
| 874 |
+
"print(updated_catalog.shape)\n",
|
| 875 |
+
"updated_catalog.nunique()"
|
| 876 |
+
]
|
| 877 |
+
},
|
| 878 |
+
{
|
| 879 |
+
"cell_type": "markdown",
|
| 880 |
+
"metadata": {},
|
| 881 |
+
"source": [
|
| 882 |
+
"Looks good, precisely as expected. Let's save this to a CSV now."
|
| 883 |
+
]
|
| 884 |
+
},
|
| 885 |
+
{
|
| 886 |
+
"cell_type": "code",
|
| 887 |
+
"execution_count": 26,
|
| 888 |
+
"metadata": {},
|
| 889 |
+
"outputs": [],
|
| 890 |
+
"source": [
|
| 891 |
+
"updated_catalog.to_csv(TOL_FILEPATH + \"catalog.csv\", index = False)"
|
| 892 |
+
]
|
| 893 |
+
},
|
| 894 |
+
{
|
| 895 |
+
"cell_type": "code",
|
| 896 |
+
"execution_count": null,
|
| 897 |
+
"metadata": {},
|
| 898 |
+
"outputs": [],
|
| 899 |
+
"source": []
|
| 900 |
+
}
|
| 901 |
+
],
|
| 902 |
+
"metadata": {
|
| 903 |
+
"jupytext": {
|
| 904 |
+
"formats": "ipynb,py:percent"
|
| 905 |
+
},
|
| 906 |
+
"kernelspec": {
|
| 907 |
+
"display_name": "tol",
|
| 908 |
+
"language": "python",
|
| 909 |
+
"name": "python3"
|
| 910 |
+
},
|
| 911 |
+
"language_info": {
|
| 912 |
+
"codemirror_mode": {
|
| 913 |
+
"name": "ipython",
|
| 914 |
+
"version": 3
|
| 915 |
+
},
|
| 916 |
+
"file_extension": ".py",
|
| 917 |
+
"mimetype": "text/x-python",
|
| 918 |
+
"name": "python",
|
| 919 |
+
"nbconvert_exporter": "python",
|
| 920 |
+
"pygments_lexer": "ipython3",
|
| 921 |
+
"version": "3.11.3"
|
| 922 |
+
}
|
| 923 |
+
},
|
| 924 |
+
"nbformat": 4,
|
| 925 |
+
"nbformat_minor": 2
|
| 926 |
+
}
|