Code Monkey home page Code Monkey logo

causal-inference-and-discovery-in-python's People

Contributors

alxndrmlk avatar packt-itservice avatar rahul-packt avatar tazeenpackt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

causal-inference-and-discovery-in-python's Issues

Environment for M1 Silicon

Hi Alex,

Please find below an environment file that successfully runs GPU related codes in Chapters 11.1 and 14 (as .txt as it won't accept yml - should just be able to change the extension back)
causal_book_py39_for_m1.txt. The changes from the yml provided in your repo are:

  • remove - nvidia from channels; remove - pytorch and -pytorch-cuda=11.7 from dependencies
  • add - notebook=6.5 to dependencies

Then replace the set device cell with

# Set device
device = "mps" if torch.backends.mps.is_available() else "cpu"

I still then had to pip install CausalPy once the env was activated.

The full yml as exported by conda is
causal_book_py39_applem1.txt

Notes:

  • This has only been tested to run on notebooks 11.1 and 14 but I did not closely monitor whether the results were the same. I'm only assuming at this point it should run fine on the other chapters
  • In notebook 14, "Expert knowledge" section, in the cell after the one with augmented Lagrangian loss objects (first line assert len(dataset_train.batch_size) == 1, "Only 1D batch size is supported"), an errors occurs with message "NotImplementedError: The operator 'aten::triu_indices' is not currently implemented for the MPS device. If you want this op to be added in priority during the prototype phase of this feature, please comment on https://github.com/pytorch/pytorch/issues/77764. As a temporary fix, you can set the environment variable PYTORCH_ENABLE_MPS_FALLBACK=1 to use the CPU as a fallback for this op. WARNING: this will be slower than running natively on MPS."

Dowhy CausalModel does not have 'causal_estimator' attribute

Both chapter 9 and chapter 10 notebooks have code like effect_pred = model.causal_estimator.effect().
I got an error running them: AttributeError: 'CausalModel' object has no attribute 'causal_estimator'

The book states that it uses DoWhy 0.8 but I am currently using DoWhy 0.10.1 (just want to keep my learning experience up-to-date) but I cannot determine if that's the cause of it. If it is, then how to implement the model on test dataset with current version of DoWhy? If not, then what have I missed?

Thanks!

Small errata for p27 of book (post-June 2023)

Loving that these resources are on GitHub - thank you @AlxndrMlk!

Quick notational suggestion: on p27, the line $X_{sample} = 1.9 < X < -1.9$ doesn't make sense at the moment.
The right-side reads as a boolean, and the condition can never be satisfied, as written.

Would be clearer what's meant if it was "...sampled according to the condition $X < - 1.9$ or $X > 1.9$".

[Chapter9] Causal_estimator.effect for prediction

Hello, I am Jake Lee from Korea, a passionate reader of your book

I have found that couple of codes not working for prediction part in Ch09.
Your code flow as following

  1. Instantiate Causal model
  2. Estimand
  3. Estimate
  4. Predict test data using .causal_estimator.effect

However #4 is not working from my side (description said there is no object of causal_estimator)
It would be appreciate if you give me help on it, especially in case that code is running in latest DoWhy version (11.0)

Thanks in advance!
Jake

Notebook 13 np.np typo

Screenshot 2023-12-26 at 11 21 30โ€ฏPM

Notebook 13 seems to have a typo of np.np.tril, which causes an error. Changing to np.tril resolves this error.

Chapter 7 notebook array shape error messages

Possibly related to the numba deprecation warning , the following code spits out an array shape error, which then propogates errors in the remaining cells in the chapter 7 notebook. I tried upgrading shap to 0.42.0 which resolved some but not all of the errors.

`estimate = model.estimate_effect(
identified_estimand=estimand,
method_name='backdoor.econml.dml.DML',
method_params={
'init_params': {
'model_y': GradientBoostingRegressor(),
'model_t': GradientBoostingRegressor(),
'model_final': LassoCV(fit_intercept=False),
},
'fit_params': {}}
)

print(f'Estimate of causal effect (DML): {estimate.value}')
`

A column-vector y was passed when a 1d array was expected. Please change the shape of y to (n_samples, ), for example using ravel().

Solving environment not completing

The command conda env create -f causal_book_py39_cuda117.yml never finishes. Tested on Windows and WSL. Anyone else encountering this issue? Found a solution?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.