[{"content":"I am a graduate student at the University of California, Davis in the geodynamics lab. Currently, I am working on improving slab shape models of the Cascadia subduction zone by linking predictions of the mantle flow around the slab from geodynamic models to seismic observations.\nI am interested in marine and volcano geophysics, seismology (especially seismic imaging and tomography), machine/deep learning, and any opportunity to be in the field→.\n","date":"16 April 2026","externalUrl":null,"permalink":"/","section":"","summary":"","title":"","type":"page"},{"content":"","date":"16 April 2026","externalUrl":null,"permalink":"/authors/","section":"Authors","summary":"","title":"Authors","type":"authors"},{"content":"","date":"16 April 2026","externalUrl":null,"permalink":"/conferences/","section":"Conferences","summary":"","title":"Conferences","type":"publication"},{"content":"","date":"16 April 2026","externalUrl":null,"permalink":"/authors/magali-i.-billen/","section":"Authors","summary":"","title":"Magali I. Billen","type":"authors"},{"content":"","date":"16 April 2026","externalUrl":null,"permalink":"/authors/manuele-faccenda/","section":"Authors","summary":"","title":"Manuele Faccenda","type":"authors"},{"content":"","date":"16 April 2026","externalUrl":null,"permalink":"/authors/menno-fraters/","section":"Authors","summary":"","title":"Menno Fraters","type":"authors"},{"content":"","date":"16 April 2026","externalUrl":null,"permalink":"/authors/nathalie-r.-redick/","section":"Authors","summary":"","title":"Nathalie R. Redick","type":"authors"},{"content":" Abstract # The Cascadia Subduction Zone (CSZ) poses significant hazards to the Pacific Northwest U.S. and Canada. Mantle flow patterns around the slab and stress transmitted to the shallow megathrust are governed by the 3D slab geometry. However, existing studies disagree on many aspects of Cascadia slab geometry, including the presence of a large gap in the Gorda segment beneath Oregon, the slab\u0026rsquo;s depth extent, and the location of the northern boundary of the Explorer segment. This disagreement is due to the low rate of background seismicity relative to other subduction zones, which makes it difficult to construct seismic tomography images of the slab geometry. While seismic images of the slab are poorly constrained, it may be possible to constrain aspects of slab geometry by linking predictions of mantle flow and seismic anisotropy from geodynamic models to observations of shear wave splitting (SWS). Here we aim to compare predicted anisotropy from existing 3D geodynamic models of various CSZ slab geometries with observed SWS in Cascadia. Our approach leverages the ECOMAN software, which uses a modified D-REX method to calculate lattice-preferred orientation due to shear deformation, and the SKS-SPLIT package to model synthetic SKS splitting at the surface to predict seismic anisotropy. We anticipate that our results will help refine future slab models by providing a new constraint on slab geometry and flow in Cascadia. On a global scale, our proposed methods could improve understanding of mantle flow and upper mantle structure in other regions with complex flow and subduction-related hazards.\nPlain-language Summary # Segments of oceanic plates are being driven beneath the North American plate of the Pacific Northwest U.S. and Canada in the Cascadia Subduction Zone (CSZ). The most destructive earthquakes occur along this interface where the down-going and overlying plate meet. The pattern of mantle flow around the slab and the stress transmitted to the interface are controlled by the shape of the down-going slab, which is poorly constrained in the CSZ. It may be possible to improve slab shape models by linking predictions of the mantle flow around the slab from geodynamic models to seismic observations. We will use a computer software to generate synthetic seismic observations as if the earthquake waves had passed through each proposed model. Therefore, we can make direct comparisons between what we observe in the CSZ and what we would expect to see for a given model of the slab shape to determine the best match. We anticipate that our results will help improve future slab models by providing a new constraint on slab shape and mantle flow in Cascadia. On a global scale, our proposed methods could improve understanding of mantle flow and mantle structure in other regions at risk for subduction-related hazards.\nReferences # Faccenda, M., \u0026amp; Capitanio, F. A. (2013). Seismic anisotropy around subduction zones: Insights from three-dimensional modeling of upper mantle deformation and SKS splitting calculations. Geochemistry, Geophysics, Geosystems, 14(1), 243–262. https://doi.org/10.1002/ggge.20055\nFaccenda, M., \u0026amp; VanderBeek, B. P. (2023). On constraining 3D seismic anisotropy in subduction, mid-ocean-ridge, and plume environments with teleseismic body wave data. Journal of Geodynamics, 158, 102003. https://doi.org/10.1016/j.jog.2023.102003\nFaccenda, M., VanderBeek, B. P., de Montserrat, A., Yang, J., Rappisi, F., \u0026amp; Ribe, N. (2024). ECOMAN: An open-source package for geodynamic and seismological modelling of mechanical anisotropy. Solid Earth, 15(10), 1241–1264. https://doi.org/10.5194/se-15-1241-2024\nFraters, M., Billen, M., Naliboff, J., Staisch, L., Watt, J., \u0026amp; Li, H. (2025). Using Subducting Plate Motion to Constrain Cascadia Slab Geometry and Interface Strength. Geochemistry, Geophysics, Geosystems, 26(5), e2024GC011895. https://doi.org/10.1029/2024GC011895\nRoy, P. (2024). Modeling of Lower Mantle Anisotropy Due to Plume Generation from Large Low-Shear-Velocity Provinces. https://doi.org/10.5281/ZENODO.13241048\nVanderBeek, B. P., Bue, R. L., Rappisi, F., \u0026amp; Faccenda, M. (2023). Imaging upper mantle anisotropy with traveltime and splitting intensity observations from teleseismic shear waves: Insights from tomographic reconstructions of subduction simulations. Geophysical Journal International, 235(3), 2640–2670. https://doi.org/10.1093/gji/ggad389\n","date":"16 April 2026","externalUrl":null,"permalink":"/conferences/sz4d-2026/","section":"Conferences","summary":"","title":"Understanding Seismic Anisotropy Observations in the Context of 3D Slab-Induced Flow in the Cascadia Subduction Zone","type":"publication"},{"content":" Abstract # The Cascadia Subduction Zone (CSZ) poses significant hazards to the Pacific Northwest U.S. and Canada. Mantle flow patterns around the slab and stress transmitted to the shallow megathrust are governed by the 3D slab geometry. However, existing studies disagree on many aspects of Cascadia slab geometry, including the presence of a large gap in the Gorda segment beneath Oregon, the slab\u0026rsquo;s depth extent, and the location of the northern boundary of the Explorer segment. This disagreement is due to the low rate of background seismicity relative to other subduction zones, which makes it difficult to construct seismic tomographic imagery of the slab geometry. While seismic images of the slab are poorly constrained, it may be possible to constrain aspects of slab geometry by linking predictions of mantle flow and seismic anisotropy from geodynamic models to observations of shear wave splitting. Here we aim to compare predicted anisotropy and tomography from existing 3D geodynamic models of various CSZ slab geometries with SWS observations and seismic tomography models of Cascadia. Our approach leverages the ECOMAN software, which uses a modified D-REX method to calculate lattice-preferred orientation due to shear deformation, the SKS-SPLIT package to model synthetic SKS splitting at the surface, and the PSI-D package to forward-model synthetic seismic observables, to predict seismic anisotropy, and to predict isotropic and anisotropic seismic tomography. We anticipate that our results will help refine future slab models by providing a new constraint on slab geometry and flow in Cascadia. On a global scale, our proposed methods could improve understanding of mantle flow and upper mantle structure in other regions with complex flow and subduction-related hazards.\nPlain-language Summary # Segments of oceanic plates are being driven beneath the North American plate of the Pacific Northwest U.S. and Canada in the Cascadia Subduction Zone (CSZ). The most destructive earthquakes occur along this interface where the down-going and overlying plate meet. The pattern of mantle flow around the slab and the stress transmitted to the interface are controlled by the shape of the down-going slab, which is poorly constrained in the CSZ. It may be possible to improve slab shape models by linking predictions of the mantle flow around the slab from geodynamic models to seismic observations. We will use a computer software to generate synthetic seismic observations as if the earthquake waves had passed through each proposed model. Therefore, we can make direct comparisons between what we observe in the CSZ and what we would expect to see for a given model of the slab shape to determine the best match. We anticipate that our results will help improve future slab models by providing a new constraint on slab shape and mantle flow in Cascadia. On a global scale, our proposed methods could improve understanding of mantle flow and mantle structure in other regions at risk for subduction-related hazards.\nReferences # Faccenda, M., \u0026amp; Capitanio, F. A. (2013). Seismic anisotropy around subduction zones: Insights from three-dimensional modeling of upper mantle deformation and SKS splitting calculations. Geochemistry, Geophysics, Geosystems, 14(1), 243–262. https://doi.org/10.1002/ggge.20055\nFaccenda, M., \u0026amp; VanderBeek, B. P. (2023). On constraining 3D seismic anisotropy in subduction, mid-ocean-ridge, and plume environments with teleseismic body wave data. Journal of Geodynamics, 158, 102003. https://doi.org/10.1016/j.jog.2023.102003\nFaccenda, M., VanderBeek, B. P., de Montserrat, A., Yang, J., Rappisi, F., \u0026amp; Ribe, N. (2024). ECOMAN: An open-source package for geodynamic and seismological modelling of mechanical anisotropy. Solid Earth, 15(10), 1241–1264. https://doi.org/10.5194/se-15-1241-2024\nFraters, M., Billen, M., Naliboff, J., Staisch, L., Watt, J., \u0026amp; Li, H. (2025). Using Subducting Plate Motion to Constrain Cascadia Slab Geometry and Interface Strength. Geochemistry, Geophysics, Geosystems, 26(5), e2024GC011895. https://doi.org/10.1029/2024GC011895\nRoy, P. (2024). Modeling of Lower Mantle Anisotropy Due to Plume Generation from Large Low-Shear-Velocity Provinces. https://doi.org/10.5281/ZENODO.13241048\nVanderBeek, B. P., Bue, R. L., Rappisi, F., \u0026amp; Faccenda, M. (2023). Imaging upper mantle anisotropy with traveltime and splitting intensity observations from teleseismic shear waves: Insights from tomographic reconstructions of subduction simulations. Geophysical Journal International, 235(3), 2640–2670. https://doi.org/10.1093/gji/ggad389\n","date":"19 December 2025","externalUrl":null,"permalink":"/conferences/agu25/","section":"Conferences","summary":"","title":"Understanding Seismic Anisotropy Observations in the Context of 3D Slab-Induced Flow in the Cascadia Subduction Zone","type":"publication"},{"content":"","date":"3 September 2025","externalUrl":null,"permalink":"/code/","section":"Code","summary":"","title":"Code","type":"code"},{"content":"","date":"3 September 2025","externalUrl":null,"permalink":"/docs/","section":"Docs","summary":"","title":"Docs","type":"docs"},{"content":" import pandas as pd import geopandas as gpd import plotly.express as px import seaborn as sns import matplotlib.pyplot as plt from sklearn.ensemble import GradientBoostingClassifier from sklearn.pipeline import Pipeline from sklearn.preprocessing import OneHotEncoder, StandardScaler, LabelEncoder from sklearn.compose import ColumnTransformer from sklearn.model_selection import train_test_split from sklearn.metrics import accuracy_score, log_loss, confusion_matrix Data Preprocessing # Data cleaning Data transformation Feature selection Data normalization/standardization \u0026amp; encoding Train/test split Download volcano data from GVP # Holocene \u0026amp; Pleistocene volcanoes from the Smithsonian Global Volcanism Program (GVP) databases.\nhttps://volcano.si.edu/database/webservices.cfm\n# request data from Smithsonian database server = \u0026#39;https://webservices.volcano.si.edu/geoserver/GVP-VOTW/ows?\u0026#39; queries = { \u0026#39;holocene\u0026#39;: \u0026#39;service=WFS\u0026amp;request=GetFeature\u0026amp;typeName=GVP-VOTW:Smithsonian_VOTW_Holocene_Volcanoes\u0026amp;outputFormat=json\u0026#39;, \u0026#39;pleistocene\u0026#39;: \u0026#39;service=WFS\u0026amp;request=GetFeature\u0026amp;typeName=GVP-VOTW:Smithsonian_VOTW_Pleistocene_Volcanoes\u0026amp;outputFormat=json\u0026#39; } # download data using geopandas holocene_volcanoes = gpd.read_file(server + queries[\u0026#39;holocene\u0026#39;]) pleistocene_volcanoes = gpd.read_file(server + queries[\u0026#39;pleistocene\u0026#39;]) # combine the two dataframes volcanoes = gpd.GeoDataFrame(pd.concat([holocene_volcanoes, pleistocene_volcanoes], ignore_index=True)) Data cleaning \u0026amp; transformation # # print the counts of the major rock types volcanoes[\u0026#39;Major_Rock_Type\u0026#39;].value_counts() volcanoes id Volcano_Number Volcano_Name Volcanic_Landform Primary_Volcano_Type Last_Eruption_Year Country Region Subregion Geological_Summary ... Longitude Elevation Tectonic_Setting Geologic_Epoch Evidence_Category Primary_Photo_Link Primary_Photo_Caption Primary_Photo_Credit Major_Rock_Type geometry 0 Smithsonian_VOTW_Holocene_Volcanoes.fid--71e2f... 210010 West Eifel Volcanic Field Cluster Volcanic field -8300.0 Germany European Volcanic Regions Central European Volcanic Province The West Eifel Volcanic Field of western Germa... ... 6.8500 600.0 Rift zone / Continental crust (\u0026gt; 25 km) Holocene Eruption Dated https://volcano.si.edu/gallery/photos/GVP-0150... The lake-filled Weinfelder maar is one of abou... Photo by Richard Waitt, 1990 (U.S. Geological ... Foidite POINT (6.85 50.17) 1 Smithsonian_VOTW_Holocene_Volcanoes.fid--71e2f... 210020 Chaine des Puys Cluster Lava dome(s) -4040.0 France European Volcanic Regions Western European Volcanic Province The Chaîne des Puys, prominent in the history ... ... 2.9810 1464.0 Rift zone / Continental crust (\u0026gt; 25 km) Holocene Eruption Dated https://volcano.si.edu/gallery/photos/GVP-0880... The central part of the Chaîne des Puys volcan... Photo by Ichio Moriya (Kanazawa University). Basalt / Picro-Basalt POINT (2.981 45.786) 2 Smithsonian_VOTW_Holocene_Volcanoes.fid--71e2f... 210030 Olot Volcanic Field Cluster Volcanic field NaN Spain European Volcanic Regions Western European Volcanic Province The Olot volcanic field (also known as the Gar... ... 2.5300 893.0 Intraplate / Continental crust (\u0026gt; 25 km) Holocene Evidence Credible https://volcano.si.edu/gallery/photos/GVP-1199... The forested Volcà Montolivet scoria cone rise... Photo by Puigalder (Wikimedia Commons). Trachybasalt / Tephrite Basanite POINT (2.53 42.17) 3 Smithsonian_VOTW_Holocene_Volcanoes.fid--71e2f... 210040 Calatrava Volcanic Field Cluster Volcanic field -3600.0 Spain European Volcanic Regions Western European Volcanic Province The Calatrava volcanic field lies in central S... ... -4.0200 1117.0 Intraplate / Continental crust (\u0026gt; 25 km) Holocene Eruption Dated https://volcano.si.edu/gallery/photos/GVP-1185... Columba volcano, the youngest known vent of th... Photo by Rafael Becerra Ramírez, 2006 (Univers... Basalt / Picro-Basalt POINT (-4.02 38.87) 4 Smithsonian_VOTW_Holocene_Volcanoes.fid--71e2f... 211004 Colli Albani Caldera Caldera NaN Italy European Volcanic Regions Italian Peninsula Volcanic Provinces The Colli Albani (Alban Hills) complex immedia... ... 12.7251 949.0 Subduction zone / Continental crust (\u0026gt; 25 km) Holocene Evidence Uncertain https://volcano.si.edu/gallery/photos/GVP-0881... The lake-filled Albano maar is part of the Alb... Photo by Ichio Moriya (Kanazawa University). Foidite POINT (12.7251 41.7569) ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... 2655 Smithsonian_VOTW_Pleistocene_Volcanoes.fid--71... 274080 Y'Ami-North Composite Compound NaN Philippines Western Pacific Volcanic Regions Taiwan-Luzon Volcanic Arc Submarine volcanic edifice with the islands of... ... 121.9420 213.0 NaN Pleistocene NaN NaN NaN NaN NaN POINT (121.942 21.0868) 2656 Smithsonian_VOTW_Pleistocene_Volcanoes.fid--71... 274085 Hsiaolanyu Composite Compound NaN Taiwan Western Pacific Volcanic Regions Taiwan-Luzon Volcanic Arc None ... 121.6123 148.0 NaN Pleistocene NaN NaN NaN NaN NaN POINT (121.6123 21.9529) 2657 Smithsonian_VOTW_Pleistocene_Volcanoes.fid--71... 274090 Lutao Composite Compound NaN Taiwan Western Pacific Volcanic Regions Taiwan-Luzon Volcanic Arc None ... 121.4927 268.0 NaN Pleistocene NaN NaN NaN NaN NaN POINT (121.4927 22.658) 2658 Smithsonian_VOTW_Pleistocene_Volcanoes.fid--71... 315055 Addington Volcanic Field Cluster Volcanic field NaN United States North America Volcanic Regions Queen Charlotte Volcano Group The submarine Addington Volcanic Field is abou... ... -134.1700 -74.0 NaN Pleistocene NaN NaN NaN NaN NaN POINT (-134.17 55.44) 2659 Smithsonian_VOTW_Pleistocene_Volcanoes.fid--71... 315100 Maclaren River Volcanic Field Minor Volcanic field NaN United States North America Volcanic Regions Northern Cordilleran Volcanic Province As described by the Alaska Volcano Observatory... ... -146.3200 1470.0 NaN Pleistocene NaN NaN NaN NaN NaN POINT (-146.32 63.1369) 2660 rows × 21 columns\nFeature selection # # filter for only andesite, basalt volcanoes = volcanoes[volcanoes[\u0026#39;Major_Rock_Type\u0026#39;].isin([\u0026#39;Andesite / Basaltic Andesite\u0026#39;, \u0026#39;Basalt / Picro-Basalt\u0026#39;])] # select just the feature cols of interest volcanoes = volcanoes[[\u0026#39;Major_Rock_Type\u0026#39;, \u0026#39;Tectonic_Setting\u0026#39;, \u0026#39;Primary_Volcano_Type\u0026#39;, \u0026#39;Latitude\u0026#39;, \u0026#39;Longitude\u0026#39;, \u0026#39;Volcanic_Landform\u0026#39;]] # drop any that have missing data in the rows volcanoes.dropna(inplace=True) # view dataframe volcanoes Major_Rock_Type Tectonic_Setting Primary_Volcano_Type Latitude Longitude Volcanic_Landform 1 Basalt / Picro-Basalt Rift zone / Continental crust (\u0026gt; 25 km) Lava dome(s) 45.7860 2.9810 Cluster 3 Basalt / Picro-Basalt Intraplate / Continental crust (\u0026gt; 25 km) Volcanic field 38.8700 -4.0200 Cluster 9 Andesite / Basaltic Andesite Subduction zone / Continental crust (\u0026gt; 25 km) Stratovolcano 38.6380 15.0640 Composite 16 Andesite / Basaltic Andesite Subduction zone / Continental crust (\u0026gt; 25 km) Lava dome(s) 37.6186 23.3331 Minor (Basaltic) 22 Basalt / Picro-Basalt Intraplate / Continental crust (\u0026gt; 25 km) Shield 37.6700 39.8300 Shield ... ... ... ... ... ... ... 1252 Basalt / Picro-Basalt Subduction zone / Oceanic crust (\u0026lt; 15 km) Stratovolcano -56.7120 -27.1760 Composite 1253 Andesite / Basaltic Andesite Subduction zone / Oceanic crust (\u0026lt; 15 km) Stratovolcano -56.6560 -28.1400 Composite 1254 Basalt / Picro-Basalt Subduction zone / Oceanic crust (\u0026lt; 15 km) Stratovolcano -56.3000 -27.5700 Composite 1257 Basalt / Picro-Basalt Intraplate / Continental crust (\u0026gt; 25 km) Shield -64.1500 -57.7500 Shield 1268 Basalt / Picro-Basalt Subduction zone / Continental crust (\u0026gt; 25 km) Volcanic field -45.2200 -73.0500 Cluster 933 rows × 6 columns\nData visualization # # plot volcanoes on map with plotly fig = px.scatter_geo(volcanoes, lat=\u0026#39;Latitude\u0026#39;, lon=\u0026#39;Longitude\u0026#39;, hover_name=\u0026#39;Major_Rock_Type\u0026#39;, color=\u0026#39;Major_Rock_Type\u0026#39;) fig.update_geos(projection_type=\u0026#39;natural earth\u0026#39;) fig.update_layout(title=\u0026#39;Pleistocene \u0026amp; Holocene Volcanoes by Rock Type\u0026#39;) fig.show() Data normalization/standardization \u0026amp; encoding # # Preprocess the features and encode the target preprocessor = ColumnTransformer( transformers=[ (\u0026#39;num\u0026#39;, StandardScaler(), [\u0026#39;Latitude\u0026#39;, \u0026#39;Longitude\u0026#39;]), (\u0026#39;cat\u0026#39;, OneHotEncoder(handle_unknown=\u0026#39;ignore\u0026#39;), [\u0026#39;Tectonic_Setting\u0026#39;, \u0026#39;Volcanic_Landform\u0026#39;, \u0026#39;Primary_Volcano_Type\u0026#39;]) ]) # separate features (X) and target (y) X = volcanoes[[\u0026#39;Latitude\u0026#39;, \u0026#39;Longitude\u0026#39;, \u0026#39;Tectonic_Setting\u0026#39;, \u0026#39;Volcanic_Landform\u0026#39;, \u0026#39;Primary_Volcano_Type\u0026#39;]] y = volcanoes[\u0026#39;Major_Rock_Type\u0026#39;] # encode the target variable (Major_Rock_Type) label_encoder = LabelEncoder() y_encoded = label_encoder.fit_transform(y) Train/test split # # use 20% of the data for testing, shuffle to reduce bias X_train, X_test, y_train, y_test = train_test_split(X, y_encoded, test_size=0.2, shuffle=True) Model selection # preprocessor: A preprocessing step to transform the data before classification. classifier: A Gradient Boosting classifier with the following hyperparameters: n_estimators: The number of boosting stages to be run (default=100). verbose: Controls the verbosity of the output (default=1). validation_fraction: The proportion of training data to set aside as validation set for early stopping (default=0.15). learning_rate: The learning rate shrinks the contribution of each tree by learning_rate (default=0.075). min_impurity_decrease: A node will be split if this split induces a decrease of the impurity greater than or equal to this value (default=0.01). max_depth: The maximum depth of the individual regression estimators (default=3). # create a pipeline with preprocessor and classifier model = Pipeline(steps=[ (\u0026#39;preprocessor\u0026#39;, preprocessor), (\u0026#39;classifier\u0026#39;, GradientBoostingClassifier(n_estimators=100, verbose=1, validation_fraction=0.15, learning_rate=0.075, min_impurity_decrease=0.01, max_depth=3)) ]) Model training # # fit the model model.fit(X_train, y_train) Iter Train Loss Remaining Time 1 1.3147 0.13s 2 1.2710 0.11s 3 1.2332 0.10s 4 1.2006 0.09s 5 1.1719 0.08s 6 1.1471 0.08s 7 1.1225 0.08s 8 1.1028 0.08s 9 1.0833 0.07s 10 1.0657 0.07s 20 0.9339 0.07s 30 0.8741 0.06s 40 0.8296 0.05s 50 0.8015 0.04s 60 0.7746 0.03s 70 0.7547 0.02s 80 0.7262 0.02s 90 0.7085 0.01s 100 0.6926 0.00s Pipeline(steps=[(\u0026#x27;preprocessor\u0026#x27;, ColumnTransformer(transformers=[(\u0026amp;#x27;num\u0026amp;#x27;, StandardScaler(), [\u0026amp;#x27;Latitude\u0026amp;#x27;, \u0026amp;#x27;Longitude\u0026amp;#x27;]), (\u0026amp;#x27;cat\u0026amp;#x27;, OneHotEncoder(handle_unknown=\u0026amp;#x27;ignore\u0026amp;#x27;), [\u0026amp;#x27;Tectonic_Setting\u0026amp;#x27;, \u0026amp;#x27;Volcanic_Landform\u0026amp;#x27;, \u0026amp;#x27;Primary_Volcano_Type\u0026amp;#x27;])])), (\u0026amp;#x27;classifier\u0026amp;#x27;, GradientBoostingClassifier(learning_rate=0.075, min_impurity_decrease=0.01, validation_fraction=0.15, verbose=1))])\u0026lt;/pre\u0026gt;\u0026lt;b\u0026gt;In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook. \u0026lt;br /\u0026gt;On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.\u0026lt;/b\u0026gt;\u0026lt;/div\u0026gt;\u0026lt;div class=\u0026quot;sk-container\u0026quot; hidden\u0026gt;\u0026lt;div class=\u0026quot;sk-item sk-dashed-wrapped\u0026quot;\u0026gt;\u0026lt;div class=\u0026quot;sk-label-container\u0026quot;\u0026gt;\u0026lt;div class=\u0026quot;sk-label fitted sk-toggleable\u0026quot;\u0026gt;\u0026lt;input class=\u0026quot;sk-toggleable__control sk-hidden--visually\u0026quot; id=\u0026quot;sk-estimator-id-43\u0026quot; type=\u0026quot;checkbox\u0026quot; \u0026gt;\u0026lt;label for=\u0026quot;sk-estimator-id-43\u0026quot; class=\u0026quot;sk-toggleable__label fitted sk-toggleable__label-arrow\u0026quot;\u0026gt;\u0026lt;div\u0026gt;\u0026lt;div\u0026gt;Pipeline\u0026lt;/div\u0026gt;\u0026lt;/div\u0026gt;\u0026lt;div\u0026gt;\u0026lt;a class=\u0026quot;sk-estimator-doc-link fitted\u0026quot; rel=\u0026quot;noreferrer\u0026quot; target=\u0026quot;_blank\u0026quot; href=\u0026quot;https://scikit-learn.org/1.6/modules/generated/sklearn.pipeline.Pipeline.html\u0026quot;\u0026gt;?\u0026lt;span\u0026gt;Documentation for Pipeline\u0026lt;/span\u0026gt;\u0026lt;/a\u0026gt;\u0026lt;span class=\u0026quot;sk-estimator-doc-link fitted\u0026quot;\u0026gt;i\u0026lt;span\u0026gt;Fitted\u0026lt;/span\u0026gt;\u0026lt;/span\u0026gt;\u0026lt;/div\u0026gt;\u0026lt;/label\u0026gt;\u0026lt;div class=\u0026quot;sk-toggleable__content fitted\u0026quot;\u0026gt;\u0026lt;pre\u0026gt;Pipeline(steps=[(\u0026amp;#x27;preprocessor\u0026amp;#x27;, ColumnTransformer(transformers=[(\u0026amp;#x27;num\u0026amp;#x27;, StandardScaler(), [\u0026amp;#x27;Latitude\u0026amp;#x27;, \u0026amp;#x27;Longitude\u0026amp;#x27;]), (\u0026amp;#x27;cat\u0026amp;#x27;, OneHotEncoder(handle_unknown=\u0026amp;#x27;ignore\u0026amp;#x27;), [\u0026amp;#x27;Tectonic_Setting\u0026amp;#x27;, \u0026amp;#x27;Volcanic_Landform\u0026amp;#x27;, \u0026amp;#x27;Primary_Volcano_Type\u0026amp;#x27;])])), (\u0026amp;#x27;classifier\u0026amp;#x27;, GradientBoostingClassifier(learning_rate=0.075, min_impurity_decrease=0.01, validation_fraction=0.15, verbose=1))])\u0026lt;/pre\u0026gt;\u0026lt;/div\u0026gt; \u0026lt;/div\u0026gt;\u0026lt;/div\u0026gt;\u0026lt;div class=\u0026quot;sk-serial\u0026quot;\u0026gt;\u0026lt;div class=\u0026quot;sk-item sk-dashed-wrapped\u0026quot;\u0026gt;\u0026lt;div class=\u0026quot;sk-label-container\u0026quot;\u0026gt;\u0026lt;div class=\u0026quot;sk-label fitted sk-toggleable\u0026quot;\u0026gt;\u0026lt;input class=\u0026quot;sk-toggleable__control sk-hidden--visually\u0026quot; id=\u0026quot;sk-estimator-id-44\u0026quot; type=\u0026quot;checkbox\u0026quot; \u0026gt;\u0026lt;label for=\u0026quot;sk-estimator-id-44\u0026quot; class=\u0026quot;sk-toggleable__label fitted sk-toggleable__label-arrow\u0026quot;\u0026gt;\u0026lt;div\u0026gt;\u0026lt;div\u0026gt;preprocessor: ColumnTransformer\u0026lt;/div\u0026gt;\u0026lt;/div\u0026gt;\u0026lt;div\u0026gt;\u0026lt;a class=\u0026quot;sk-estimator-doc-link fitted\u0026quot; rel=\u0026quot;noreferrer\u0026quot; target=\u0026quot;_blank\u0026quot; href=\u0026quot;https://scikit-learn.org/1.6/modules/generated/sklearn.compose.ColumnTransformer.html\u0026quot;\u0026gt;?\u0026lt;span\u0026gt;Documentation for preprocessor: ColumnTransformer\u0026lt;/span\u0026gt;\u0026lt;/a\u0026gt;\u0026lt;/div\u0026gt;\u0026lt;/label\u0026gt;\u0026lt;div class=\u0026quot;sk-toggleable__content fitted\u0026quot;\u0026gt;\u0026lt;pre\u0026gt;ColumnTransformer(transformers=[(\u0026amp;#x27;num\u0026amp;#x27;, StandardScaler(), [\u0026amp;#x27;Latitude\u0026amp;#x27;, \u0026amp;#x27;Longitude\u0026amp;#x27;]), (\u0026amp;#x27;cat\u0026amp;#x27;, OneHotEncoder(handle_unknown=\u0026amp;#x27;ignore\u0026amp;#x27;), [\u0026amp;#x27;Tectonic_Setting\u0026amp;#x27;, \u0026amp;#x27;Volcanic_Landform\u0026amp;#x27;, \u0026amp;#x27;Primary_Volcano_Type\u0026amp;#x27;])])\u0026lt;/pre\u0026gt;\u0026lt;/div\u0026gt; \u0026lt;/div\u0026gt;\u0026lt;/div\u0026gt;\u0026lt;div class=\u0026quot;sk-parallel\u0026quot;\u0026gt;\u0026lt;div class=\u0026quot;sk-parallel-item\u0026quot;\u0026gt;\u0026lt;div class=\u0026quot;sk-item\u0026quot;\u0026gt;\u0026lt;div class=\u0026quot;sk-label-container\u0026quot;\u0026gt;\u0026lt;div class=\u0026quot;sk-label fitted sk-toggleable\u0026quot;\u0026gt;\u0026lt;input class=\u0026quot;sk-toggleable__control sk-hidden--visually\u0026quot; id=\u0026quot;sk-estimator-id-45\u0026quot; type=\u0026quot;checkbox\u0026quot; \u0026gt;\u0026lt;label for=\u0026quot;sk-estimator-id-45\u0026quot; class=\u0026quot;sk-toggleable__label fitted sk-toggleable__label-arrow\u0026quot;\u0026gt;\u0026lt;div\u0026gt;\u0026lt;div\u0026gt;num\u0026lt;/div\u0026gt;\u0026lt;/div\u0026gt;\u0026lt;/label\u0026gt;\u0026lt;div class=\u0026quot;sk-toggleable__content fitted\u0026quot;\u0026gt;\u0026lt;pre\u0026gt;[\u0026amp;#x27;Latitude\u0026amp;#x27;, \u0026amp;#x27;Longitude\u0026amp;#x27;]\u0026lt;/pre\u0026gt;\u0026lt;/div\u0026gt; \u0026lt;/div\u0026gt;\u0026lt;/div\u0026gt;\u0026lt;div class=\u0026quot;sk-serial\u0026quot;\u0026gt;\u0026lt;div class=\u0026quot;sk-item\u0026quot;\u0026gt;\u0026lt;div class=\u0026quot;sk-estimator fitted sk-toggleable\u0026quot;\u0026gt;\u0026lt;input class=\u0026quot;sk-toggleable__control sk-hidden--visually\u0026quot; id=\u0026quot;sk-estimator-id-46\u0026quot; type=\u0026quot;checkbox\u0026quot; \u0026gt;\u0026lt;label for=\u0026quot;sk-estimator-id-46\u0026quot; class=\u0026quot;sk-toggleable__label fitted sk-toggleable__label-arrow\u0026quot;\u0026gt;\u0026lt;div\u0026gt;\u0026lt;div\u0026gt;StandardScaler\u0026lt;/div\u0026gt;\u0026lt;/div\u0026gt;\u0026lt;div\u0026gt;\u0026lt;a class=\u0026quot;sk-estimator-doc-link fitted\u0026quot; rel=\u0026quot;noreferrer\u0026quot; target=\u0026quot;_blank\u0026quot; href=\u0026quot;https://scikit-learn.org/1.6/modules/generated/sklearn.preprocessing.StandardScaler.html\u0026quot;\u0026gt;?\u0026lt;span\u0026gt;Documentation for StandardScaler\u0026lt;/span\u0026gt;\u0026lt;/a\u0026gt;\u0026lt;/div\u0026gt;\u0026lt;/label\u0026gt;\u0026lt;div class=\u0026quot;sk-toggleable__content fitted\u0026quot;\u0026gt;\u0026lt;pre\u0026gt;StandardScaler()\u0026lt;/pre\u0026gt;\u0026lt;/div\u0026gt; \u0026lt;/div\u0026gt;\u0026lt;/div\u0026gt;\u0026lt;/div\u0026gt;\u0026lt;/div\u0026gt;\u0026lt;/div\u0026gt;\u0026lt;div class=\u0026quot;sk-parallel-item\u0026quot;\u0026gt;\u0026lt;div class=\u0026quot;sk-item\u0026quot;\u0026gt;\u0026lt;div class=\u0026quot;sk-label-container\u0026quot;\u0026gt;\u0026lt;div class=\u0026quot;sk-label fitted sk-toggleable\u0026quot;\u0026gt;\u0026lt;input class=\u0026quot;sk-toggleable__control sk-hidden--visually\u0026quot; id=\u0026quot;sk-estimator-id-47\u0026quot; type=\u0026quot;checkbox\u0026quot; \u0026gt;\u0026lt;label for=\u0026quot;sk-estimator-id-47\u0026quot; class=\u0026quot;sk-toggleable__label fitted sk-toggleable__label-arrow\u0026quot;\u0026gt;\u0026lt;div\u0026gt;\u0026lt;div\u0026gt;cat\u0026lt;/div\u0026gt;\u0026lt;/div\u0026gt;\u0026lt;/label\u0026gt;\u0026lt;div class=\u0026quot;sk-toggleable__content fitted\u0026quot;\u0026gt;\u0026lt;pre\u0026gt;[\u0026amp;#x27;Tectonic_Setting\u0026amp;#x27;, \u0026amp;#x27;Volcanic_Landform\u0026amp;#x27;, \u0026amp;#x27;Primary_Volcano_Type\u0026amp;#x27;]\u0026lt;/pre\u0026gt;\u0026lt;/div\u0026gt; \u0026lt;/div\u0026gt;\u0026lt;/div\u0026gt;\u0026lt;div class=\u0026quot;sk-serial\u0026quot;\u0026gt;\u0026lt;div class=\u0026quot;sk-item\u0026quot;\u0026gt;\u0026lt;div class=\u0026quot;sk-estimator fitted sk-toggleable\u0026quot;\u0026gt;\u0026lt;input class=\u0026quot;sk-toggleable__control sk-hidden--visually\u0026quot; id=\u0026quot;sk-estimator-id-48\u0026quot; type=\u0026quot;checkbox\u0026quot; \u0026gt;\u0026lt;label for=\u0026quot;sk-estimator-id-48\u0026quot; class=\u0026quot;sk-toggleable__label fitted sk-toggleable__label-arrow\u0026quot;\u0026gt;\u0026lt;div\u0026gt;\u0026lt;div\u0026gt;OneHotEncoder\u0026lt;/div\u0026gt;\u0026lt;/div\u0026gt;\u0026lt;div\u0026gt;\u0026lt;a class=\u0026quot;sk-estimator-doc-link fitted\u0026quot; rel=\u0026quot;noreferrer\u0026quot; target=\u0026quot;_blank\u0026quot; href=\u0026quot;https://scikit-learn.org/1.6/modules/generated/sklearn.preprocessing.OneHotEncoder.html\u0026quot;\u0026gt;?\u0026lt;span\u0026gt;Documentation for OneHotEncoder\u0026lt;/span\u0026gt;\u0026lt;/a\u0026gt;\u0026lt;/div\u0026gt;\u0026lt;/label\u0026gt;\u0026lt;div class=\u0026quot;sk-toggleable__content fitted\u0026quot;\u0026gt;\u0026lt;pre\u0026gt;OneHotEncoder(handle_unknown=\u0026amp;#x27;ignore\u0026amp;#x27;)\u0026lt;/pre\u0026gt;\u0026lt;/div\u0026gt; \u0026lt;/div\u0026gt;\u0026lt;/div\u0026gt;\u0026lt;/div\u0026gt;\u0026lt;/div\u0026gt;\u0026lt;/div\u0026gt;\u0026lt;/div\u0026gt;\u0026lt;/div\u0026gt;\u0026lt;div class=\u0026quot;sk-item\u0026quot;\u0026gt;\u0026lt;div class=\u0026quot;sk-estimator fitted sk-toggleable\u0026quot;\u0026gt;\u0026lt;input class=\u0026quot;sk-toggleable__control sk-hidden--visually\u0026quot; id=\u0026quot;sk-estimator-id-49\u0026quot; type=\u0026quot;checkbox\u0026quot; \u0026gt;\u0026lt;label for=\u0026quot;sk-estimator-id-49\u0026quot; class=\u0026quot;sk-toggleable__label fitted sk-toggleable__label-arrow\u0026quot;\u0026gt;\u0026lt;div\u0026gt;\u0026lt;div\u0026gt;GradientBoostingClassifier\u0026lt;/div\u0026gt;\u0026lt;/div\u0026gt;\u0026lt;div\u0026gt;\u0026lt;a class=\u0026quot;sk-estimator-doc-link fitted\u0026quot; rel=\u0026quot;noreferrer\u0026quot; target=\u0026quot;_blank\u0026quot; href=\u0026quot;https://scikit-learn.org/1.6/modules/generated/sklearn.ensemble.GradientBoostingClassifier.html\u0026quot;\u0026gt;?\u0026lt;span\u0026gt;Documentation for GradientBoostingClassifier\u0026lt;/span\u0026gt;\u0026lt;/a\u0026gt;\u0026lt;/div\u0026gt;\u0026lt;/label\u0026gt;\u0026lt;div class=\u0026quot;sk-toggleable__content fitted\u0026quot;\u0026gt;\u0026lt;pre\u0026gt;GradientBoostingClassifier(learning_rate=0.075, min_impurity_decrease=0.01, validation_fraction=0.15, verbose=1)\u0026lt;/pre\u0026gt;\u0026lt;/div\u0026gt; \u0026lt;/div\u0026gt;\u0026lt;/div\u0026gt;\u0026lt;/div\u0026gt;\u0026lt;/div\u0026gt;\u0026lt;/div\u0026gt;\u0026lt;/div\u0026gt; Model evaluation # # eval the model y_pred = model.predict(X_test) accuracy = accuracy_score(y_test, y_pred) # get predicted probabilities (needed for log loss) y_pred_proba = model.predict_proba(X_test) # calc log loss loss = log_loss(y_test, y_pred_proba) # print test metrics print(f\u0026#39;Accuracy on Test Data: {accuracy * 100:.2f}%\u0026#39;) print(f\u0026#39;Log Loss on Test Data: {loss:.4f}\u0026#39;) # model info print(\u0026#34;\\nModel details:\u0026#34;, model.named_steps[\u0026#39;classifier\u0026#39;]) Accuracy on Test Data: 80.75% Log Loss on Test Data: 0.3957 Model details: GradientBoostingClassifier(learning_rate=0.075, min_impurity_decrease=0.01, validation_fraction=0.15, verbose=1) Confusion matrix # cm = confusion_matrix(y_test, y_pred) sns.heatmap(cm, annot=True, fmt=\u0026#39;d\u0026#39;, cmap=\u0026#39;Blues\u0026#39;, xticklabels=label_encoder.classes_, yticklabels=label_encoder.classes_) plt.xlabel(\u0026#39;Predicted\u0026#39;) plt.ylabel(\u0026#39;True\u0026#39;) plt.show() Feature importance # # compute the feature importance feature_names = model.named_steps[\u0026#39;preprocessor\u0026#39;].transformers_[0][2] + list(model.named_steps[\u0026#39;preprocessor\u0026#39;].transformers_[1][1].get_feature_names_out()) importance_scores = model.named_steps[\u0026#39;classifier\u0026#39;].feature_importances_ # filter for features with importance \u0026gt; 5% important_features = [(name, score) for name, score in zip(feature_names, importance_scores) if score \u0026gt; 0.05] feature_names, importance_scores = zip(*important_features) # Assuming you have feature_names and importance_scores plt.figure(figsize=(10, 6)) plt.barh(feature_names, importance_scores) plt.title(\u0026#39;Feature Importance\u0026#39;) plt.ylabel(\u0026#39;Features\u0026#39;) plt.xlabel(\u0026#39;Importance Score\u0026#39;) plt.tight_layout() plt.show() ","date":"3 September 2025","externalUrl":null,"permalink":"/code/intro-to-ml/","section":"Code","summary":"Jupyter notebook code from the Intro to ML talk.","title":"Intro to Machine Learning Tools \u0026 Applications for Geoscience","type":"code"},{"content":"","date":"3 September 2025","externalUrl":null,"permalink":"/papers/","section":"Papers","summary":"","title":"Papers","type":"publication"},{"content":"","date":"3 September 2025","externalUrl":null,"permalink":"/talks/","section":"Talks","summary":"","title":"Talks","type":"publication"},{"content":"Guest lecture given as a TA for GEL 1: The Earth at UC Davis, Spring 2025. Taught by Prof. Gregory Funston.\nGoals of this topic: # To locate Earth\u0026rsquo;s place in the universe To address the basic question: how do planets like Earth form? To illustrate how Earth\u0026rsquo;s core, mantle and crust formed To describe the extreme conditions of the Earth during its first few hundred million years ","date":"8 April 2025","externalUrl":null,"permalink":"/talks/redickoriginearthearly2025/","section":"Talks","summary":"","title":"Origin of Earth \u0026 Early Earth","type":"publication"},{"content":"","date":"17 January 2025","externalUrl":null,"permalink":"/tags/geoscience/","section":"Tags","summary":"","title":"Geoscience","type":"tags"},{"content":"","date":"17 January 2025","externalUrl":null,"permalink":"/talks/redickintromachinelearning2025/","section":"Talks","summary":"","title":"Intro to Machine Learning Tools \u0026 Applications for Geoscience","type":"publication"},{"content":"","date":"17 January 2025","externalUrl":null,"permalink":"/tags/machine-learning/","section":"Tags","summary":"","title":"Machine Learning","type":"tags"},{"content":"","date":"17 January 2025","externalUrl":null,"permalink":"/tags/","section":"Tags","summary":"","title":"Tags","type":"tags"},{"content":"","date":"17 January 2025","externalUrl":null,"permalink":"/tags/tutorial/","section":"Tags","summary":"","title":"Tutorial","type":"tags"},{"content":"","date":"25 November 2024","externalUrl":null,"permalink":"/authors/admin/","section":"Authors","summary":"","title":"Admin","type":"authors"},{"content":"","date":"25 November 2024","externalUrl":null,"permalink":"/tags/macos/","section":"Tags","summary":"","title":"Macos","type":"tags"},{"content":"","date":"25 November 2024","externalUrl":null,"permalink":"/tags/python/","section":"Tags","summary":"","title":"Python","type":"tags"},{"content":" Installations # Installing Python # We will download our Python distribution from the Miniconda website. Click on the link for the MacOS (Apple Silicon) installer and download the file.\nA distribution of a language is a bundle that contains an implementation of Python along with a bunch of libraries or tools.\nWe will use the Miniconda Python distribution, which is provided by Anaconda. You can read more about it here (later). Simply, it contains the Python language, a package manager called conda, all of the packages they both depend on, and a small number of other useful packages.\nMiniconda is a good distribution because:\nIt is relatively light-weight, so it won\u0026rsquo;t take up a lot of stuff on your computer It contains conda, which is very good at installing python packages (like numpy, pygmt) and for managing virtual environments (which we\u0026rsquo;ll talk about later) Once you have downloaded the installer, open it and follow the instructions. You will need to agree to the license, select the installation location, and then install the software. You do not need to make any changes to the installation options.\nInstalling Visual Studio Code # Now that we have a Python distribution installed, we need somewhere we can read, write, and run code!\nVisual Studio Code (VSCode, VSC) is one of the most popular ways to write code, not just Python! It is a light-weight code editor (What\u0026rsquo;s the difference between a code editor and an IDE?).\nYou can find the download link \u0026amp; some helpful instructions for VSC here: https://code.visualstudio.com/docs/setup/mac\nOnce you have downloaded VSC, open it and follow any instructions that pop up. Then, open the app!\nWhat\u0026rsquo;s the difference between a code editor and an IDE? # \u0026ldquo;IDE\u0026rdquo; stands for \u0026ldquo;Integrated Development Environment\u0026rdquo; is a fully-featured place to develop code. They have built-in debuggers, syntax highlighting, etc.\nPopular IDEs for Python are PyCharm and Spyder. However, they take up a lot of space and frequently only work to code in one language.\nOn the other hand, a code editor is very light-weight an easy to modify. They typically also work for many languages. VSC is a code editor that is built on the idea of extensions. You can add extensions to modify the way VSC works\u0026mdash;almost anything you can think of.\nImportantly, VSCode is free, and so are its extensions. While there are free versions of IDEs, some of the features are behind paywalls.\nSetting up your coding environment # Adding Python-relevant extensions to VSC # To be able to read, write, and run Python, we will need to install some extensions.\nFirst, open up VSC. It will look something like this:\nThen, we want to open up the \u0026ldquo;extensions\u0026rdquo; panel and install the extensions you see in the image below:\nNow, we want to ensure that VSC knows where to find our Miniconda Python executable. To do so, open up settings (the easiest way to do so is cmd + ,), or the top navigation bar that says: \u0026ldquo;Code\u0026rdquo; \u0026gt; \u0026ldquo;Settings\u0026hellip;\u0026rdquo;\nThen, we add ~/miniconda3/bin/python to the following setting:\nWe also want to tell the Code Runner extension to use the Python interpreter from our Miniconda distribution. To do so, we need to add the following line to our VSC settings:\n\u0026#34;code-runner.executorMap\u0026#34;: { \u0026#34;python\u0026#34;: \u0026#34;python $fullFileName\u0026#34;, } You can find this setting by searching for code-runner.executorMap in the settings search bar (open settings with cmd + ,), then clicking the link to edit in settings.json.\nThen, make sure VSC will use your terminal for outputs. You can do this by searching for code-runner.runInTerminal in the settings search bar and making sure it is set to true.\nRunning your first Python file # Now, it is time to see if everything is working. First, let\u0026rsquo;s create a new Python file and name it fibonacci.py:\nLet\u0026rsquo;s create a function that returns the nth value in the Fibonacci sequence.\n# create a function that returns the nth number in the fibonacci sequence def fibonacci(n): if n == 0: return 0 elif n == 1: return 1 else: return fibonacci(n-1) + fibonacci(n-2) print(fibonacci(10)) Then, we need to set the interpreter (AKA, what python environment are you using?). You may see this option in the bottom bar (blue in the image above). Alternatively, you can access it from the command palette using the keyboard shortcut cmd + shift + p. For now, we want to use our conda base environment. It does not matter if the Python version is the same as shown in the photo below.\nNow, we can use the button in the top right corner to run the file. This will open a terminal shell within VSC that outputs the result of the code we wrote.\nPython virtual environments # In the last example, we used our conda base environment to run the code. However, we never want to install packages in our base environment. If we accidentally mess up the base, it can cause a lot of (very frustrating issues). So, we use virtual environments.\nA virtual environment (venv) is an isolated version of Python you can install packages into without effecting your base environment or any other venvs that you create. Typically, we create new venvs for each project we work on.\nconda can help us manage virtual environments.\nFirst, we want to open one of the extensions we installed (donjayamanne.python-environment-manager):\nThen, under global environments, under conda, we will use the + to create a new globally-accessible Python environment.\nA window will pop up asking you to select the version of Python you want the environment to use, typically you would select the newest version.\nThen, you will be asked to give the environment a name:\nA window will ask you if you want to use this environment in the current workspace, you should say yes. This sets your interpreter to the new environment we created.\nIn our global environments pane, we can now see the environment we created. Now, we want to install packages that we want to use. To do so, you will need to open a terminal shell with the venv activated. Our package manager extension can do this for us:\nThis will run the command to activate the environment for you and an integrated terminal (one that is inside of our code editor) will pop up.\nNow we can run conda commands. We want to install a few different libraries:\nnumpy pygmt geopandas obspy We can do this with the following command in our integrated terminal window:\nconda install numpy pygmt geopandas obspy -y The command may take several seconds to run, especially when you are installing several libraries at once.\n-y tells the command to confirm any prompts confirming the libraries. If you want to answer prompts manually, you can leave this message off.\nYou will see this output if the installs are successful:\nIf you want to check which packages are in your venv, you can run conda list. This will include a lot of libraries you don\u0026rsquo;t remember installing. These are called dependencies, they are packages that the libraries you asked conda to install need to be able to run properly. If you want to search for specific libraries in the list, you can use this command: conda list | grep \u0026lt;name of package\u0026gt;\nThe other columns are the version of pygmt, the build, and the channel of conda we installed it from.\nRunning your first Jupyter Notebook # Now that we have a working virtual environment, we can start working within our venv in a Jupyter Notebook (any file with a *.ipynb extension).\nFirst, use the command palette (cmd + shift + p) to run the command for creating a new notebook. The command palette will search as you type.\nNow, we have an empty notebook file. First, we need to tell the notebook what Python venv to use when running code. Notebooks call this the kernel. You will see a button in the upper right corner for selecting the kernel.\nWe want to select the venv we just installed our packages into:\nNow, we can add some code to our cells.\nThen, you can use the run all button to run all of the cells. You will notice that when you first run your notebook with a new environment, you will be asked to install the ipykernel library. This is what your venv needs to interpret and run cells, so let it install the library.\nThen, your code will run!\nPro-tips # Using the command palette # In VSC, the command palette is your best friend. Becoming comfortable with the cmd + shift + p keyboard shortcut will make development much easier.\nThe command palette will search as you type, allowing you to find and use the commands provided by both VSC natively and all of the extensions you have installed.\nAccessing (and hiding) the integrated terminal # Sometimes, you want to hide (or show) the integrated terminal window. It have be helpful to minimize it to maximize editor space. For showing or hiding the terminal (without ending the shell session), you can use cmd + j.\nExploring settings # You will want to take some time to explore the settings of VSC and the extensions you have installed. It may be overwhelming at first, but it will give you a better idea of what VSC and your extensions can do.\nSome useful things to look for may be:\nturning on autosave turning on auto-closing brackets such as (), {}, [] changing the default font \u0026amp; font size changing the theme!! Other useful extensions # VSC has infinitely many useful extensions. Take some time to search in the extensions pane for things that might be useful. I have included ones I use all the time below.\nLearning your other keyboard shortcuts # There are so many useful shortcuts that will make it possible \u0026amp; easier to do useful things. There are lots of \u0026ldquo;cheat sheets\u0026rdquo; online that explain what these are.\n","date":"25 November 2024","externalUrl":null,"permalink":"/docs/setting-up-vsc-macos/","section":"Docs","summary":"Guide to setting up VSCode and Python on MacOS with or without Homebrew","title":"Setting up VSCode and Python for MacOS","type":"docs"},{"content":"","date":"25 November 2024","externalUrl":null,"permalink":"/tags/vscode/","section":"Tags","summary":"","title":"Vscode","type":"tags"},{"content":"","date":"23 January 2024","externalUrl":null,"permalink":"/talks/redickcodefreedeeplearning2024/","section":"Talks","summary":"","title":"Code-Free Deep Learning for Geospatial Applications","type":"publication"},{"content":"","date":"23 January 2024","externalUrl":null,"permalink":"/tags/deep-learning/","section":"Tags","summary":"","title":"Deep Learning","type":"tags"},{"content":"","date":"23 January 2024","externalUrl":null,"permalink":"/tags/geospatial-analysis/","section":"Tags","summary":"","title":"Geospatial Analysis","type":"tags"},{"content":"","date":"23 January 2024","externalUrl":null,"permalink":"/authors/james-d.-kirkpatrick/","section":"Authors","summary":"","title":"James D. Kirkpatrick","type":"authors"},{"content":"","date":"23 January 2024","externalUrl":null,"permalink":"/tags/low-code/","section":"Tags","summary":"","title":"Low-Code","type":"tags"},{"content":"","date":"23 January 2024","externalUrl":null,"permalink":"/authors/matthew-s.-tarling/","section":"Authors","summary":"","title":"Matthew S. Tarling","type":"authors"},{"content":"","date":"23 January 2024","externalUrl":null,"permalink":"/tags/open-science/","section":"Tags","summary":"","title":"Open Science","type":"tags"},{"content":"","date":"4 April 2023","externalUrl":null,"permalink":"/talks/redickbuildingaccessiblemachine2023/","section":"Talks","summary":"","title":"Building an Accessible Machine Learning Workflow for Geospatial Analysis","type":"publication"},{"content":"","date":"20 March 2023","externalUrl":null,"permalink":"/papers/redick-review-pumice-raft-2023/","section":"Papers","summary":"","title":"A Review of Pumice Raft Formation Environments, Saturation, and Dispersal Mechanisms","type":"publication"},{"content":"","date":"20 March 2023","externalUrl":null,"permalink":"/tags/pumice-dispersal-mechanisms/","section":"Tags","summary":"","title":"Pumice Dispersal Mechanisms","type":"tags"},{"content":"","date":"20 March 2023","externalUrl":null,"permalink":"/tags/pumice-rafting/","section":"Tags","summary":"","title":"Pumice Rafting","type":"tags"},{"content":"","date":"20 March 2023","externalUrl":null,"permalink":"/tags/pumice-saturation/","section":"Tags","summary":"","title":"Pumice Saturation","type":"tags"},{"content":"","date":"20 March 2023","externalUrl":null,"permalink":"/tags/review/","section":"Tags","summary":"","title":"Review","type":"tags"},{"content":"","date":"20 March 2023","externalUrl":null,"permalink":"/tags/submarine-volcanism/","section":"Tags","summary":"","title":"Submarine Volcanism","type":"tags"},{"content":" ","externalUrl":null,"permalink":"/gallery/","section":"","summary":"","title":"","type":"page"},{"content":"","externalUrl":null,"permalink":"/categories/","section":"Categories","summary":"","title":"Categories","type":"categories"},{"content":"","externalUrl":null,"permalink":"/series/","section":"Series","summary":"","title":"Series","type":"series"}]