erdogant / bnlearn

Python package for Causal Discovery by learning the graphical structure of Bayesian networks. Structure Learning, Parameter Learning, Inferences, Sampling methods.
https://erdogant.github.io/bnlearn
Other
480 stars 46 forks source link

fit() got an unexpected keyword argument 'evidance' #58

Closed samanemami closed 2 years ago

samanemami commented 2 years ago

I am trying to reproduce the Inference example by making DAG with the following method;

model = bn.structure_learning.fit(df, methodtype='hc', scoretype='bic')
DAG = bn.make_DAG(model)
q1 =bn.inference.fit(DAG, variables=['3'], evidance={'1':0})

But I receive the following TypeError

TypeError: fit() got an unexpected keyword argument 'evidance'

I know that it comes from the DAG, but DAG is a dictionary and it is based on the standard of the example in the documentation.

Could you help me with this, please?

erdogant commented 2 years ago

Seems like a typo: try evidence instead of evidance

If this example comes from the from documentation pages, I need to fix the typo.

samanemami commented 2 years ago

Seems like a typo: try evidence instead of evidance

If this example comes from the from documentation pages, I need to fix the typo.

The example of the documentation works perfectly. But when I use structure_learning.fit() method to construct a DAG with make_DAG(), it returns an error in inference(), but if I manually construct the edges in the dictionary, it works fine.

erdogant commented 2 years ago

Ok! I will look at this!

samanemami commented 2 years ago

Ok! I will look at this!

Thank you so much

erdogant commented 2 years ago

I am unable to reproduce the error. Can you show this error with a small example?

samanemami commented 2 years ago

Thank you @erdogant I managed to fix the problem. It was coming from the data frame. I am using uchar8 as the data type for the model input. But I can not make the predict method work. It gives me the following error;

image

erdogant commented 2 years ago

Did you try to update to the latest version? It seems look an issue that may have fixed the other day.

Try first:

pip install -U bnlearn

samanemami commented 2 years ago

It is not working with the last version. If you send me the kaggle user, I can give you access to the problem. Thank you