Key Libraries:
causalvis for DAG visualisation = https://github.com/causalvis/causalvis (Guo, Grace, et al. "Causalvis: Visualizations for causal inference." Proceedings of the 2023 CHI conference on human factors in computing systems. 2023.)
causal-learn for PC Algorithm = https://github.com/py-why/causal-learn (Spirtes, P., Glymour, C. N., Scheines, R., & Heckerman, D. (2000). Causation, prediction, and search. MIT press.)
lingam for LiNGAM/LiM Algorithm = https://github.com/cdt15/lingam
DirectLiNGAM (S. Shimizu, T. Inazumi, Y. Sogawa, A. Hyvärinen, Y. Kawahara, T. Washio, P. O. Hoyer and K. Bollen. DirectLiNGAM: A direct method for learning a linear non-Gaussian structural equation model. Journal of Machine Learning Research, 12(Apr): 1225--1248, 2011.)
LiM (Zeng, Yan, et al. "Causal discovery for linear mixed data." Conference on Causal Learning and Reasoning. PMLR, 2022.)
scikit-learn for encoding, scaling and Logistic Regression = https://scikit-learn.org/stable/ (Kramer, Oliver, and Oliver Kramer. "Scikit-learn." Machine learning for evolution strategies (2016): 45-53.)
pydot for graph visualisation = https://pypi.org/project/pydot/
networkx for graph visualisation = https://networkx.org/documentation/stable/tutorial.html (Hagberg, Aric, and Drew Conway. "Networkx: Network analysis with python." URL: https://networkx. github. io (2020).)
To test DAG construction, outputs and ATE estimations open the relevant .ipynb modules in jupyter lab You will need to select which dataset to use when running algorithms/cohort_visualisation (adult, adult_small, student, student_small)
.ipynb mdodules
dag_construction = for manually creating DAGs to identify confounders, prognostics etc. returns a json file for cohort_visualisation PC_final, LiM_final, Direct_lingam_final = DAG construction using the selected algorithm module cohort_visualisation = perform matching, visualise cohorts and return ATE
.py modules
dag_utils = loads DAG representation from a JSON file data_preparation = prepares the datasets and returns 'processed' csvs to 'data' folder (details about processing decisions in thesis) evaluation = evaluates accuracy of an estimated graph by comparing it to the true graph and calculating the Structural Hamming Distance matching = performs propensity score matching to adjust for confounding variables and estimate the causal effect of a treatment plotting_utils = converts a graph from the causallearn library to a networkx graph, adds labels to the nodes, visualizes the graph using matplotlib replace_np_mat = replaces every instance of np.mat (with np.asmatrix) to address compatibility issues in the causallearn library true_graph = create and visualise true DAGs
.json files
All DAGs created with dag_construction. Resulting graphs are downloaded as .jsons and then imported into cohort_visualisation for matching/ATE estimation. These include DAGs created from the true_graph (small_adult_true_confounds, adult_true_confounds, small_student_true_confounds, student_true_confounds) and the DAGs generated by DirectLiNGAM with background knowledge (small_student_LiNGAM_with_bk, small_adult_lingam_bk)
.csv files (in data folder)
Those utilised by other modules are: processed_adult, processed_student, processed_adult_small, processed_student_small All other csvs contain the data prior to cleaning/enconding
pip list Package Version
anyio 4.4.0 argon2-cffi 23.1.0 argon2-cffi-bindings 21.2.0 arrow 1.3.0 asttokens 2.4.1 async-lru 2.0.4 attrs 23.2.0 Babel 2.15.0 beautifulsoup4 4.12.3 bleach 6.1.0 causal-learn 0.1.3.8 causallib 0.9.7 causalvis 0.1.0a0 certifi 2024.7.4 cffi 1.16.0 charset-normalizer 3.3.2 clarabel 0.9.0 colorama 0.4.6 comm 0.2.2 contourpy 1.2.1 cvxpy 1.5.2 cycler 0.12.1 Cython 3.0.10 debugpy 1.8.2 decorator 5.1.1 defusedxml 0.7.1 dowhy 0.11.1 ecos 2.0.14 exceptiongroup 1.2.2 executing 2.0.1 fastjsonschema 2.20.0 fonttools 4.53.1 fqdn 1.5.1 graphviz 0.20.3 h11 0.14.0 httpcore 1.0.5 httpx 0.27.0 idna 3.7 importlib_metadata 8.1.0 importlib_resources 6.4.0 ipykernel 6.29.5 ipython 8.18.1 ipywidgets 8.1.3 isoduration 20.11.0 jedi 0.19.1 Jinja2 3.1.4 joblib 1.4.2 json5 0.9.25 jsonpointer 3.0.0 jsonschema 4.23.0 jsonschema-specifications 2023.12.1 jupyter 1.0.0 jupyter_client 8.6.2 jupyter-console 6.6.3 jupyter_core 5.7.2 jupyter-events 0.10.0 jupyter-lsp 2.2.5 jupyter_server 2.14.2 jupyter_server_terminals 0.5.3 jupyterlab 4.2.4 jupyterlab_pygments 0.3.0 jupyterlab_server 2.27.3 jupyterlab_widgets 3.0.11 kiwisolver 1.4.5 lingam 1.9.0 MarkupSafe 2.1.5 matplotlib 3.9.1 matplotlib-inline 0.1.7 mistune 3.0.2 mpmath 1.3.0 nbclient 0.10.0 nbconvert 7.16.4 nbformat 5.10.4 nest-asyncio 1.6.0 networkx 3.2.1 notebook 7.2.1 notebook_shim 0.2.4 numdifftools 0.9.41 numpy 1.26.4 osqp 0.6.7.post1 overrides 7.7.0 packaging 24.1 pandas 2.2.2 pandocfilters 1.5.1 parso 0.8.4 patsy 0.5.6 pillow 10.4.0 pip 24.1.2 platformdirs 4.2.2 progressbar2 4.4.2 prometheus_client 0.20.0 prompt_toolkit 3.0.47 psutil 6.0.0 psy 0.0.1 pure_eval 0.2.3 pycparser 2.22 pydot 3.0.1 pydotplus 2.0.2 pygam 0.9.1 Pygments 2.18.0 pyparsing 3.1.2 python-dateutil 2.9.0.post0 python-json-logger 2.0.7 python-utils 3.8.2 pytz 2024.1 pywin32 306 pywinpty 2.0.13 PyYAML 6.0.1 pyzmq 26.0.3 qdldl 0.1.7.post4 qtconsole 5.5.2 QtPy 2.4.1 referencing 0.35.1 requests 2.32.3 rfc3339-validator 0.1.4 rfc3986-validator 0.1.1 rpds-py 0.19.0 scikit-learn 1.5.1 scipy 1.11.4 scs 3.2.6 semopy 2.3.11 Send2Trash 1.8.3 setuptools 71.1.0 six 1.16.0 sniffio 1.3.1 soupsieve 2.5 stack-data 0.6.3 statsmodels 0.14.2 sympy 1.13.1 terminado 0.18.1 threadpoolctl 3.5.0 tinycss2 1.3.0 tomli 2.0.1 tornado 6.4.1 tqdm 4.66.4 traitlets 5.14.3 types-python-dateutil 2.9.0.20240316 typing_extensions 4.12.2 tzdata 2024.1 uri-template 1.3.0 urllib3 2.2.2 wcwidth 0.2.13 webcolors 24.6.0 webencodings 0.5.1 websocket-client 1.8.0 widgetsnbextension 4.0.11 zipp 3.19.2