pgmpy / pgmpy_notebook

Short Tutorial to Probabilistic Graphical Models(PGM) and pgmpy
http://pgmpy.org/
MIT License
368 stars 213 forks source link

Error ImportError: cannot import name 'BdeuScore' #37

Closed arita37 closed 4 years ago

arita37 commented 4 years ago

when using, I got this error msg just after the install.

File "", line 3, in from pgmpy.estimators import BdeuScore, K2Score, BicScore

ImportError: cannot import name 'BdeuScore'

ankurankan commented 4 years ago

@arita37 BdeuScore has been changed to BDeuScore in the latest version: https://github.com/pgmpy/pgmpy/blame/dev/CHANGELOG.md#L16

arita37 commented 4 years ago

Sure, But, how to solve in

import bnlearn ?

Change manually the code ?

On Jan 25, 2020, at 18:14, Ankur Ankan notifications@github.com wrote:

 @arita37 BdeuScore has been changed to BDeuScore in the latest version: https://github.com/pgmpy/pgmpy/blame/dev/CHANGELOG.md#L16

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

ankurankan commented 4 years ago

@arita37 I have updated the notebook to fix this. Thanks for reporting it.

arita37 commented 4 years ago

Sorry, This is not notebook BUT pip install pgmy code

On Jan 27, 2020, at 18:46, Ankur Ankan notifications@github.com wrote:

 @arita37 I have updated the notebook to fix this. Thanks for reporting it.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

ankurankan commented 4 years ago

In that case, you can just change the import from Bdeu to BDeu in your code and it should work.

arita37 commented 4 years ago

Think you need to re-publish the package to pip.

Thanks

On Jan 27, 2020, at 19:15, Ankur Ankan notifications@github.com wrote:

 In that case, you can just change the import from Bdeu to BDeu and it should work.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

ankurankan commented 4 years ago

@arita37 Are you still getting errors? It's working fine for me:

In [1]: from pgmpy.estimators import BDeuScore             

In [2]: score = BDeuScore?                                 
Init signature: BDeuScore(data, equivalent_sample_size=10, **kwargs)
Docstring:      <no docstring>
Init docstring:
Class for Bayesian structure scoring for BayesianModels with Dirichlet priors.
The BDeu score is the result of setting all Dirichlet hyperparameters/pseudo_counts to
`equivalent_sample_size/variable_cardinality`.
The `score`-method measures how well a model is able to describe the given data set.

Parameters
----------
data: pandas DataFrame object
    datafame object where each column represents one variable.
    (If some values in the data are missing the data cells should be set to `numpy.NaN`.
    Note that pandas converts each column containing `numpy.NaN`s to dtype `float`.)

equivalent_sample_size: int (default: 10)
    The equivalent/imaginary sample size (of uniform pseudo samples) for the dirichlet hyperparameters.
    The score is sensitive to this value, runs with different values might be useful.

state_names: dict (optional)
    A dict indicating, for each variable, the discrete set of states (or values)
    that the variable can take. If unspecified, the observed values in the data set
    are taken to be the only possible states.

complete_samples_only: bool (optional, default `True`)
    Specifies how to deal with missing data, if present. If set to `True` all rows
    that contain `np.Nan` somewhere are ignored. If `False` then, for each variable,
    every row where neither the variable nor its parents are `np.NaN` is used.
    This sets the behavior of the `state_count`-method.

References
---------
[1] Koller & Friedman, Probabilistic Graphical Models - Principles and Techniques, 2009
Section 18.3.4-18.3.6 (esp. page 806)
[2] AM Carvalho, Scoring functions for learning Bayesian networks,
http://www.lx.it.pt/~asmc/pub/talks/09-TA/ta_pres.pdf
File:           ~/pgmpy/pgmpy/estimators/BDeuScore.py
Type:           type