{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Different ways to load an input graph\n", "\n", "We recommend using the GML graph format to load a graph. You can also use the DOT format, which requires additional dependencies (either pydot or pygraphviz). \n", "\n", "DoWhy supports both loading a graph as a string, or as a file (with the extensions 'gml' or 'dot').\n", "\n", "Below is an example showing the different ways of loading the same graph. " ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import os, sys\n", "import random\n", "sys.path.append(os.path.abspath(\"../../../\"))" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import pandas as pd\n", "\n", "import dowhy\n", "from dowhy import CausalModel\n", "from IPython.display import Image, display" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## I. Generating dummy data\n", "We generate some dummy data for three variables: X, Y and Z. " ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | Z | \n", "X | \n", "Y | \n", "
---|---|---|---|
0 | \n", "0 | \n", "0 | \n", "0 | \n", "
1 | \n", "7 | \n", "1 | \n", "10 | \n", "
2 | \n", "8 | \n", "2 | \n", "20 | \n", "
3 | \n", "6 | \n", "3 | \n", "30 | \n", "
4 | \n", "5 | \n", "4 | \n", "40 | \n", "
5 | \n", "3 | \n", "5 | \n", "50 | \n", "
6 | \n", "9 | \n", "6 | \n", "60 | \n", "
7 | \n", "2 | \n", "7 | \n", "70 | \n", "
8 | \n", "1 | \n", "8 | \n", "80 | \n", "
9 | \n", "4 | \n", "9 | \n", "90 | \n", "