Skip to main content

Prediction of Exchangeable Potassium in Soil through Mid-Infrared Spectroscopy and Deep Learning: from Prediction to Explainability, Albinet et al., 2022

The mirzai Python Package, the present documentation and associated notebooks ensure the reproducibility of the above-mentioned scientific paper.

Paper with code

  1. Exploratory Data Analysis (Fig. 1)

  2. Data selection and transformation

  3. Baseline model (PLSR):

  4. Convolutional Neural Network (CNN):

  5. PLSR vs. CNN figures:

  6. Interpretability

Setup

Getting the data

A zipped archive of the data used in this study are available for download at the following link: https://drive.google.com/drive/folders/1VGfrBexMPCFvoUa1VW26n-zO9v5WHeFh?usp=sharing

In a local environment

The preferred way it to use Mamba. Mamba is a fast, robust, and cross-platform package manager.

To install the required dependency and proper Python version:

  • Clone git clone git@github.com:franckalbinet/mirzai.git or download the https://github.com/franckalbinet/mirzai into your local environement
  • In mirzai/ root folder, execute the following Mamba command mamba env create -f environment.yml

Here below the content of mirzai/environment.yml file listing required Python version and packages:

name: mirzai
channels:
  - conda-forge
  - fastchan
  - pytorch
dependencies:
  - python=3.8
  - nbdev
  - jupyterlab
  - numpy
  - scipy
  - matplotlib=3.5.1
  - scikit-learn
  - pytorch
  - torchvision=0.12.0
  - tqdm
  - captum
  • Then activate the Python environement generated: mamba activate mirzai

  • And finally launch jupyter notebook

In Google Colab

Google Colab has been used to perform the experiments described in the above mentioned paper. The main advantage of Colab is to give access to a GPU (Graphical Processing Unit) which allows to train Deep Learning model in a fair amount of time. Please refer to Colab FAQ for further information.

Each notebook listed above includes a link to load it in the Google Colab environment. When clicking on those links, the notebook will get loaded in Google Colab.

Then, once open in Colab, you will need:

  1. To mount Google drive to access the data uploaded
  2. To install the mirzai Python package

These two steps are already included on top of each notebook and will be executed if on Colab:

if 'google.colab' in str(get_ipython()):
    from google.colab import drive
    drive.mount('/content/drive',  force_remount=False)
    !pip install mirzai

To locate the Google Drive folder where you uploaded the data, follow the 3 steps shown below:

  1. Click the “Files” icon in the Colab left panel then click on “MyDrive”
  2. Navigate to the directory containing the data then click on the ” 3 vertical dots” icon
  3. Click on “Copy path” to copy the full path (for instance /content/drive/MyDrive/research/predict-k-mirs-dl/data)

Last, when a GPU is required (e.g when training the Convolutional Neural Network or computing the GradientShap values), change runtime type in Colab top menu: Runtime ▶ Change runtime type ▶ and select GPU in the “Hardware accelerator” select box.

Acknowledgements

This work was carried out in the context of the IAEA funded Coordinated Research Project (CRP D1.50.19) titled “Remediation of Radioactive Contaminated Agricultural Land”, under IAEA Technical Contract n°23685.

We also thank Richard Ferguson from Kellogg Soil Survey Laboratory for providing access to the USDA MIR soil spectra library and the r equired training sessions for its operation.

Others

The name mirzai comes from Mid-InfraRed Spectroscopy with AI but also is a way to pay tribute to Nino Ferrer’s song “Mirza”

Metadata

Release files for mirzai 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mirzai 0.4.0
File Size Uploaded Provenance
mirzai-0.4.0.tar.gz 24.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for mirzai 0.4.0
File Interpreter ABI Platform
mirzai-0.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 48.9 kB

Release files / mirzai-0.4.0.tar.gz

Download URL mirzai-0.4.0.tar.gz
Size 24.2 kB
Tags Source
SHA-256 checksum
How to use checksums
cfee4a357de9041dc22561a390796306689eb351b28e3516a88c1e06474f926e
BLAKE2b-256 checksum
How to use checksums
f29f93cacbe2ef10241de1f746d6b973f690dcbf9c18d869d55b7563c3ed5280
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Release files / mirzai-0.4.0-py3-none-any.whl

Download URL mirzai-0.4.0-py3-none-any.whl
Size 24.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c507185a20bbb59ee16f8d8ba32b74f2647f49c026f72a7fb04af6a5935a53c1
BLAKE2b-256 checksum
How to use checksums
6048d643e9ca3cded0e8e84c67c738129b06e68424065127b1e5ec6d71148669
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Security for mirzai 0.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page