Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementation to calculate conditional independencies #29

Merged
merged 100 commits into from
Mar 10, 2021
Merged
Changes from 1 commit
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
dd48578
Add outline of calculate conditional independencies
cthoyt Jan 22, 2021
919c1d1
Merge branch 'main' into calculate-conditional-independencies
cthoyt Jan 22, 2021
0ccf0df
Merge branch 'main' into calculate-conditional-independencies
cthoyt Jan 22, 2021
0aa3a27
Merge branch 'main' into calculate-conditional-independencies
cthoyt Feb 2, 2021
309ab7d
Potential path for falsification
JosephCottam Feb 15, 2021
6037ebe
First draft that looks at given-variables. Needs work still.
JosephCottam Feb 22, 2021
f1cc89a
Able to test condtional independence with givens.
JosephCottam Feb 23, 2021
5967c9e
Move falsification into a module, made some unit tests
JosephCottam Feb 23, 2021
467798c
Using ADMG for falsification
JosephCottam Feb 23, 2021
fdcf0f7
Draw method added to mixed graph
JosephCottam Feb 23, 2021
3826c83
Merge branch 'main' into calculate-conditional-independencies
cthoyt Feb 23, 2021
9f1a019
Clean up tests
cthoyt Feb 23, 2021
3330ae4
Remove redundant definition
cthoyt Feb 23, 2021
8a4b209
Remove mutable default value
cthoyt Feb 23, 2021
2bcc2ce
Use top-level import of tqdm
cthoyt Feb 23, 2021
32e7bb2
Flake8 (mostly) compliance.
JosephCottam Feb 23, 2021
d86143a
Moved d-separation test graph to examples
JosephCottam Feb 23, 2021
4f37aa3
Notes on next steps.
JosephCottam Feb 23, 2021
ac1b0d1
Add title to draw function
cthoyt Feb 23, 2021
7c4bf9f
Automatically look up current axis
cthoyt Feb 23, 2021
4baf384
Fix import order
cthoyt Feb 23, 2021
3b42b34
Make classes for results reusable
cthoyt Feb 23, 2021
43fc539
Rename module to follow pep8
cthoyt Feb 23, 2021
6a9959a
Code style updates
cthoyt Feb 23, 2021
5300849
More flake8 and style
cthoyt Feb 23, 2021
1db9e86
Extract code for getting augments
cthoyt Feb 23, 2021
f9f2a61
Update falsification.py
cthoyt Feb 23, 2021
44424d6
Simplify and document more code
cthoyt Feb 23, 2021
5ebf0c6
Modified coloring to emphasize line (instead of column)
JosephCottam Feb 24, 2021
6319448
Added more compact repr for conditional independencies
JosephCottam Feb 24, 2021
a962b03
Adding conditional independences for d-separation example graph, calc…
JosephCottam Feb 24, 2021
eae5061
*Draft* at conditional independencies generation (known to report too…
JosephCottam Feb 24, 2021
921692d
More compact error messages for conditional independence test failures.
JosephCottam Feb 24, 2021
6097379
Make matplotlib dependency more optional
cthoyt Feb 24, 2021
8e1f106
Update docstring
cthoyt Feb 24, 2021
0b4e7e0
Normalize repr
cthoyt Feb 24, 2021
4cdee76
Fix kwarg
cthoyt Feb 24, 2021
3b92f51
Removing todo (was done in an earlier commit)
JosephCottam Feb 26, 2021
2ffef82
Added acencestor-style toplogocial restriction. Not sufficient to ge…
JosephCottam Feb 26, 2021
9bcf2de
Reverting to domain-semantic name
JosephCottam Feb 26, 2021
32682fd
Error messages that scale to the size of the extra info.
JosephCottam Feb 26, 2021
ee582dc
Added path restriction conditional independency.
JosephCottam Mar 1, 2021
eed5a36
Possible path outlined for fewer redundant CIs
JosephCottam Mar 2, 2021
ee1ed6b
Adding missed conditional independency
JosephCottam Mar 3, 2021
8a87862
Removing minimization from ConditionalIndependency, moving to the ite…
JosephCottam Mar 3, 2021
9a10b65
Ignoring multi-line statements
JosephCottam Mar 3, 2021
4f6597f
flake8 compliance progress
JosephCottam Mar 3, 2021
93ba53c
Conditional Independency test only checks the left/right members.
JosephCottam Mar 3, 2021
cc1b570
Correcting expected independencies as per causalfusion.
JosephCottam Mar 3, 2021
307aca0
Test checks that conditional independency set is valid.
JosephCottam Mar 3, 2021
e7be0e8
Generalized policy argument so length of givens list doesn't have to …
JosephCottam Mar 3, 2021
93f35d4
Renamed methods and added documentation
JosephCottam Mar 4, 2021
c404145
Falsification example working! (again)
JosephCottam Mar 4, 2021
310276c
Adding Holm–Bonferroni multiple-comparisons correction to falsification
JosephCottam Mar 4, 2021
08eb955
Removed references to dsl.Variable from ConditionalIndependency and F…
JosephCottam Mar 5, 2021
fc2d652
Merged DSeparation and ConditionalIndependency
JosephCottam Mar 5, 2021
cbe7cd2
Removed DSeparationJudgement context object due to dubious utility
JosephCottam Mar 5, 2021
227892c
Formatting for flake8
JosephCottam Mar 5, 2021
1156b24
Documentation notes
JosephCottam Mar 5, 2021
14b2b87
Update identifiability 2 example
cthoyt Mar 6, 2021
e97613e
Pass mypy
cthoyt Mar 6, 2021
da1433c
Update names in tests
cthoyt Mar 6, 2021
fa9101f
Remove unnecessary changes in flake8
cthoyt Mar 6, 2021
a978bd1
More code reorganization for clarity and readability
cthoyt Mar 6, 2021
95441cd
Update .flake8
cthoyt Mar 6, 2021
a827c77
Update type checking of graphs
cthoyt Mar 6, 2021
a332a06
Reorganize tests
cthoyt Mar 6, 2021
0ca1707
Fixed example 2 graph.
JosephCottam Mar 9, 2021
66e43af
Added topological policy
JosephCottam Mar 9, 2021
5ec3c5a
Testing that all the references samples are covered (still need to ch…
JosephCottam Mar 9, 2021
b53555d
Moved powerset utility to the utils package
JosephCottam Mar 9, 2021
2f80c9e
Testing that found conditional independencies are at least as good as…
JosephCottam Mar 9, 2021
8583e56
Testing additional d-separations
JosephCottam Mar 9, 2021
7ba7ea8
Removing extra conditions on d-separations
JosephCottam Mar 9, 2021
67f63f0
Documentation
JosephCottam Mar 9, 2021
23481de
Only returns FIRST left/right/conditions set from the d-separation it…
JosephCottam Mar 9, 2021
a805f3d
Documentation clarification and tests for moral_links step of d-separ…
JosephCottam Mar 9, 2021
96a4d71
Falsification updated for ConditionalIndependence/DSeparationJudgemen…
JosephCottam Mar 9, 2021
f9e4c48
Documentation & test cases
JosephCottam Mar 9, 2021
9a5eefd
Reparameterized to reflect opitional arguments better.
JosephCottam Mar 9, 2021
f84736f
Testing alternative interface
JosephCottam Mar 9, 2021
b69b217
Documentation for utilities
JosephCottam Mar 9, 2021
dccf552
Fixing (some) flake8 issues
JosephCottam Mar 9, 2021
44ae458
Flake8 formatting compliance.
JosephCottam Mar 9, 2021
967becb
More flake8 formatting compliance.
JosephCottam Mar 9, 2021
add8226
More flake8 formatting compliance.
JosephCottam Mar 9, 2021
c4b8397
Fix usage of backslashes
cthoyt Mar 9, 2021
2a2a5db
Update falsification.py
cthoyt Mar 9, 2021
a85262b
Make it possible to use custom policy
cthoyt Mar 9, 2021
bb6e91a
Fix typos
cthoyt Mar 9, 2021
8088b39
Simplify code
cthoyt Mar 9, 2021
45ac906
Text updates
cthoyt Mar 9, 2021
f57b33a
Make pipe action its own function
cthoyt Mar 9, 2021
39b5afd
More simple data loading
cthoyt Mar 9, 2021
4fb5311
Fixing falsification tests by propertly loading example data
JosephCottam Mar 10, 2021
5e2e491
Generalizing parameters
JosephCottam Mar 10, 2021
a96520c
Ignoring jupyter temporaries and simplified report format
JosephCottam Mar 10, 2021
fa39951
More flake8 formatting compliance.
JosephCottam Mar 10, 2021
154e43d
Add type annotation
cthoyt Mar 10, 2021
ec5adf8
Update code style in tests
cthoyt Mar 10, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 4 additions & 12 deletions src/y0/algorithm/falsification.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from collections import abc
from itertools import combinations, chain

from tqdm import tqdm
import copy

def are_d_separated(G, a,b, *, given=None):
Expand Down Expand Up @@ -90,24 +90,16 @@ def __init__(self, failures, evidence):
def __getitem__(self, i): return self._failures[i]
def __len__(self): return len(self._failures)
def __repr__(self): return repr(self._failures) + "+evidence"

wrapper = lambda v, desc: v
if verbose:
try:
import tqdm
wrapper = tqdm.tqdm
except:
print("TQDM not installed, verbose mode not supported")


all_nodes = set(G.vertices)
all_pairs = combinations(all_nodes, 2)

to_test = [(a, b, given) for a,b in wrapper(all_pairs, desc="Checking d-separation")
to_test = [(a, b, given) for a,b in tqdm(all_pairs, desc="Checking d-separation")
cthoyt marked this conversation as resolved.
Show resolved Hide resolved
for given in all_combinations(all_nodes-{a,b}, max=max_given)
if are_d_separated(G, a, b, given=given)]

variances = {(a,b, given): CITests.cressie_read(a, b, given, df, boolean=False)
for a, b, given in wrapper(to_test, desc="Checking conditionals")}
for a, b, given in tqdm(to_test, desc="Checking conditionals")}

#TODO: Multiple-comparisons correction
evidence = pd.DataFrame([(a, b, given, chi, p, dof)
Expand Down