Skip to content

nstepka/Causal-Inference-and-Discovery-in-Python

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Causal Inference and Discovery in Python

Causal Inference and Discovery in Python

This is the code repository for Causal Inference and Discovery in Python, published by Packt.

Unlock the secrets of modern causal machine learning with DoWhy, EconML, PyTorch and more

What is this book about?

Causal methods present unique challenges compared to traditional machine learning and statistics. Learning causality can be challenging, but it offers distinct advantages that elude a purely statistical mindset. Causal Inference and Discovery in Python helps you unlock the potential of causality.

You’ll start with basic motivations behind causal thinking and a comprehensive introduction to Pearlian causal concepts, such as structural causal models, interventions, counterfactuals, and more. Each concept is accompanied by a theoretical explanation and a set of practical exercises with Python code.

Next, you’ll dive into the world of causal effect estimation, consistently progressing towards modern machine learning methods. Step-by-step, you’ll discover Python causal ecosystem and harness the power of cutting-edge algorithms. You’ll further explore the mechanics of how “causes leave traces” and compare the main families of causal discovery algorithms.

The final chapter gives you a broad outlook into the future of causal AI where we examine challenges and opportunities and provide you with a comprehensive list of resources to learn more.

This book covers the following exciting features:

  • Master the fundamental concepts of causal inference
  • Decipher the mysteries of structural causal models
  • Unleash the power of the 4-step causal inference process in Python
  • Explore advanced uplift modeling techniques
  • Unlock the secrets of modern causal discovery using Python
  • Use causal inference for social impact and community benefit

If you feel this book is for you, get your copy today!

Instructions and Navigations

All of the code is organized into folders.

The code will look like the following:

preds = causal_bert.inference(
    texts=df['text'],
    confounds=df['has_photo'],
)[0]

Following is what you need for this book:

This book is for machine learning engineers, data scientists, and machine learning researchers looking to extend their data science toolkit and explore causal machine learning. It will also help developers familiar with causality who have worked in another technology and want to switch to Python, and data scientists with a history of working with traditional causality who want to learn causal machine learning. It’s also a must-read for tech-savvy entrepreneurs looking to build a competitive edge for their products and go beyond the limitations of traditional machine learning.

With the following software and hardware list you can run all code files present in the book (Chapter 1-15).

Software and Hardware List

Chapter Software required OS required
1-15 Python 3.9 Windows macOS, or Linux
1-15 DoWhy 0.8 Windows, macOS, or Linux
1-15 EconML 0.12.0 Windows, macOS, or Linux
1-15 CATENets 0.2.3 Windows, macOS, or Linux
1-15 gCastle 1.0.3 Windows, macOS, or Linux
1-15 Causica 0.2.0 Windows, macOS, or Linux
1-15 Causal-learn 0.1.3.3 Windows, macOS, or Linux
1-15 Transformers 4.24.0 Windows, macOS, or Linux

Related products

Get to Know the Author

Aleksander Molak is a Machine Learning Researcher and Consultant who gained experience working with Fortune 100, Fortune 500, and Inc. 5000 companies across Europe, the USA, and Israel, designing and building large-scale machine learning systems. On a mission to democratize causality for businesses and machine learning practitioners, Aleksander is a prolific writer, creator, and international speaker. As a co-founder of Lespire, an innovative provider of AI and machine learning training for corporate teams, Aleksander is committed to empowering businesses to harness the full potential of cutting-edge technologies that allow them to stay ahead of the curve.

Note from the Author:

Environment installation

To install the basic environment run: conda env create -f causal_book_py39_cuda117.yml

To install the environment for notebook Chapter_11.2.ipynb run: conda create -f causal-pymc.yml

Selecting the kernel

After a successful installation of the environment, open your notebook and select the kernel causal_book_py39_cuda117

For notebook Chapter_11.2.ipynb change kernel to causal-pymc

Using graphviz and GPU

Note: Depending on your system settings, you might need to install graphviz manually in order to recreate the graph plots in the code. Check https://pypi.org/project/graphviz/ for specific instructions specific to your operating system.

Note 2: To use GPU you'll need to install CUDA 11.7 drivers. This can be done here: https://developer.nvidia.com/cuda-11-7-0-download-archive

‼️ Known mistakes // errata

For known errors and corrections check:

If you spotted a mistake, let us know at book(at)causalpython.io or just open an issue in this repo. Thank you 🙏🏼

About

Causal Inference and Discovery in Python by Packt Publishing

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Jupyter Notebook 99.8%
  • Python 0.2%