-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(API): updated documentation, overhauled API
BREAKING CHANGE: Total API overhaul for final (at this time) release
- Loading branch information
1 parent
274fa52
commit 43b0429
Showing
46 changed files
with
413 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Archive | ||
|
||
Contained here is some old code that built a (now-outdated) wiki that I don't have the heart to delete. | ||
|
||
Don't rely on it expecting accurate information. |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from pathlib import Path | ||
|
||
from do import API | ||
|
||
api = API() | ||
|
||
file = Path("pearl-3.4.yml") | ||
model = api.instantiate_model(file) | ||
|
||
backdoors = api.backdoors({"Xi"}, {"Xj"}, model.graph()) | ||
assert len(backdoors) > 0, "No backdoor paths detected!" | ||
assert not api.blocks({"Xi"}, {"Xj"}, model.graph(), set()), "This should not block all paths!" | ||
|
||
for path in backdoors: | ||
print("Path:", path) | ||
|
||
backdoors = api.backdoors({"Xi"}, {"Xj"}, model.graph(), {"X1", "X4"}) | ||
assert len(backdoors) == 0, "Expected this to block!" | ||
assert api.blocks({"Xi"}, {"Xj"}, model.graph(), {"X1", "X4"}), "This should block!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
name: 'Pearl: Figure 3.4' | ||
endogenous: | ||
X1: | ||
outcomes: | ||
- x1 | ||
- ~x1 | ||
parents: [] | ||
table: [ | ||
[x1, 0.4], | ||
[~x1, 0.6] | ||
] | ||
X2: | ||
outcomes: | ||
- x2 | ||
- ~x2 | ||
parents: [] | ||
table: [ | ||
[x2, 0.15], | ||
[~x2, 0.85] | ||
] | ||
X3: | ||
outcomes: | ||
- x3 | ||
- ~x3 | ||
parents: | ||
- X1 | ||
table: [ | ||
[x3, x1, 0.1], | ||
[x3, ~x1, 0.3], | ||
[~x3, x1, 0.9], | ||
[~x3, ~x1, 0.7] | ||
] | ||
X4: | ||
outcomes: | ||
- x4 | ||
- ~x4 | ||
parents: | ||
- X1 | ||
- X2 | ||
table: [ | ||
[x4, x1, x2, 0.7], | ||
[x4, x1, ~x2, 0.9], | ||
[x4, ~x1, x2, 0.55], | ||
[x4, ~x1, ~x2, 0.15], | ||
[~x4, x1, x2, 0.3], | ||
[~x4, x1, ~x2, 0.1], | ||
[~x4, ~x1, x2, 0.45], | ||
[~x4, ~x1, ~x2, 0.85] | ||
] | ||
X5: | ||
outcomes: | ||
- x5 | ||
- ~x5 | ||
parents: | ||
- X2 | ||
table: [ | ||
[x5, x2, 0.8], | ||
[x5, ~x2, 0.25], | ||
[~x5, x2, 0.2], | ||
[~x5, ~x2, 0.75] | ||
] | ||
X6: | ||
outcomes: | ||
- x6 | ||
- ~x6 | ||
parents: | ||
- Xi | ||
table: [ | ||
[x6, xi, 0.9], | ||
[x6, ~xi, 0.25], | ||
[~x6, xi, 0.1], | ||
[~x6, ~xi, 0.75] | ||
] | ||
Xi: | ||
outcomes: | ||
- xi | ||
- ~xi | ||
parents: | ||
- X3 | ||
- X4 | ||
table: [ | ||
[xi, x3, x4, 0.5], | ||
[xi, x3, ~x4, 0.65], | ||
[xi, ~x3, x4, 0.1], | ||
[xi, ~x3, ~x4, 0.25], | ||
[~xi, x3, x4, 0.5], | ||
[~xi, x3, ~x4, 0.35], | ||
[~xi, ~x3, x4, 0.9], | ||
[~xi, ~x3, ~x4, 0.75] | ||
] | ||
Xj: | ||
outcomes: | ||
- xj | ||
- ~xj | ||
parents: | ||
- X6 | ||
- X4 | ||
- X5 | ||
table: [ | ||
[xj, x6, x4, x5, 0.0], | ||
[xj, x6, x4, ~x5, 0.25], | ||
[xj, x6, ~x4, x5, 0.7], | ||
[xj, x6, ~x4, ~x5, 0.45], | ||
[xj, ~x6, x4, x5, 0.15], | ||
[xj, ~x6, x4, ~x5, 0.8], | ||
[xj, ~x6, ~x4, x5, 0.95], | ||
[xj, ~x6, ~x4, ~x5, 0.05], | ||
[~xj, x6, x4, x5, 1.0], | ||
[~xj, x6, x4, ~x5, 0.75], | ||
[~xj, x6, ~x4, x5, 0.3], | ||
[~xj, x6, ~x4, ~x5, 0.55], | ||
[~xj, ~x6, x4, x5, 0.85], | ||
[~xj, ~x6, x4, ~x5, 0.2], | ||
[~xj, ~x6, ~x4, x5, 0.05], | ||
[~xj, ~x6, ~x4, ~x5, 0.95] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
name: 'Pearl: Figure 3.4' | ||
endogenous: | ||
X1: | ||
outcomes: | ||
- x1 | ||
- ~x1 | ||
parents: [] | ||
table: [ | ||
[x1, 0.4], | ||
[~x1, 0.6] | ||
] | ||
X2: | ||
outcomes: | ||
- x2 | ||
- ~x2 | ||
parents: [] | ||
table: [ | ||
[x2, 0.15], | ||
[~x2, 0.85] | ||
] | ||
X3: | ||
outcomes: | ||
- x3 | ||
- ~x3 | ||
table: [ | ||
[x3, 0.1], | ||
[~x3, 0.9], | ||
] | ||
X4: | ||
outcomes: | ||
- x4 | ||
- ~x4 | ||
parents: | ||
- Xi | ||
table: [ | ||
[x4, xi, 0.9], | ||
[x4, ~xi, 0.25], | ||
[~x4, xi, 0.1], | ||
[~x4, ~xi, 0.75] | ||
] | ||
Xi: | ||
outcomes: | ||
- xi | ||
- ~xi | ||
parents: | ||
- X1 | ||
- X2 | ||
table: [ | ||
[xi, x1, x2, 0.5], | ||
[xi, x1, ~x2, 0.65], | ||
[xi, ~x1, x2, 0.1], | ||
[xi, ~x1, ~x2, 0.25], | ||
[~xi, x1, x2, 0.5], | ||
[~xi, x1, ~x2, 0.35], | ||
[~xi, ~x1, x2, 0.9], | ||
[~xi, ~x1, ~x2, 0.75] | ||
] | ||
Xj: | ||
outcomes: | ||
- xj | ||
- ~xj | ||
parents: | ||
- X2 | ||
- X3 | ||
- X4 | ||
table: [ | ||
[xj, x2, x3, x4, 0.0], | ||
[xj, x2, x3, ~x4, 0.25], | ||
[xj, x2, ~x3, x4, 0.7], | ||
[xj, x2, ~x3, ~x4, 0.45], | ||
[xj, ~x2, x3, x4, 0.15], | ||
[xj, ~x2, x3, ~x4, 0.8], | ||
[xj, ~x2, ~x3, x4, 0.95], | ||
[xj, ~x2, ~x3, ~x4, 0.05], | ||
[~xj, x2, x3, x4, 1.0], | ||
[~xj, x2, x3, ~x4, 0.75], | ||
[~xj, x2, ~x3, x4, 0.3], | ||
[~xj, x2, ~x3, ~x4, 0.55], | ||
[~xj, ~x2, x3, x4, 0.85], | ||
[~xj, ~x2, x3, ~x4, 0.2], | ||
[~xj, ~x2, ~x3, x4, 0.05], | ||
[~xj, ~x2, ~x3, ~x4, 0.95] | ||
] | ||
exogenous: | ||
U1: | ||
- X1 | ||
- X2 | ||
U2: | ||
- X2 | ||
- X3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from pathlib import Path | ||
|
||
from do import API, Expression, Intervention, Outcome | ||
|
||
api = API() | ||
|
||
file = Path("3.4-latent.yml") | ||
model = api.instantiate_model(file) | ||
|
||
xj = Outcome("Xj", "xj") | ||
xi = Intervention("Xi", "xi") | ||
e = Expression(xj, [xi]) | ||
|
||
result, proof = api.identification([xj], [xi], model) | ||
print(result) | ||
print(proof) |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.