Package: mirzai
Prediction of Exchangeable Potassium in Soil through Mid-Infrared
Spectroscopy and Deep Learning: from Prediction to Explainability,
Albinet et al., 2022ThemirzaiPython Package, the
presentdocumentationand associated
notebooks ensure the reproducibility of the above-mentionedscientific
paper.Paper with codeExploratory Data Analysis (Fig. 1)Data selection and transformationBaseline model (PLSR):Learning curveTraining & evaluationConvolutional Neural Network (CNN):Learning rate finderLearning curveTraining & evaluationValidation curve by Soil Taxonomy Orders (Fig.
5)PLSR vs. CNN figures:Learning curves (Fig. 3)Observed vs. predicted scatterplots (Fig.
4)Global vs. local modelling (Fig.
6)InterpretabilityGradientShap values (Fig.
7))GradientShap values correlation (Fig.
8)SetupGetting the dataA 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=sharingIn a local environmentThe preferred way it to useMamba. Mamba
is a fast, robust, and cross-platform package manager.To install the required dependency and proper Python version:Clonegit clone git@github.com:franckalbinet/mirzai.gitor download
thehttps://github.com/franckalbinet/mirzaiinto your local
environementInmirzai/root folder, execute the following Mamba commandmamba env create -f environment.ymlHere below the content ofmirzai/environment.ymlfile 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
  - captumThen activate the Python environement generated:mamba activate mirzaiAnd finally launchjupyter notebookIn Google ColabGoogle 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 toColab
FAQfor further
information.Each notebook listed above includes alink 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:To mount Google drive to access the data uploadedTo install themirzaiPython packageThese 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 mirzaiTo locate the Google Drive folder where you uploaded the data, follow
the 3 steps shown below:Click the “Files” icon in the Colab left panel then click on
“MyDrive”Navigate to the directory containing the data then click on the ” 3
vertical dots” iconClick 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 inColabtop menu: Runtime ▶ Change runtime type ▶ and selectGPUin
the “Hardware accelerator” select box.AcknowledgementsThis 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.OthersThe namemirzaicomes from Mid-InfraRed Spectroscopy with AI but also
is a way to pay tribute toNino Ferrer’s song
“Mirza”