Setup of Jupyter Notebook

How to Setup Jupyter Notebook and run Credmark Models on it.

To run Credmark models, it is not necessary to run them in your SDK locally, you can as well simply run with Jupyter Notebooks.

Jupyter Notebook is a web-based interactive computing platform often used for data analysis. In this guide, we will

  1. Set up a virtual environment using Conda

  2. Clone Credmark-Models-Notebook repository

  3. Open and run Jupyter Notebook in this environment

  4. Clone the Credmark github repository in Jupyter Notebook

  5. Run Credmark models in Jupyter Notebook

Click here for more information on installing Conda.

Setting up your Virtual Environment

  1. Run the following script in your CLI. Note, you can change the variable NAME to use this script to create other Conda environments.

conda create -y --name "$NAME"
conda install -y --name "$NAME" -c conda-forge pip
conda activate ${NAME}
conda install -y --name "$NAME" -c conda-forge ipython jupyterlab nb_conda_kernels black isort
conda install -y --name "$NAME" -c conda-forge jupyterlab_code_formatter ipywidgets
conda install -y --name "$NAME" -c conda-forge scipy numpy
conda install -y --name "$NAME" -c conda-forge altair pandas matplotlib openpyxl xlsxwriter
conda activate ${NAME}

2. Your CLI should show the new environment in the command line.

Cloning the Credmark-Models-Notebook repository.

Navigate your CLI to the directory where you'd like to clone the repository. Clone the repository with

git clone

in the command line.

Open Jupyter Notebook and navigate to the examples

Open Jupyter Notebook with

jupyter notebook

in the command line.

When the notebook opens in your browser, you will see the Notebook Dashboard, which will show a list of the notebooks, files, and subdirectories in the directory where the notebook server was started. Most of the time, you will wish to start a notebook server in the highest level directory containing notebooks.

Now click on the example directory

And click 00-start.ipynb to open the notebook. Note that we have already completed the first few steps (creating a virtual environment and launching Jupyter Notebook).

Look to the upper right corner of the notebook to see which kernel the Jupyter Notebook is running.

Mine opens with the default Python 3 ipykernel, so I'll have to switch it to the conda environment we created for using the Credmark Model Framework in Jupyter Notebook. Do this by clicking the Kernel tab of the Notebook, and navigating to Change kernel. I'll switch from the default Python 3 (ipykernel) to the cmf conda environment.

Once the notebook switches kernels, you should see your chosen kernel in the upper right corner of the notebook.

Install Credmark Model Framework using Jupyter Notebook

Insert a new cell below the installation instructions and execute the following commands

!cd ../../ && git clone
!cd ../../credmark-models-py && pip install -r requirements.txt && pip install -e .

Configure Model Directory and Chain to Provider URL

Use your Ethereum Web3 API key as your chain_to_provider_url and be sure the model_loader_path is pointing at the cloned credmark-models-py's "models" folder.

Follow along with the rest of this example notebook, and any others, to learn how to use the Credmark Model Framework within Jupyter Notebooks.

Last updated