Giter Club home page Giter Club logo

Comments (7)

Diviyan-Kalainathan avatar Diviyan-Kalainathan commented on May 14, 2024

Hi,
It seems like your pytorch version is not 0.4. Could you update it and try again?
Best,
Diviyan

from causaldiscoverytoolbox.

snowde avatar snowde commented on May 14, 2024

Awesome, that sorted the first one out! On the next tab, I have this issue.

Thanks for taking the time.

# Orient the edges of the graph
from cdt.causality.graph import CGNN
Cgnn = CGNN()
start_time = time.time()
dgraph = Cgnn.predict(data, graph=ugraph, nb_runs=12, nb_max_runs=20, train_epochs=1500, test_epochs=1000)
print("--- Execution time : %4.4s seconds ---" % (time.time() - start_time))

# Plot the output graph
nx.draw_networkx(dgraph, font_size=8) # The plot function allows for quick visualization of the graph.
plt.show()
# Print output results : 
pd.DataFrame(list(dgraph.edges(data='weight')), columns=['Cause', 'Effect', 'Score'])

The pairwise GNN model is computed on each edge of the UMG to initialize the model and start CGNN with a DAG

TypeError Traceback (most recent call last)
in ()
3 Cgnn = CGNN()
4 start_time = time.time()
----> 5 dgraph = Cgnn.predict(data, graph=ugraph, nb_runs=12, nb_max_runs=20, train_epochs=1500, test_epochs=1000)
6 print("--- Execution time : %4.4s seconds ---" % (time.time() - start_time))
7

~/anaconda/envs/py36/lib/python3.6/site-packages/cdt/causality/graph/model.py in predict(self, df_data, graph, **kwargs)
31 return self.orient_directed_graph(df_data, graph, **kwargs)
32 elif type(graph) == nx.Graph:
---> 33 return self.orient_undirected_graph(df_data, graph, **kwargs)
34 else:
35 print('Unknown Graph type')

~/anaconda/envs/py36/lib/python3.6/site-packages/cdt/causality/graph/CGNN.py in orient_undirected_graph(self, data, umg, nh, nb_runs, nb_jobs, gpu, lr, train_epochs, test_epochs, verbose, nb_max_runs)
257 og = gnn.orient_graph(data, umg, nb_runs=nb_runs, nb_max_runs=nb_max_runs,
258 nb_jobs=nb_jobs, train_epochs=train_epochs,
--> 259 test_epochs=test_epochs, verbose=verbose, gpu=gpu) # Pairwise method
260 # print(nx.adj_matrix(og).todense().shape)
261

~/anaconda/envs/py36/lib/python3.6/site-packages/cdt/causality/pairwise/model.py in orient_graph(self, df_data, graph, printout, nb_runs, **kwargs)
91
92 elif type(graph) == nx.Graph:
---> 93 edges = list(graph.edges)
94 output = nx.DiGraph()
95

TypeError: 'method' object is not iterable

from causaldiscoverytoolbox.

Diviyan-Kalainathan avatar Diviyan-Kalainathan commented on May 14, 2024

Oh yes, I had this bug corrected, could you update your toolbox to master?
Best,
Diviyan

from causaldiscoverytoolbox.

snowde avatar snowde commented on May 14, 2024

Sorry I got one problem after the update. - Running the same code.

The pairwise GNN model is computed on each edge of the UMG to initialize the model and start CGNN with a DAG

AttributeError Traceback (most recent call last)
in ()
3 Cgnn = CGNN()
4 start_time = time.time()
----> 5 dgraph = Cgnn.predict(data, graph=ugraph, nb_runs=5, nb_max_runs=6, train_epochs=15, test_epochs=8)
6 print("--- Execution time : %4.4s seconds ---" % (time.time() - start_time))
7

/Volumes/extra/FirmAI/Causal Inference/CausalDiscoveryToolbox-master/examples/cdt/causality/graph/model.py in predict(self, df_data, graph, **kwargs)
31 return self.orient_directed_graph(df_data, graph, **kwargs)
32 elif type(graph) == nx.Graph:
---> 33 return self.orient_undirected_graph(df_data, graph, **kwargs)
34 else:
35 print('Unknown Graph type')

/Volumes/extra/FirmAI/Causal Inference/CausalDiscoveryToolbox-master/examples/cdt/causality/graph/CGNN.py in orient_undirected_graph(self, data, umg, nh, nb_runs, nb_jobs, gpu, lr, train_epochs, test_epochs, verbose, nb_max_runs)
269 # print(nx.adj_matrix(og).todense().shape)
270 # print(list(og.edges()))
--> 271 dag = dagify_min_edge(og)
272 # print(nx.adj_matrix(dag).todense().shape)
273

/Volumes/extra/FirmAI/Causal Inference/CausalDiscoveryToolbox-master/examples/cdt/utils/graph_utils.py in dagify_min_edge(g)
14 """
15 while not nx.is_directed_acyclic_graph(g):
---> 16 cycle = nx.simple_cycles(g).next()
17 scores = []
18 edges = []

AttributeError: 'generator' object has no attribute 'next'

from causaldiscoverytoolbox.

snowde avatar snowde commented on May 14, 2024

It might be a python 3 thing, I will jsut change it locally. Thank, one last question - more personal - would you recommend any packages for automated causal effects from observational data after I have done the casual discovery? I have had a look at the following, https://github.com/laurencium/Causalinference, and https://github.com/akelleh/causality. If you are unsure then please just ignore the question, thanks so much for your help :)

from causaldiscoverytoolbox.

Diviyan-Kalainathan avatar Diviyan-Kalainathan commented on May 14, 2024

Hi again, glad that some errors are sorted out. Please keep me updated about the generator error.
Concerning causal inference, I've got no great experience in python packages. You could look into the "IDA" algorithm (implemented in the pcalg R package).

We plan to bring tools for causal effect evaluation in this toolbox, but it will be at a later date =)
Best,
Diviyan

from causaldiscoverytoolbox.

Diviyan-Kalainathan avatar Diviyan-Kalainathan commented on May 14, 2024

I'll be closing this issue, don't hesitate to open it if a bug pops again.
Best,
Diviyan

from causaldiscoverytoolbox.

Related Issues (20)

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.