-
Notifications
You must be signed in to change notification settings - Fork 24
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
Adding FGES #78
Adding FGES #78
Conversation
|
||
""" | ||
fges(data; penalty = 1.0, verbose=false) | ||
Compute a causal graph for the given observed data. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Compute a causal graph for the given observed data. | |
Compute a causal graph for the given observed data. |
d = Normal() | ||
p = 0.01 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
d = Normal() | |
p = 0.01 |
unused?
neighborList = Int64[] | ||
|
||
#loop through all vertices except for x | ||
for vᵢ in Iterators.filter(!isequal(x),vertices(g)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for vᵢ in Iterators.filter(!isequal(x),vertices(g)) | |
for vᵢ in Iterators.filter(!isequal(x), vertices(g)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
below too
allpairs(v) = Iterators.filter(i -> isless(i...), Iterators.product(v,v)) | ||
|
||
#Get every undirected edge in the entire graph g | ||
allundirected(g) = [Edge(nodePair) for nodePair in allpairs(vertices(g)) if isundirected(g,nodePair)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make it a generator?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean something like this?
allundirected(g) = [Edge(nodePair) for nodePair in allpairs(vertices(g)) if isundirected(g,nodePair)] | |
allundirected(g) = (Edge(nodePair) for nodePair in allpairs(vertices(g)) if isundirected(g,nodePair)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
# Neighborhood functions | ||
#################################################################### | ||
|
||
#Should these be non-allocating iterators? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aren't they?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think they weren't originally, but I changed it and forgot to remove the comment.
#################################################################### | ||
|
||
""" | ||
orientedge!(g, x, y) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
orientedge!(g, x, y) | |
orientedge!(g, x, y) | |
|
||
#Do the nodesRemoved block all semi-directed paths between src and dest? | ||
""" | ||
isblocked(g, src, dest, nodesRemoved) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isblocked(g, src, dest, nodesRemoved) | |
isblocked(g, src, dest, nodesRemoved) | |
Very nice, no problem with the additional dependencies. One could think of getting rid of camel case in function names |
end | ||
|
||
#Simple structure to hold the current edge, a subset of neighbors, and a score change | ||
Base.@kwdef mutable struct Step{A,B} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Base.@kwdef mutable struct Step{A,B} | |
Base.@kwdef mutable struct FESStep{A,B} |
This should have a more specific name
|
||
#Simple structure to hold the current edge, a subset of neighbors, and a score change | ||
Base.@kwdef mutable struct Step{A,B} | ||
edge::Edge = Edge(1,2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be that this should be SimpleEdge
as Edge is an abstract type. Is this struct performance critical / used in a tight loop?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very good point. We should change this to a concrete type
#################################################################### | ||
|
||
""" | ||
fges(data; penalty = 1.0, verbose=false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fges(data; penalty = 1.0, verbose=false) | |
fges(data; penalty = 1.0, verbose=false) | |
I am adding these spaces after the function signature in the doc string
You committed the manifest and a settings file by accident, I think this might cause the test failure. |
What are your thoughts on this? |
Ah apologies, I completely dropped the ball on this. I'll look at your comments this weekend in more detail, but overall they seem like good/minor additions. I'll make sure the manifest file doesn't get committed and check out the |
Not needed for FGES
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the suggestions seem good. I've only done a pull request once before so sorry if anything looks weird. I'll try and commit the suggestions and remove the manifest file to see if things check out.
|
||
#Simple structure to hold the current edge, a subset of neighbors, and a score change | ||
Base.@kwdef mutable struct Step{A,B} | ||
edge::Edge = Edge(1,2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very good point. We should change this to a concrete type
allpairs(v) = Iterators.filter(i -> isless(i...), Iterators.product(v,v)) | ||
|
||
#Get every undirected edge in the entire graph g | ||
allundirected(g) = [Edge(nodePair) for nodePair in allpairs(vertices(g)) if isundirected(g,nodePair)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean something like this?
allundirected(g) = [Edge(nodePair) for nodePair in allpairs(vertices(g)) if isundirected(g,nodePair)] | |
allundirected(g) = (Edge(nodePair) for nodePair in allpairs(vertices(g)) if isundirected(g,nodePair)) |
I think you forgot to add the new test to the runtest file. |
Ps: If it is easier, just make a new PR. |
Continued in #92 |
So it looks like I've got FGES working with the DiGraphs from
Graphs.jl
. I've also simplified some parts of the package I wrote:message()
function as that was specific to running the package on a clusterX \ y
to perform linear regressionI added a test for
fges
(copying the test from pc2.jl) and it passed. Let me know if you want me to add other tests.I also added two dependencies
Memoization
andLRUCache
. FGES performs A LOT of linear regressions and often performs the same one more than once. These two packages basically keep a dictionary of inputs and outputs that it checks before running thescore
function.Let me know what you think!