Version: 1.3.16

Get started in Jupyter Notebooks

Certifai toolkit can be installed for use with Jupyter notebooks in two ways.

  • Install the Certifai toolkit and create a conda environment in which to run the Certifai notebooks: See the section below Run the example notebooks

  • Install the Certifai toolkit in the context of an existing Jupyter notebook, without creating and running a separate conda environment: See the section below Install Certifai toolkit in an existing notebook environment

Run the example notebooks

Certifai provides two sets of example notebooks:

The rest of this section describes how to run the example notebooks provided in the cortex-certifai-examples repo.

PREREQUISITES

Follow the instructions provided on these pages to download, install, and create a conda environment in which to run Certifai sample notebooks provided in the toolkit:

PROCESS:

  1. Clone the cortex-certifai-examples repo:

    1. Open a terminal window and cd to the folder where you would like to store the repo clone.
    2. Run git clone https://github.com/CognitiveScale/cortex-certifai-examples.git

    OR

    1. From the repo window click Clone or Download and then click download .zip.
    2. Move the .zip from your downloads folder to a folder where you would like to keep it.

    THEN

  2. Activate your Certifai conda environment if it is not already activated.

    conda activate certifai
  3. Change your directory to the folder of the notebook you want to run (see the Example Notebooks section below for descriptions of the available notebooks). For example: cd cortex-certifai-examples/notebooks/fairness_metrics/

  4. From the Jupyter browser, open the notebook, then follow the steps to Run each cell.

Scan reports are saved by default at /<repo-root>/<notebook-root>/reports/ at the root of where you are running the notebook from.

Install Certifai toolkit in an existing notebook environment

PREREQUISITES

Follow the instruction provided on this page to download the Certifai toolkit then proceed using the instructions below:

PROCESS

  1. Open a terminal or PowerShell window and set your context inside the root of the certifai_toolkit folder.

    cd <folder-where-you-unzipped-certifai_toolkit>
  2. Install the Certifai packages required for running scans in notebooks.

    NOTE: The version+tag required in the following commands can be found in your certifai_toolkit/packages folder. (Example: cortex-certifai-scanner-0.5.1-55-g73c4eabf)

    Where to find version number and tag to install packages

    • a. Install the Certifai Scanner.

      pip install packages/all/cortex-certifai-scanner-<version>-<tag>.zip

      Example:

      pip install packages/all/cortex-certifai-scanner-1.3.1-32-g8c0f816e.zip
    • b. Install the Certifai common library.

      pip install packages/all/cortex-certifai-common-<version>-<tag>.zip

      Example:

      pip install packages/all/cortex-certifai-common-1.3.1-32-g8c0f816e.zip
    • c. Install the Certifai engine for the python version you are using.

      pip install packages/python3.7/cortex-certifai-engine-<version>-<tag>.zip

      OR

      pip install packages/python3.8/cortex-certifai-engine-<version>-<tag>.zip
  3. (Optional) To run the example notebooks, install the python library: matplotlib.

    pip install matplotlib
  4. Verify your install by running certifai -h.

  5. Start the Jupyter server.

    jupyter notebook

    A file list is displayed in the JupyterLab browser.

Visualizing scan results

View the report visualizations in your local Console. With the example data and notebooks the following report directories are used (relative to the root of the cortex-certifai-examples local or the notebook depending on where you are running the notebook from.):

  • toolkit/examples/reports - a set of pre-generated example reports included in the toolkit
  • <repo-root>/<notebook-root>/reports - reports generated by running the notebooks in the cortex-certifai-examples repo.
certifai console <path-to-reports>

Check out some additional details about specifying the report path.