Comments (7)
Hi,
It seems like your pytorch version is not 0.4. Could you update it and try again?
Best,
Diviyan
from causaldiscoverytoolbox.
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.
Oh yes, I had this bug corrected, could you update your toolbox to master?
Best,
Diviyan
from causaldiscoverytoolbox.
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.
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.
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.
I'll be closing this issue, don't hesitate to open it if a bug pops again.
Best,
Diviyan
from causaldiscoverytoolbox.
Related Issues (20)
- SID and SHD do not get the same results as the author of SID HOT 3
- SID error HOT 1
- Is it possible to insert prior knowledge before the causal graph creation? HOT 3
- [BUG] CGNN (Causal Graph Generation) + Usage of multiprocessing with pytorch HOT 1
- R Package (k)pcalg/RCIT is not available. RCIT has to be installed from https://github.com/Diviyan-Kalainathan/RCIT HOT 6
- [BUG] cdt.data.load_dataset('sachs') + one of the returned objects, 'target', is inconsistent with the paper(Sachs,etc 2005) HOT 1
- [fileNotFoundError: [Errno 2]] cdt.causality.graph.LiNGAM + No such file or directory: 'C:\\anaconda\\lib\\site-packages\\cdt\\utils\\R_templates\\test_import.R' HOT 1
- GIES targets and target.index parameter needs to be exposed HOT 2
- [BUG] orient_graph removes some of the edges
- [Question] What does the causal score in the pairwise model really indicate?
- ImportError: R Package (k)pcalg/RCIT is not available. HOT 3
- [BUG] CGNN run() Wrong way to calculate the score HOT 1
- FloatingPointError: The system is too ill-conditioned for this solver. The system is too ill-conditioned for this solver HOT 1
- Help! HOT 1
- Can PC algorithm be used for causal discovery under mixed types of data๏ผ
- ImportError: R Package pcalg is not available
- [BUG] autoset_settings() fails with MIG GPU
- CCDr algorithm execution error
- CCDr Algorithm + estimate.dag in R Script, Error in weights HOT 3
- CGNN running time is too long
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from causaldiscoverytoolbox.