GithubHelp home page GithubHelp logo

Comments (4)

jdramsey avatar jdramsey commented on May 27, 2024

The issue I think is that checking background knowledge requires an overhead, so if you don't have to do it the algorithms will run faster.

The way it's stored is in pairs <{n1, ..., nm>, {nq...nr}>, where edges are forbidden in reverse. The set lookups should be fast (i.e., if you forbid all of the second from causing any of the first, and you try to add an edge x1->x2, if will look to see if x1 is in the second set and x2 is in the first set and if so will forbid it). If you give separate singleton pairs for each, like <{x1}, {x2}>, it has to go through a lot of sets to figure this out. Do you know how your knowledge is being entered?

from causal-learn.

verae98 avatar verae98 commented on May 27, 2024

Thank you for your reply! I store the forbidden and required edges in self.forbidden_rules_specs and self.required_rules_specs for the BackgroundKnowledge class which I thought only allow singleton pairs, since the type is Set[Tuple[Node, Node]]. That explains why the algorithm is slower then. But how can I change then then to the pairs with multiple values?

from causal-learn.

verae98 avatar verae98 commented on May 27, 2024

Hi, I have added a childclass of this BackgroundKnowledge class called FastBackgroundKnowledge in my code which inherits all the properties of the BackgroundKnowledge, except for the is_forbidden() and is_required() functions to fix my problem.

I have added two dictionaries for which the required and forbidden edges are stored in. For each required edge X1 -> X2 we have a dict_required {"X1" : [X2]}. This way the is_forbidden() function and is_required() function do not have to look through all sets, but has a lookup by node name. This has lowered the FCI function computation time significantly!

There is only one problem, in the file fas.py line 286, type checking has been done by stating type(knowledge) == BackgroundKnowledge I would like to suggest to change this to isinstance(knowledge, BackgroundKnowledge), such that inheritance is possible :)

from causal-learn.

kunwuz avatar kunwuz commented on May 27, 2024

Thanks so much! Your solution looks fantastic : ) If you would like to, could you please create a PR (including a short test example) for this so that your contribution could be better recognized? We can also review and push this if everything goes smoothly. Of course, we greatly appreciate your suggestions whether you would like to PR it or not.

from causal-learn.

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.