Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
Pierre-Henri Wuillemin
@phwuill_gitlab
image.png
I is the mutual information between 2 nodes
@CasseNoisette_gitlab Hi Melanie, as far as I can tell, I guess that there must be a small difference between the label strings in your CSV and in your BN. Maybe could you try to let the learner find itself the labels in order to compare them to the ones you have proposed ?
@xavier7179 pyAgrum propose a nice representation of the information between nodes:
image.png
The width of each arc is proportional to the Mutual Information between the nodes.
Melanie
@CasseNoisette_gitlab
@phwuill_gitlab Hi Pierre-Henri, thank you for your answer. Could this be due to the presence of missing data (NaN) in my dataset? However, it seems that the miic algorithm takes into account the missing data in its R package... is this also the case in PyAgrum?
Pierre-Henri Wuillemin
@phwuill_gitlab

Hi Mélanie, from the error you show The translation of ""[45,65]"" could not be found, the problem seems to be the " that are somehow included at the beginning and at the end of the labels ...

It is true that we do not accept missing data in our MIIC's implementation. The reason is that we are not very keen on that very solution which consists in just dropping the lines when NA is involved in the computation. It allows learning any base but it is easy to show how bad the result can be if the number of NA is important enough ...

Melanie
@CasseNoisette_gitlab
Hi, thank you for your response. I understand your point about the missing data. What about the other advantages of miic available in the R package such as taking into account the presence of latent variables when building the network or the possibility of filtering arcs?
Pierre-Henri Wuillemin
@phwuill_gitlab

When you say "taking into account latent variables" do you mean "detecting latent variables" ? If yes, this is a part of the MIIC algorithm and you can check learner.latentVariables() to see if any has been detected during the learning phase.

I guess that by "filtering arcs", you mean "selecting allowed and forbidden arcs" ? If yes, we have the same problem as for missing values : even if, of course, we could do so, we are not able to find a correct interpretation of such an operation:

For score-based algorithms, it is obvious that you can do such filtering : the learning process exactly consists in selecting arcs so you can change the set of "selectable arcs". However, for constraint-based algorithms, the algo does not select arcs but infer conditional independence. If you find a conditional independence, you HAVE TO remove some arcs, if you do not find such CI, you HAVE TO keep the arcs. We do not find any good way to conciliate a user saying that the arc A->B is not possible whereas his/her own data say that this very arc has to be in the model (and vice versa).

We prefer to give to the user the responsibility to do such horrible things :-) So, after learning a BN with MIIC, you still can add/remove some arcs and then learn the parameters (even with missing value using a correct, proved and sound EM algorithm :-) )

Pierre-Henri Wuillemin
@phwuill_gitlab
Melanie
@CasseNoisette_gitlab
Hello, thanks for this link, I'm going to explore this for latent variables!
Concerning the filtering of arcs, the miic R package allows to set a threshold to keep only arcs with a log-confidence value higher than this one. For pyAgrum this would therefore mean putting a threshold on mutual information to remove arcs with too little one.
It seems to me that the package also makes it possible to present data on which the observations are dependent (the network is then created thanks to several random sampling on data). Do you plan to implement it in a future version?
Sorry for all these questions... In any case you're doing a really great job! pyAgrum is very useful to me (I am doing a thesis in the study and prediction of toxicities in radiotherapy), thank you very much! :)
Pierre-Henri Wuillemin
@phwuill_gitlab
Glad to know that agrum is helping you :-) As I told you, it seems to us that this phase should be a phase of simplification of the structure and not a part of the MIIC algorithm (this treshold is somehow in contradiction with the way MIIC works). In the philosopy of pyAgrum, it should be left to the user to decide exactly what (s)he wants to do in such a case :
ie=gum.LazyPropagation(bn)
ie.makeInference()

toberemoved=[a for a in bn.arcs() if ie.I(*a)<1e-3]    # threshold=1e-3

for a in toberemoved:
    bn.eraseArc(*a)

#learn parameters
[...]
Melanie
@CasseNoisette_gitlab
Thank you very much for this example!
I looked at your notebook on latent variables and applied it to my case. It seems that no latent variables are detected, which surprises me a lot (in the medical field, there are a lot of latent variables unfortunately! ). Could you explain to me how latentVariables() is supposed to work please ?
Pierre-Henri Wuillemin
@phwuill_gitlab

Hello Melanie, this is well described in the MIIC's papers.

In a nutshell, constraint-based algorithms try to find V-structures : X->Y<-Z.
The trace of latent variables in such algorithms comes from the identification of 2 V-structures : A->B<-C and B->C<-D ... So the arc (B,C) should be bi-oriented. MIIC and other constraint-based algorithms propose then to interpret B<->C as the "proof" of a latent common parent : B<-?->C.

So one can just detect from time to time the trace of a latent variable if this variable has at least 2 observable children (and then "confoundingly" correlated).

Melanie
@CasseNoisette_gitlab
Hello, thank you very much for all these explanations it helps me a lot!
To conclude this exchange I would like to draw your attention to a "bug" in the getCausalImpact() function. If the name of the variable contains accents, then the function makes the kernel crash. This is the problem that Francisco J. Camacho has encountered and that he told you about earlier in the discussion.
Pierre-Henri Wuillemin
@phwuill_gitlab
Pierre-Henri Wuillemin
@phwuill_gitlab

Hi, agrumery/aGrUM#52 is closed. Thanks @CasseNoisette_gitlab and Francisco Camacho

(you will be able to test it by pip install pyAgrum-nightlytomorrow or by waiting for the next tag)

Pierre-Henri Wuillemin
@phwuill_gitlab
Hello, aGrUM/pyAgrum 0.18.1 is out ! see https://agrum.gitlab.io/articles/agrumpyagrum-0181-released.html
xavier7179
@xavier7179
hi there. Is there any known reason why your C++ Inference example produces this compiler error?
error: no matching conversion for functional-style cast from 'gum::BayesNet<float>' to 'ShaferShenoyInference<float>'
`
xavier7179
@xavier7179
another question: on Osx (both using clang and gcc), when linking, I got this error too:
ld: library not found for -lodbc
xavier7179
@xavier7179

another question: on Osx (both using clang and gcc), when linking, I got this error too:

ld: library not found for -lodbc

I actually solved this one only by changing "odbc" into "iodbc" in agrum-targets.cmake

xavier7179
@xavier7179
last question from today: is there any reference were we can learn how to use the classes for learning parmeters (CPTs mainly)?
Pierre-Henri Wuillemin
@phwuill_gitlab

hi there. Is there any known reason why your C++ Inference example produces this compiler error?

error: no matching conversion for functional-style cast from 'gum::BayesNet<float>' to 'ShaferShenoyInference<float>'
`

Hi Xavier, can you be a bit more precise about the code that does not work ?

another question: on Osx (both using clang and gcc), when linking, I got this error too:

ld: library not found for -lodbc

I actually solved this one only by changing "odbc" into "iodbc" in agrum-targets.cmake

thanks for that.

Pierre-Henri Wuillemin
@phwuill_gitlab
image.png

last question from today: is there any reference were we can learn how to use the classes for learning parmeters (CPTs mainly)?

You mean, I guess, in C++ ?

http://webia.lip6.fr/~phw/aGrUM/docs/current/doxygen/d1/dd0/classgum_1_1learning_1_1BNLearner.html#a59071b92a09b64e614d9fe3a4b23c2f9

and the testsuite (see above)

xavier7179
@xavier7179

Hi Xavier, can you be a bit more precise about the code that does not work ?

Sure here it is:

auto ln_net = BayesNet<float>("Net");

this is the definition of the network and then, if follow your examples and I write something like this:

auto inference = LazyPropagation<float>( ln_net);

I get the error (I tried with differen Algortims to be sure...)

another question: on Osx (both using clang and gcc), when linking, I got this error too:

ld: library not found for -lodbc

I actually solved this one only by changing "odbc" into "iodbc" in agrum-targets.cmake

thanks for that.

Is there any chance you can put that into the next release? I tried to figure out in your repository who is responsible for that one but I did not find the right place, and making the change in the final .cmake is not very effective. I'm also trying to maintain (feel free to use it) a repo for homebrew formula (for this reason I was looking at least for a patch to apply to the code once downloaded): https://github.com/xavier7179/homebrew-research_libs.git

Pierre-Henri Wuillemin
@phwuill_gitlab

Ok, for the error, it is just that we forced the constructor to be explicit (and to use a pointer of a BN). So the code :

      auto ln_net = gum::BayesNet< float >("Net");
      gum::LazyPropagation< float > inference(&ln_net);

should work fine. If you could tell me where you find the erroneous code, I wil change it.

Pierre-Henri Wuillemin
@phwuill_gitlab
For odbc, I made a first try in the branch feature/odbc4mac. Could you tell me if it works as you need ? (thanks for the homebrew's repo, it's great to know that !)
xavier7179
@xavier7179

@phwuill_gitlab

should work fine. If you could tell me where you find the erroneous code, I wil change it.

Here it is the full error chain hoping it helps (for me was on all inference algorithm I selected):

main.cpp:122:19: error: no matching conversion for functional-style cast from 'gum::BayesNet<float>' to 'LazyPropagation<float>'
        auto inference = LazyPropagation<float>( ln_net_o);
                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/Cellar/agrum/0.18.1/include/agrum/BN/inference/lazyPropagation.h:81:14: note: candidate constructor not viable: no known conversion from 'gum::BayesNet<float>' to 'const IBayesNet<float> *' for 1st argument; take the address of the argument with &
    explicit LazyPropagation(
             ^
/usr/local/Cellar/agrum/0.18.1/include/agrum/BN/inference/lazyPropagation.h:89:5: note: candidate constructor not viable: no known conversion from 'gum::BayesNet<float>' to 'const LazyPropagation<float>' for 1st argument
    LazyPropagation(const LazyPropagation< GUM_SCALAR >&) = delete;
    ^
xavier7179
@xavier7179

@xavier7179

For odbc, I made a first try in the branch feature/odbc4mac. Could you tell me if it works as you need ? (thanks for the homebrew's repo, it's great to know that !)

I confirm you that the branch contains a fine compile toolchain on OSX, including the odbc part

Pierre-Henri Wuillemin
@phwuill_gitlab
Thanks Xavier, I cannot find this file 'main.cpp'. Is it one of yours ?
xavier7179
@xavier7179

Thanks Xavier, I cannot find this file 'main.cpp'. Is it one of yours ?

yes, it is created by myself based on a program I wrote with a different library

Pierre-Henri Wuillemin
@phwuill_gitlab

OK, so I do not understand your first message : "Is there any known reason why your C++ Inference example produces this compiler error?" ?

Have you tried to change the code as I wrote it ?

xavier7179
@xavier7179
Have you tried to change the code as I wrote it ?
I tried but the deleted constructor is still giving an error on your first line:
/src/main.cpp:122:7: error: call to deleted constructor of 'gum::LazyPropagation<float>'
        gum::LazyPropagation< float > inference = LazyPropagation<float>(&ln_net);
             ^           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/Cellar/agrum/HEAD-65e7441/include/agrum/BN/inference/lazyPropagation.h:89:5: note: 'LazyPropagation' has been explicitly marked deleted here
    LazyPropagation(const LazyPropagation< GUM_SCALAR >&) = delete;
Pierre-Henri Wuillemin
@phwuill_gitlab

My second line is (solid basic old-fashioned constructor :-) ) :
gum::LazyPropagation< float > inference(&ln_net);

and not (new modern C++ i)

gum::LazyPropagation< float > inference = LazyPropagation<float>(&ln_net); (that you should write auto inference = gum::LazyPropagation<float>(&ln_net);

Indeed, in order to avoid erroneous conversion, we made the default constructor 'explicit' (and deleted the copy constructor). So you have to build an inference engine that old-fashioned way...

xavier7179
@xavier7179
@phwuill_gitlab I see. Sorry I did not noticed the difference in the first place. Now it compiles, thanks.
Roger Hak
@CheeringRoger_gitlab
Hi! For my research I'm looking to use bayesian networks. I came across PyAgrum which seems to be the most promising and intuitive.
When I was following this tutorial http://webia.lip6.fr/~phw/aGrUM/docs/last/notebooks/11-structuralLearning.ipynb.html I receive an error. I'm using Windows 10, python 3.7.4
image.png
Pierre-Henri Wuillemin
@phwuill_gitlab
Hi Roger, which BN do you use as a parameter in cell 43 ?
Roger Hak
@CheeringRoger_gitlab
Thanks for you swift response, the BN I am using is this one
image.png
With cpt similar to the one used in the tutorial
image.png
Roger Hak
@CheeringRoger_gitlab
I think something was wrong with the asia.bif. I just build a fast BN from scratch and I had no problems anymore.
Pierre-Henri Wuillemin
@phwuill_gitlab

As you can see in the CPTs, the labels of the variables are "yes" and "no" ... In the csv, the labels are "0" and "1" ...

When you pass a bn as a parameter to a BNLearner, it is exactly to give it the labels (and their orders) that will be found in the csv ... Thge error "unknown label found" is then understandable :-) A "1" or a "0" is found for a variable which can be "yes" or "no" ...

Roger Hak
@CheeringRoger_gitlab
Ahh that makes total sense, thanks a lot!