================= Importing Package ================= We import the package mineralML in Python. .. code-block:: python import mineralML as mm ============== Importing Data ============== We walk through an implementation of ``mineralML`` here. Create this following file structure locally: :: mineralML/ ├── Chemistry.csv └── mineralML_neuralnetwork.py The following columns are required for this Chemistry file: * Sample or Sample Name * SiO₂ * TiO₂ * Al₂O₃ * FeOₜ * MnO * MgO * CaO * Na₂O * K₂O * Cr₂O₃ * P₂O₅ For example, here an example containing the mineral composition data in the desired input format. You can use the ChemistryTemplate.csv from the Training_Data bit of the GitHub repository to create your own. For oxides that were not analyzed or not detected, enter 0 into the cell or alternatively ``mineralML`` will fill in these empty cells with 0 values when you use the function ``mm.prep_df``. +--------+----------------------+---------+----------+-----------+----------+------------+----------+-----------+-----------+------------+------------+-----------+-------------------+ | | Sample Name | SiO2 | TiO2 | Al2O3 | FeOt | MnO | MgO | CaO | Na2O | K2O | P2O5 | Cr2O3 | Mineral | +========+======================+=========+==========+===========+==========+============+==========+===========+===========+============+============+===========+===================+ | 0 | Z2099 | 42.96 | 1.8 | 14.33 | 4.07 | 0.07 | 17.39 | 12.03 | 3.1 | 0.03 | nan | 0.65 | Amphibole | +--------+----------------------+---------+----------+-----------+----------+------------+----------+-----------+-----------+------------+------------+-----------+-------------------+ | 3172 | SG-09-32_12 | 0.17 | nan | nan | 0.7 | nan | 0.13 | 54.32 | nan | nan | 40.97 | nan | Apatite | +--------+----------------------+---------+----------+-----------+----------+------------+----------+-----------+-----------+------------+------------+-----------+-------------------+ | 4907 | IgnA-2 | 36.9 | 2.31 | 16.4 | 8.2 | 0.08 | 20.6 | 0.03 | 0.71 | 8.79 | nan | 0.09 | Biotite | +--------+----------------------+---------+----------+-----------+----------+------------+----------+-----------+-----------+------------+------------+-----------+-------------------+ | 8137 | REG55-calcite-1 | 0 | 0 | 0 | 0.07 | 0.0457 | 0.0526 | 57.0312 | 0.0046 | 0.0216 | nan | 0.1757 | Carbonate | +--------+----------------------+---------+----------+-----------+----------+------------+----------+-----------+-----------+------------+------------+-----------+-------------------+ | 9148 | zk803-31-01-01 | 29.41 | 0.03 | 18.6 | 33.22 | 0.08 | 6.7 | 0.1 | 0.03 | 0.26 | nan | nan | Chlorite | +--------+----------------------+---------+----------+-----------+----------+------------+----------+-----------+-----------+------------+------------+-----------+-------------------+ | 10473 | 17MMSG37_cpx4-1 | 46.8911 | 2.8722 | 6.5948 | 8.4685 | 0.1886 | 13.884 | 20.2569 | 0.3403 | nan | nan | 0.0908 | Pyroxene (Cpx) | +--------+----------------------+---------+----------+-----------+----------+------------+----------+-----------+-----------+------------+------------+-----------+-------------------+ | 21383 | CL09MB009 C2 ep 20 | 37.38 | 0.01 | 21.29 | 15.3507 | 0.29 | 0.06 | 23.19 | 0 | 0 | nan | nan | Epidote | +--------+----------------------+---------+----------+-----------+----------+------------+----------+-----------+-----------+------------+------------+-----------+-------------------+ | 22647 | Lw-Ec_GR1_core | 38.52 | 0.04 | 21.84 | 27.07 | 1.49 | 5.58 | 5.82 | 0.03 | 0 | nan | 0 | Garnet | +--------+----------------------+---------+----------+-----------+----------+------------+----------+-----------+-----------+------------+------------+-----------+-------------------+ | 27666 | REG-18_kalsilite-1 | 37.02 | 0 | 31.43 | 0.35 | 0 | 0 | 0 | 0.04 | 29.61 | nan | 0.0069 | Kalsilite | +--------+----------------------+---------+----------+-----------+----------+------------+----------+-----------+-----------+------------+------------+-----------+-------------------+ | 28666 | DG-44 | 65.0797 | nan | 18.8768 | 0 | nan | nan | 0.0664 | 2.4138 | 13.194 | nan | nan | Feldspar (Alkali) | +--------+----------------------+---------+----------+-----------+----------+------------+----------+-----------+-----------+------------+------------+-----------+-------------------+ | 34677 | VS219_129 / 1 . Leu | 54.7008 | 0.113 | 23.0378 | 0.5208 | 0.0064 | 0.0493 | nan | 0.0205 | 21.7093 | nan | nan | Leucite | +--------+----------------------+---------+----------+-----------+----------+------------+----------+-----------+-----------+------------+------------+-----------+-------------------+ | 39803 | S80_7 / 2 . | 41.0155 | 0.0521 | 5.6907 | 5.2198 | 0.131 | 6.6045 | 28.6936 | 3.7814 | 0.1842 | nan | nan | Melilite | +--------+----------------------+---------+----------+-----------+----------+------------+----------+-----------+-----------+------------+------------+-----------+-------------------+ | 40939 | WS5_37 | 44.8 | 0.24 | 35.12 | 0.269 | 0.04 | 3.22 | 0.16 | 0.15 | 10.57 | nan | 0 | Muscovite | +--------+----------------------+---------+----------+-----------+----------+------------+----------+-----------+-----------+------------+------------+-----------+-------------------+ | 42090 | 10_N_1 | 42.033 | nan | 32.705 | 0 | nan | nan | 0.105 | 15.507 | 7.859 | nan | nan | Nepheline | +--------+----------------------+---------+----------+-----------+----------+------------+----------+-----------+-----------+------------+------------+-----------+-------------------+ | 43110 | CN_C_Ol1 | 39.846 | 2e-05 | 0.01915 | 17.3987 | 0.243865 | 43.1267 | 0.21963 | 0.01495 | 0.007775 | 0.013685 | nan | Olivine | +--------+----------------------+---------+----------+-----------+----------+------------+----------+-----------+-----------+------------+------------+-----------+-------------------+ | 65125 | L04_N1_1 | 56.08 | 0.2769 | 1.868 | 7.21 | 0.1732 | 34.17 | 0.517 | nan | nan | nan | 0.4681 | Orthopyroxene | +--------+----------------------+---------+----------+-----------+----------+------------+----------+-----------+-----------+------------+------------+-----------+-------------------+ | 70895 | K8_plag1_rtoc | 46.6657 | 0.0297 | 32.4782 | 0.5769 | 0.0013 | 0.2178 | 16.8384 | 1.7939 | 0.0031 | nan | nan | Plagioclase | +--------+----------------------+---------+----------+-----------+----------+------------+----------+-----------+-----------+------------+------------+-----------+-------------------+ | 25650 | UC1250 | 0.0424 | 49.1927 | 0.0757 | 43.9452 | 1.6045 | 2.8229 | 0.0139 | nan | nan | nan | 0.0148 | Rhombohedral-Oxide| +--------+----------------------+---------+----------+-----------+----------+------------+----------+-----------+-----------+------------+------------+-----------+-------------------+ | 90207 | E2718C-1 | 0.0091 | 98.4337 | 0.0236 | 0.2144 | 0.0089 | nan | nan | nan | nan | nan | 0.1976 | Rutile | +--------+----------------------+---------+----------+-----------+----------+------------+----------+-----------+-----------+------------+------------+-----------+-------------------+ | 91925 | OM15-6 | 41.2574 | nan | 1.34979 | 4.38996 | nan | 39.5454 | nan | nan | nan | nan | 0.26425 | Serpentine | +--------+----------------------+---------+----------+-----------+----------+------------+----------+-----------+-----------+------------+------------+-----------+-------------------+ | 89207 | OM08-206A_2 | 99.7 | 0 | 0 | 0.3 | 0.03 | 0 | 0 | 0.01 | 0.02 | nan | 0 | SiO2-Polymorph | +--------+----------------------+---------+----------+-----------+----------+------------+----------+-----------+-----------+------------+------------+-----------+-------------------+ | 36205 | UC1080 | 0.16 | 16.572 | 0.941 | 74.515 | 0.565 | 0.851 | 0.037 | nan | nan | nan | 0.012 | Spinel-Group | +--------+----------------------+---------+----------+-----------+----------+------------+----------+-----------+-----------+------------+------------+-----------+-------------------+ | 96256 | REG-19-titanite-1 | 29.3211 | 33.0262 | 1.3941 | 2.90473 | 0.0339 | 0.076 | 26.5311 | 0.1435 | 0.0327 | nan | 0 | Titanite | +--------+----------------------+---------+----------+-----------+----------+------------+----------+-----------+-----------+------------+------------+-----------+-------------------+ | 104307 | Tourmaline1 | 36.47 | 0.82 | 30.79 | 4.13 | nan | 9.52 | 0.74 | 2.36 | nan | nan | nan | Tourmaline | +--------+----------------------+---------+----------+-----------+----------+------------+----------+-----------+-----------+------------+------------+-----------+-------------------+ | 105329 | Zrn-I | 32.816 | 0.005 | 0 | 0.007 | nan | nan | 0 | 0.008 | nan | 0.027 | nan | Zircon | +--------+----------------------+---------+----------+-----------+----------+------------+----------+-----------+-----------+------------+------------+-----------+-------------------+ | 106329 | 20B-04 | 49.96 | 1.59 | 13.73 | 11.8 | 0.21 | 7.27 | 11.88 | 2.27 | 0.25 | 0.18 | nan | Glass | +--------+----------------------+---------+----------+-----------+----------+------------+----------+-----------+-----------+------------+------------+-----------+-------------------+ For the mineral composition, ``mineralML`` asks that users provide Fe as FeO\ :sub:`t`. To avoid ambiguity, the Chemistry file handles this by providing only one column for FeO\ :sub:`t`. We use the os package in Python to facilitate navigation to various files. To load the Chemistry file, you must provide the path to the CSV. .. code-block:: python path = os.getcwd() + '/Chemistry.csv' df_load = mm.load_df(path) df = mm.prep_df(df_load) ``mm.load_df`` returns `df_load`, an initial dataframe of all of all samples and their chemistry. ``mm.prep_df`` then prepares the loaded dataframe by filling in any nan values, ensuring all required oxide columns are present, optionally converting all Fe to FeO\ :sub:`t` and dropping rows with fewer than n oxides. ==================== Data Import Complete ==================== That is all for loading your mineral chemical compositions! You are ready to get rolling with ``mineralML``. See the example in ML Predictions for Tabular Data (mineralML_neuralnetwork.ipynb), under the big examples heading, to see how to run ``mineralML`` and export files.