Skip to content

Commit

Permalink
Update example notebook.
Browse files Browse the repository at this point in the history
  • Loading branch information
Emmu T committed Jul 22, 2024
1 parent c3b7e20 commit 8ec96f6
Showing 1 changed file with 20 additions and 45 deletions.
65 changes: 20 additions & 45 deletions notebooks/testing_logratio_transformations.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@
"name": "stderr",
"output_type": "stream",
"text": [
"/root/.cache/pypoetry/virtualenvs/eis-toolkit-QEzTY9B6-py3.10/lib/python3.10/site-packages/beartype/_util/hint/pep/utilpeptest.py:347: BeartypeDecorHintPep585DeprecationWarning: PEP 484 type hint typing.Sequence[str] deprecated by PEP 585. This hint is scheduled for removal in the first Python version released after October 5th, 2025. To resolve this, import this hint from \"beartype.typing\" rather than \"typing\". For further commentary and alternatives, see also:\n",
" https://beartype.readthedocs.io/en/latest/api_roar/#pep-585-deprecations\n",
" warn(\n"
"/root/.cache/pypoetry/virtualenvs/eis-toolkit-QEzTY9B6-py3.10/lib/python3.10/site-packages/geopandas/_compat.py:112: UserWarning: The Shapely GEOS version (3.10.3-CAPI-1.16.1) is incompatible with the GEOS version PyGEOS was compiled with (3.10.4-CAPI-1.16.2). Conversions between both will be slow.\n",
" warnings.warn(\n"
]
}
],
Expand Down Expand Up @@ -727,7 +726,7 @@
{
"cell_type": "code",
"execution_count": 21,
"id": "e1bda63b-ab9b-4060-90d5-7520952f2e3a",
"id": "41bfcb78-bdfa-4c03-a9b4-45c2258c60a8",
"metadata": {
"tags": []
},
Expand Down Expand Up @@ -757,7 +756,6 @@
" <th>Ca_ppm_511</th>\n",
" <th>Fe_ppm_511</th>\n",
" <th>Mg_ppm_511</th>\n",
" <th>residual</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
Expand All @@ -767,51 +765,46 @@
" <td>40200.0</td>\n",
" <td>83200.0</td>\n",
" <td>17200.0</td>\n",
" <td>831800.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>14100.0</td>\n",
" <td>5000.0</td>\n",
" <td>28300.0</td>\n",
" <td>7520.0</td>\n",
" <td>945080.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>7880.0</td>\n",
" <td>3070.0</td>\n",
" <td>14500.0</td>\n",
" <td>4540.0</td>\n",
" <td>970010.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>7300.0</td>\n",
" <td>3290.0</td>\n",
" <td>14600.0</td>\n",
" <td>3240.0</td>\n",
" <td>971570.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>12500.0</td>\n",
" <td>3600.0</td>\n",
" <td>31500.0</td>\n",
" <td>8020.0</td>\n",
" <td>944380.0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Al_ppm_511 Ca_ppm_511 Fe_ppm_511 Mg_ppm_511 residual\n",
"0 27600.0 40200.0 83200.0 17200.0 831800.0\n",
"1 14100.0 5000.0 28300.0 7520.0 945080.0\n",
"2 7880.0 3070.0 14500.0 4540.0 970010.0\n",
"3 7300.0 3290.0 14600.0 3240.0 971570.0\n",
"4 12500.0 3600.0 31500.0 8020.0 944380.0"
" Al_ppm_511 Ca_ppm_511 Fe_ppm_511 Mg_ppm_511\n",
"0 27600.0 40200.0 83200.0 17200.0\n",
"1 14100.0 5000.0 28300.0 7520.0\n",
"2 7880.0 3070.0 14500.0 4540.0\n",
"3 7300.0 3290.0 14600.0 3240.0\n",
"4 12500.0 3600.0 31500.0 8020.0"
]
},
"execution_count": 21,
Expand All @@ -825,15 +818,12 @@
"df = gpd.read_file(GEOCHEMICAL_DATA, include_fields=elements_to_analyze)\n",
"df = pd.DataFrame(df.drop(columns='geometry'))\n",
"\n",
"# Add a column for the residual\n",
"\n",
"df[\"residual\"] = million - np.sum(df, axis=1)\n",
"df.head()"
]
},
{
"cell_type": "code",
"execution_count": 24,
"execution_count": 22,
"id": "75728aa4-5b2e-46b6-9511-1250bf4b13ae",
"metadata": {
"tags": []
Expand All @@ -843,7 +833,6 @@
"pair_Al_Ca = pairwise_logratio(df, \"Al_ppm_511\", \"Ca_ppm_511\")\n",
"pair_Fe_Mg = pairwise_logratio(df, \"Fe_ppm_511\", \"Mg_ppm_511\")\n",
"pair_Mg_Al = pairwise_logratio(df, \"Mg_ppm_511\", \"Al_ppm_511\")\n",
"pair_Mg_res = pairwise_logratio(df, \"Mg_ppm_511\", \"residual\")\n",
"\n",
"df_alr = alr_transform(df)\n",
"df_alr_Mg = alr_transform(df, \"Mg_ppm_511\")\n",
Expand All @@ -859,7 +848,7 @@
},
{
"cell_type": "code",
"execution_count": 25,
"execution_count": 23,
"id": "e136d05d-671d-420f-95b9-5f350bc7a94c",
"metadata": {
"tags": []
Expand All @@ -876,7 +865,7 @@
"dtype: float64"
]
},
"execution_count": 25,
"execution_count": 23,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -887,7 +876,7 @@
},
{
"cell_type": "code",
"execution_count": 26,
"execution_count": 24,
"id": "ad352680-433a-4026-b7b5-560b682dfb96",
"metadata": {
"tags": []
Expand Down Expand Up @@ -917,7 +906,6 @@
" <th>V1</th>\n",
" <th>V2</th>\n",
" <th>V3</th>\n",
" <th>V4</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
Expand All @@ -926,65 +914,52 @@
" <td>0.472906</td>\n",
" <td>0.848958</td>\n",
" <td>1.576338</td>\n",
" <td>3.878683</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>0.628609</td>\n",
" <td>-0.408128</td>\n",
" <td>1.325296</td>\n",
" <td>4.833703</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>0.551401</td>\n",
" <td>-0.391249</td>\n",
" <td>1.161222</td>\n",
" <td>5.364379</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>0.812301</td>\n",
" <td>0.015314</td>\n",
" <td>1.505448</td>\n",
" <td>5.703340</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>0.443790</td>\n",
" <td>-0.801005</td>\n",
" <td>1.368049</td>\n",
" <td>4.768590</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" V1 V2 V3 V4\n",
"0 0.472906 0.848958 1.576338 3.878683\n",
"1 0.628609 -0.408128 1.325296 4.833703\n",
"2 0.551401 -0.391249 1.161222 5.364379\n",
"3 0.812301 0.015314 1.505448 5.703340\n",
"4 0.443790 -0.801005 1.368049 4.768590"
" V1 V2 V3\n",
"0 0.472906 0.848958 1.576338\n",
"1 0.628609 -0.408128 1.325296\n",
"2 0.551401 -0.391249 1.161222\n",
"3 0.812301 0.015314 1.505448\n",
"4 0.443790 -0.801005 1.368049"
]
},
"execution_count": 26,
"execution_count": 24,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df_alr_Mg.head()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "8b6a1929-51ef-4b7a-8621-f46bbe337e31",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down

0 comments on commit 8ec96f6

Please sign in to comment.