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
Alert: Windows 10 Users
Before you run example notebooks, you must disable QuickEdit Mode
in your terminal window. Right click in the terminal window and uncheck the QuickEdit Mode
option.
If you do not disable this option, clicking off your terminal window and back into your terminal window will cause the window to freeze and you will not receive your scan results updates.
Certifai provides two sets of example notebooks:
- The Certifai Toolkit includes one example notebook in the
examples/notebooks
directory. To run that example, see the Tutorial: Scan your own Model in a Notebook. - The public cortex-certifai-examples repo contains a larger set of content to help you get started, like sample notebooks and tutorials.
The rest of this section describes how to run the example notebooks provided in the cortex-certifai-examples repo.
NOTE
The cortex-certifai-examples repo is available as of toolkit v.1.2.14. If you are using an earlier version, all of the example notebooks are available directly from the toolkit. The instructions for using toolkit example notebooks can be found in the earlier versions of the documentation (via the toggle at the top right).
PREREQUISITES
Follow the instruction provided on these pages to download, install, and create a conda environment in which to run Certifai sample notebooks provided in the toolkit:
PROCESS:
Clone the cortex-certifai-examples repo:
- Open a terminal window and
cd
to the folder where you would like to store the repo clone. - Run
git clone https://github.com/CognitiveScale/cortex-certifai-examples.git
OR
- From the repo window click Clone or Download and then click download .zip.
- Move the .zip from your downloads folder to a folder where you would like to keep it.
THEN
- Open a terminal window and
Activate your Certifai conda environment if it is not already activated.
conda activate certifaiChange 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/
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
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>Install the Certifai packages required for running scans in notebooks.
NOTE: The
version+tag
required in the following commands can be found in yourcertifai_toolkit/packages
folder. (Example:cortex-certifai-scanner-0.5.1-55-g73c4eabf
)a. Install the Certifai Scanner.
pip install packages/all/cortex-certifai-scanner-<version>-<tag>.zipExample:
pip install packages/all/cortex-certifai-scanner-1.3.1-32-g8c0f816e.zipb. Install the Certifai common library.
pip install packages/all/cortex-certifai-common-<version>-<tag>.zipExample:
pip install packages/all/cortex-certifai-common-1.3.1-32-g8c0f816e.zipc. Install the Certifai engine for the python version you are using.
pip install packages/python3.6/cortex-certifai-engine-<version>-<tag>.zipOR
pip install packages/python3.7/cortex-certifai-engine-<version>-<tag>.zipOR
pip install packages/python3.8/cortex-certifai-engine-<version>-<tag>.zip
(Optional) To run the example notebooks, install the python library:
matplotlib
.pip install matplotlibVerify your install by running
certifai -h
.Start the Jupyter server.
jupyter notebookA 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.