Example Notebooks#

Explore our collection of example Jupyter notebooks. These demos provide practical, hands-on examples to help you understand and apply RelationalAI’s powerful features to your own data problems.

For instructions on how to run these notebooks, see the Instructions section below.

Getting Started#

Notebook Preview Download
Simple Start Snowflake Notebook
Simple Start

Domain Examples#

Complete examples of practical use-cases.

Notebook Preview Download
Community Detection (TastyBytes)
Anti-Money-Laundering
Data Harmonization
Understanding User Behavior
Traversing Decision Trees
Fraud Detection
Entity Resolution
Login Sharing
Track and Trace

Graph Algorithms#

Concise examples, each showcasing a specific graph algorithm.

Notebook Preview Download
Betweenness Centrality
Degree, In-degree, and Out-degree
Degree Centrality
Eigenvector Centrality
Infomap
Jaccard Similarity
Label Propagation
Louvain
PageRank
Triangle Community
Weakly Connected Components

Instructions#

To run one of the notebooks above, follow the steps below.

Install Python and the relationalai package#

Follow the steps for your operating system to install Python and the relationalai package.

NOTE

The relationalai Python package requires Python 3.9, 3.10, or 3.11. If you have an existing compatible Python installation, skip to the last step below.

  1. Navigate to the Python 3.11 download page, scroll down to the Files section, and download the macOS 64-bit universal2 installer.

  2. Open the installer and follow the prompts to install Python 3.11. Use the default installation options. When the installation is complete, double click the Install Certificates command in the Finder window.

  3. Open a terminal and verify that Python 3.11 is installed by running:

    #python3.11 --version
    

    The output should be similar to Python 3.11.9.

  4. Create a new project directory and virtual environment and use pip to install the relationalai package:

    #mkdir rai-getting-started && cd rai-getting-started
    
    # Replace `python3.11` with `python3.9` or `python3.10`
    # if you're using a different version.
    python3.11 -m venv .venv  # Create a virtual environment.
    source .venv/bin/activate  # Activate the virtual environment.
    
    python -m pip install relationalai
    

    Activating your virtual environment adds .venv/bin to your PATH, so you can use its Python executable as python.

    TIP

    Activate your virtual environment each time you open a new terminal to use the correct Python version and access the relationalai package.

Configure your project#

Run rai init to connect to your Snowflake account and configure your project:

#rai init

Follow the interactive prompts to enter your Snowflake credentials and choose the:

IMPORTANT

rai init saves your model’s configuration to a file named raiconfig.toml in the current directory. This file contains sensitive information, so be sure to exclude it from version control!

Install Jupyter and run the notebook#

  1. After running the steps above to create and activate a virtual environment, run the following to install Jupyter and to trust the notebook file. Trusting the file enables the graph visualizations to display when the notebook is opened.
    #python -m pip install jupyter
    jupyter trust *.ipynb
    
  2. Start a Jupyter server. This will open a browser window with the Jupyter Lab interface:
    #jupyter lab
    
  3. Open the notebook file in Jupyter Lab and run the cells. If the data for the example has not already been loaded in your Snowflake account, you’ll need to go to the Appendix and run the data-loading operations before running the main cells.