causalnex icon indicating copy to clipboard operation
causalnex copied to clipboard

from_pandas() has no attribute use_gpu

Open cm2435 opened this issue 3 years ago • 2 comments

Description

Hello! Big fan of the package, trying to make use of it for a causal structure learning problem at the moment. The pandas df has around approx 90 columns and a couple hundred rows. Using notears to learn the dag structure is proving prohibitively slow so I wanted to make use of my GPU to train the model.

However, there is an error I encounter the error in the stack trace below

      1 from causalnex.structure.notears import from_pandas
      2 
----> 3 sm = from_pandas(structure_df_fast, use_gpu = True)
      4 from_pandas()

TypeError: from_pandas() got an unexpected keyword argument 'use_gpu'

This seems to not be correct since there is lots of mentions to this method in the repo discussions. Maybe I'm missing something important.

Environment-

python3.8
clean install using conda env with no other packages
causalnex version 0.11.0 installed with "pip install causalnex" 

System- Ubuntu Linux 21.04

Any help would be appreciated

cm2435 avatar Jan 04 '22 22:01 cm2435

It seems they should have merged the changes made mentioned in #114 . However, the change is not there in 0.11.0. I am a bit confused by it.

AIasd avatar Feb 11 '22 00:02 AIasd

@AIasd Reading through the enhancement it seems like it was merged to master then the 0.11.0 branch was deleted. However from what I can see there is is not GPU functions on main.

@qbphilip @oentaryorj Would there be any interest by the maintainers if I was to contribute a new module to the package that does GPU enabled structure learning?

Perhaps an implimentation of https://arxiv.org/abs/1911.00081 or https://arxiv.org/abs/2010.09133 (using TF or torch) may be in order?

Either of those, or just a numba reimplimentation of the from_pandas() method would work also.

cm2435 avatar Feb 11 '22 17:02 cm2435

Hi @AIasd, sure, thank you. Contributions on a new module for NO-BEAR/NO-FEAR structural learning would be great.

oentaryorj avatar Aug 25 '22 13:08 oentaryorj

Hi @cm2435, my understanding is that the GPU function is only available in the PyTorch implementation. So you would need to import the PyTorch implementation instead:

from causalnex.structure.notears.pytorch import from_pandas

The latest develop branch should also include this fix on the DAGLayer - https://github.com/quantumblacklabs/causalnex/pull/135

@AIasd - We would definitely appreciate if the community can contribute to enhanced algorithms such as NO-BEAR or NO-FEAR, but this is a bigger topic that should be discussed in a separate issue/ticket.

So we'll close this ticket for now. Feel free to raise another issue to discuss about the enhancements

oentaryorj avatar Sep 01 '22 03:09 oentaryorj

from causalnex.structure.notears import from_pandas
from causalnex.structure.pytorch.notears import from_pandas as from_pandas_pytorch

blacksnail789521 avatar Jul 31 '23 09:07 blacksnail789521