From 5f106c97149f344328eb347bb19d78c90f8c5d7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Quintas-Mart=C3=ADnez?= Date: Fri, 17 May 2024 11:04:04 -0400 Subject: [PATCH] Cleanup imports, remove sns from example notebook --- .../gcm_cps2015_dist_change_robust.ipynb | 31 +++---------------- 1 file changed, 4 insertions(+), 27 deletions(-) diff --git a/docs/source/example_notebooks/gcm_cps2015_dist_change_robust.ipynb b/docs/source/example_notebooks/gcm_cps2015_dist_change_robust.ipynb index bd79e5631c..9267b15231 100644 --- a/docs/source/example_notebooks/gcm_cps2015_dist_change_robust.ipynb +++ b/docs/source/example_notebooks/gcm_cps2015_dist_change_robust.ipynb @@ -1,30 +1,5 @@ { "cells": [ - { - "cell_type": "code", - "execution_count": null, - "id": "b7dab0bd", - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "import numpy as np\n", - "import networkx as nx\n", - "import matplotlib.pyplot as plt\n", - "import seaborn as sns\n", - "from lightgbm import LGBMClassifier, LGBMRegressor\n", - "from scipy.stats import norm\n", - "from sklearn.isotonic import IsotonicRegression\n", - "from sklearn.model_selection import train_test_split\n", - "from scipy.stats import sem\n", - "from statsmodels.stats.weightstats import DescrStatsW\n", - "from pickle import dump, load\n", - "from itertools import compress, product\n", - "from math import comb\n", - "import dowhy.gcm as gcm" - ] - }, { "cell_type": "markdown", "id": "b075c6f9-2474-449f-8191-a45d77b6d3f8", @@ -224,6 +199,7 @@ "import itertools\n", "from dowhy.gcm.distribution_change_robust import ThetaC\n", "import numpy as np\n", + "from math import comb\n", "\n", "# All combinations of 0s and 1s, needed for Shapley Values:\n", "all_combos = [list(i) for i in itertools.product([0, 1], repeat=3)]\n", @@ -335,6 +311,7 @@ "from scipy.stats import norm\n", "from statsmodels.stats.weightstats import DescrStatsW\n", "from matplotlib.patches import Rectangle\n", + "import matplotlib.pyplot as plt\n", "\n", "# Significance stars:\n", "def star(est, se):\n", @@ -389,7 +366,7 @@ "\n", "First, notice that the Shapley values for $P(\\mathtt{educ})$, $P(\\mathtt{occup} \\mid \\mathtt{educ})$ and $P(\\mathtt{wage} \\mid \\mathtt{occup}, \\mathtt{educ})$ add up to the total effect.\n", "\n", - "Second, the Shapley value for $P(\\mathtt{educ})$ is positive and statistically significant. One way to interpret this measure is that, if men and women differed only in their $P(\\mathtt{educ})$ (but their other causal mechanisms were the same), women would earn \\\\$1.22/hour more than men on average. Conversely, the Shapley value for $P(\\mathtt{educ} \\mid \\mathtt{educ})$ is negative, statistically significant and of approximately the same magnitude as the first Shapley value, hence cancelling out with the effect of differences in education. These effects measure two things:\n", + "Second, the Shapley value for $P(\\mathtt{educ})$ is positive and statistically significant. One way to interpret this measure is that, if men and women differed only in their $P(\\mathtt{educ})$ (but their other causal mechanisms were the same), women would earn \\\\$1.12/hour more than men on average. Conversely, the Shapley value for $P(\\mathtt{educ} \\mid \\mathtt{educ})$ is negative, statistically significant and of slightly larger magnitude as the first Shapley value, hence cancelling out with the effect of differences in education. These effects measure two things:\n", "1. How different is a causal mechanism between males and females?\n", "2. How important is a causal mechanism for the outcome?\n", "\n", @@ -453,7 +430,7 @@ "source": [ "Women with college degrees are more predominant in administrative, education or healthcare occupations, whereas men with college degrees are more likely to work in management or sales. For comparison, managers earn \\\\$16.66/hour more than educators and \\\\$6.29/hour more than healthcare practitioners on average. \n", "\n", - "At the same time, however, there are large differences that cannot be explained by education or occupation. For example, female college graduate managers earn \\\\$14.84/hour less than their male counterparts." + "At the same time, however, there are large differences that cannot be explained by education or occupation. For example, female college graduate managers earn \\\\$13.77/hour less than their male counterparts." ] }, {