Code Monkey home page Code Monkey logo

pgmpy's Introduction

pgmpy

Build codecov Codacy Badge Downloads Join the chat at https://gitter.im/pgmpy/pgmpy asv

pgmpy is a python library for working with Probabilistic Graphical Models.

Documentation and list of algorithms supported is at our official site http://pgmpy.org/ Examples on using pgmpy: https://github.com/pgmpy/pgmpy/tree/dev/examples Basic tutorial on Probabilistic Graphical models using pgmpy: https://github.com/pgmpy/pgmpy_notebook

Our mailing list is at https://groups.google.com/forum/#!forum/pgmpy .

We have our community chat at gitter.

Dependencies

pgmpy has the following non-optional dependencies:

  • python >=3.8, <=3.11
  • networkX
  • scipy
  • numpy
  • pytorch

Some of the functionality would also require:

  • tqdm
  • pandas
  • pyparsing
  • statsmodels
  • joblib

Installation

pgmpy is available both on pypi and anaconda. For installing through anaconda use:

$ conda install -c ankurankan pgmpy

For installing through pip:

$ pip install -r requirements.txt  # only if you want to run unittests
$ pip install pgmpy

To install pgmpy from the source code:

$ git clone https://github.com/pgmpy/pgmpy
$ cd pgmpy/
$ pip install -r requirements.txt
$ python setup.py install

If you face any problems during installation let us know, via issues, mail or at our gitter channel.

Development

Code

Our latest codebase is available on the dev branch of the repository.

Contributing

Issues can be reported at our issues section.

Before opening a pull request, please have a look at our contributing guide

Contributing guide contains some points that will make our life's easier in reviewing and merging your PR.

If you face any problems in pull request, feel free to ask them on the mailing list or gitter.

If you want to implement any new features, please have a discussion about it on the issue tracker or the mailing list before starting to work on it.

Testing

After installation, you can launch the test form pgmpy source directory (you will need to have the pytest package installed):

$ pytest -v

to see the coverage of existing code use following command

$ pytest --cov-report html --cov=pgmpy

Documentation and usage

The documentation is hosted at: http://pgmpy.org/

We use sphinx to build the documentation. To build the documentation on your local system use:

$ cd /path/to/pgmpy/docs
$ make html

The generated docs will be in _build/html

Examples

We have a few example jupyter notebooks here: https://github.com/pgmpy/pgmpy/tree/dev/examples For more detailed jupyter notebooks and basic tutorials on Graphical Models check: https://github.com/pgmpy/pgmpy_notebook/

Citing

If you use pgmpy in your scientific work, please consider citing us:

Ankan, Ankur, Abinash, Panda. "pgmpy: Probabilistic Graphical Models using Python." Proceedings of the Python in Science Conference. SciPy, 2015.

Bibtex:

@inproceedings{Ankan2015,
  series = {SciPy},
  title = {pgmpy: Probabilistic Graphical Models using Python},
  ISSN = {2575-9752},
  url = {http://dx.doi.org/10.25080/Majora-7b98e3ed-001},
  DOI = {10.25080/majora-7b98e3ed-001},
  booktitle = {Proceedings of the Python in Science Conference},
  publisher = {SciPy},
  author = {Ankan,  Ankur and Panda,  Abinash},
  year = {2015},
  collection = {SciPy}
}

License

pgmpy is released under MIT License. You can read about our license at here

pgmpy's People

Contributors

abhilashrj avatar abinashpanda avatar anaviltripathi avatar anchitjain1234 avatar ankurankan avatar ashwch avatar chrisittner avatar demyanov avatar erotemic avatar felipegiro avatar finnhacks42 avatar gweesip avatar jp111 avatar khalibartan avatar kislayabhi avatar linzhp avatar liquidmetal avatar lohani2280 avatar loudly-soft avatar navinchandak avatar palashahuja avatar pandaabinash avatar pratik151 avatar pratyakshs avatar sbrugman avatar siteshjaiswal avatar snigam3112 avatar tristantreb avatar vivek425ster avatar yashu-seth avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pgmpy's Issues

Factor class __str__ method printing in wrong order

>>> jpd = JPD(['x1', 'x2', 'x3'], [2, 3, 2], np.ones(12)/12)
>>> jpd.marginal_distribution(['x1', 'x2'])

>>> print(jpd)
x2      x1      phi(x1, x2)
x1_0    x2_0    0.166666666667
x1_0    x2_1    0.166666666667
x1_0    x2_2    0.166666666667
x1_1    x2_0    0.166666666667
x1_1    x2_1    0.166666666667
x1_1    x2_2    0.166666666667

Creating setup.py for installation.

Created a setup.py for installation of pgmpy. Changes done:

  • Moved the src and tests to pgmpy.
  • Moved Factor.py to new folder Factor.
    Current Structure:
    
    |-- pgmpy
    |   |-- BayesianModel
    |   |   |-- BayesianModel.py
    |   |   |-- CPD.py
    |   |   |-- __init__.py
    |   |-- Exceptions
    |   |   |-- Exceptions.py
    |   |   |-- __init__.py
    |   |-- Factor
    |   |   |-- _factor_product.pyx
    |   |   |-- Factor.py
    |   |   |-- __init__.py
    |   |-- __init__.py
    |   |-- tests
    |       |-- help_functions.py
    |       |-- test_BayesianModel.py
    
    

Few things still needed to be resolved.

  • Package structure.
  • init.py in both packages and subpackages.

Implementing reading from and writing to various file formats

Error with is_active_trail

In [1]:         >>> from pgmpy import BayesianModel as bm

In [2]:         >>> student = bm.BayesianModel()

In [3]:         >>> student.add_nodes_from(['diff', 'intel', 'grades'])

In [4]:         >>> student.add_edges_from([('diff', 'grades'), ('intel', 'grades')])

In [5]:         >>> student.set_states({'diff': ['easy', 'hard'],
   ...:         ...                     'intel': ['dumb', 'smart'],
   ...:         ...                     'grades': ['A', 'B', 'C']})

In [6]:         >>> student.set_observations({'grades': 'A'})

In [7]:         >>> student.is_active_trail('diff', 'intel')
---------------------------------------------------------------------------
NetworkXError                             Traceback (most recent call last)
<ipython-input-7-4ff33e481cd2> in <module>()
----> 1 student.is_active_trail('diff', 'intel')

/media/ankit/76815F011898C29E/foss/pgmpy/pgmpy/BayesianModel/BayesianModel.py in is_active_trail(self, start, end, observed, additional_observed)
   1008         active_trail_nodes
   1009         """
-> 1010         if end in self.active_trail_nodes(start, observed, additional_observed):
   1011             return True
   1012         else:

/media/ankit/76815F011898C29E/foss/pgmpy/pgmpy/BayesianModel/BayesianModel.py in active_trail_nodes(self, start, observed, additional_observed)
    944         else:
    945             observed_list = self._get_observed_list()
--> 946         ancestors_list = self._get_ancestors_of(observed_list)
    947 
    948         # Direction of flow of information

/media/ankit/76815F011898C29E/foss/pgmpy/pgmpy/BayesianModel/BayesianModel.py in _get_ancestors_of(self, obs_nodes_list)
    887             node = nodes_list.pop()
    888             if node not in ancestors_list:
--> 889                 nodes_list.update(self.predecessors(node))
    890             ancestors_list.add(node)
    891         return ancestors_list

/usr/local/lib/python3.3/dist-packages/networkx-1.8.1-py3.3.egg/networkx/classes/digraph.py in predecessors(self, n)
    681     def predecessors(self, n):
    682         """Return a list of predecessor nodes of n."""
--> 683         return list(self.predecessors_iter(n))
    684 
    685 

/usr/local/lib/python3.3/dist-packages/networkx-1.8.1-py3.3.egg/networkx/classes/digraph.py in predecessors_iter(self, n)
    670             return iter(self.pred[n])
    671         except KeyError:
--> 672             raise NetworkXError("The node %s is not in the digraph."%(n,))
    673 
    674     def successors(self, n):

NetworkXError: The node None is not in the digraph.

Representation of Factor class

The current values of Factor class is set with the left most variable changing the fastest:

        +-----+-----+-----+-------------------+
        |  x1 |  x2 |  x3 |    phi(x1, x2, x2)|
        +-----+-----+-----+-------------------+
        | x1_0| x2_0| x3_0|     phi.value(0)  |
        +-----+-----+-----+-------------------+
        | x1_1| x2_0| x3_0|     phi.value(1)  |
        +-----+-----+-----+-------------------+
        | x1_0| x2_1| x3_0|     phi.value(2)  |
        +-----+-----+-----+-------------------+
        | x1_1| x2_1| x3_0|     phi.value(3)  |
        +-----+-----+-----+-------------------+
        | x1_0| x2_0| x3_1|     phi.value(4)  |
        +-----+-----+-----+-------------------+
        | x1_1| x2_0| x3_1|     phi.value(5)  |
        +-----+-----+-----+-------------------+
        | x1_0| x2_1| x3_1|     phi.value(6)  |
        +-----+-----+-----+-------------------+
        | x1_1| x2_1| x3_1|     phi.value(7)  |
        +-----+-----+-----+-------------------+

But in Koller's book the representation is with right most variable changing the fastest.

Which representation should we go with?
@abinashpanda @gargshashank5

Fix __repr__ method of Factor Class

Need to format the output of repr.
Current output:

factor
Out[3]: 
x1  x2  x3  phi(x1, x2, x3)
x1_0    x2_0    x3_0    0.0
x1_0    x2_0    x3_1    1.0
x1_0    x2_1    x3_0    2.0
x1_0    x2_1    x3_1    3.0
x1_0    x2_2    x3_0    4.0
x1_0    x2_2    x3_1    5.0
x1_1    x2_0    x3_0    6.0
x1_1    x2_0    x3_1    7.0
x1_1    x2_1    x3_0    8.0
x1_1    x2_1    x3_1    9.0
x1_1    x2_2    x3_0    10.0
x1_1    x2_2    x3_1    11.0

test_class_init_with_data_cycle failing

............E.E......
======================================================================
ERROR: test_class_init_with_data_cycle (test_BayesianModel.TestModel)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python3.3/dist-packages/networkx/convert.py", line 146, in to_networkx_graph
    return from_edgelist(data,create_using=create_using)
  File "/usr/local/lib/python3.3/dist-packages/networkx/convert.py", line 412, in from_edgelist
    G.add_edges_from(edgelist)
  File "/home/ankur/pgmpy/src/BayesianModel/BayesianModel.py", line 154, in add_edges_from
    if self._check_graph(ebunch, delete_graph=False):
  File "/home/ankur/pgmpy/src/BayesianModel/BayesianModel.py", line 230, in _check_graph
    simple_cycles)
Exceptions.Exceptions.CycleError: "('Cycles are not allowed', [['c', 'a', 'b']])"

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/ankur/pgmpy/tests/test_BayesianModel.py", line 30, in test_class_init_with_data_cycle
    self.assertRaises(Exceptions.CycleError, bm.BayesianModel, [('a', 'b'), ('b', 'c'), ('c', 'a')])
  File "/usr/lib/python3.3/unittest/case.py", line 570, in assertRaises
    return context.handle('assertRaises', callableObj, args, kwargs)
  File "/usr/lib/python3.3/unittest/case.py", line 135, in handle
    callable_obj(*args, **kwargs)
  File "/home/ankur/pgmpy/src/BayesianModel/BayesianModel.py", line 35, in __init__
    nx.DiGraph.__init__(self, ebunch)
  File "/usr/local/lib/python3.3/dist-packages/networkx/classes/digraph.py", line 210, in __init__
    convert.to_networkx_graph(data,create_using=self)
  File "/usr/local/lib/python3.3/dist-packages/networkx/convert.py", line 148, in to_networkx_graph
    raise nx.NetworkXError("Input is not a valid edge list")
networkx.exception.NetworkXError: Input is not a valid edge list

Add factor_product method

Add factor_product method inside Factor class returning a new Factor object which is the factor product of itself and the arguments.

Observing Evidence

This function should modify a set of factors given the observed values of some of the variables, so that assignments not consistent with the observed values are set to zero (in effect, reducing them). These factors do not need to be re-normalized.

read-write from ProbModelXML

ProbModelXML: http://leo.ugr.es/pgm2012/submissions/pgm2012_submission_43.pdf

For the student example the ProbModelXML file should be:

<?xml version=โ€œ1.0โ€ encoding=โ€œUTF-8โ€?>
<ProbModelXML formatVersion=โ€œ1.0โ€>
    <ProbNet type=BayesianNetwork >
        <AdditionalConstraints />
        <Comment>
            Student example model from Probabilistic Graphical Models: Principles and Techniques by Daphne Koller
        </Comment>
        <Language>
            English
        </Language>
        <AdditionalProperties />
        <Variables>
            <Variable name="intelligence" type="FiniteState" role="Chance">
                <Comment />
                <Coordinates />
                <AdditionalProperties />
                <States>
                    <State name="smart"><AdditionalProperties /></State>
                    <State name="dumb"><AdditionalProperties /></State>
                </States>
            </Variable>
            <Variable name="difficulty" type="FiniteState" role="Chance">
                <Comment />
                <Coordinates />
                <AdditionalProperties />
                <States>
                    <State name="difficult"><AdditionalProperties /></State>
                    <State name="easy"><AdditionalProperties /></State>
                </States>
            </Variable>
            <Variable name="grade" type="FiniteState" role="Chance">
                <Comment />
                <Coordinates />
                <AdditionalProperties />
                <States>
                    <State name="grade_A"><AdditionalProperties /></State>
                    <State name="grade_B"><AdditionalProperties /></State>
                    <State name="grade_C"><AdditionalProperties /></State>
                </States>
            </Variable>
            <Variable name="recommendation_letter" type="FiniteState" role="Chance">
                <Comment />
                <Coordinates />
                <AdditionalProperties />
                <States>
                    <State name="good"><AdditionalProperties /></State>
                    <State name="bad"><AdditionalProperties /></State>
                </States>
            </Variable>
            <Variable name="SAT" type="FiniteState" role="Chance">
                <Comment />
                <Coordinates />
                <AdditionalProperties />
                <States>
                    <State name="high"><AdditionalProperties /></State>
                    <State name="low"><AdditionalProperties /></State>
                </States>
            </Variable>
        </Variables>
        <Links>
            <Link var1="difficulty" var2="grade" directed=1>
                <Comment>Directed Edge from difficulty to grade</Comment>
                <Label>diff_to_grad</Label>
                <AdditionalProperties />
            </Link>
            <Link var1="intelligence" var2="grade" directed=1>
                <Comment>Directed Edge from intelligence to grade</Comment>
                <Label>intel_to_grad</Label>
                <AdditionalProperties />
            </Link>
            <Link var1="intelligence" var2="SAT" directed=1>
                <Comment>Directed Edge from intelligence to SAT</Comment>
                <Label>intel_to_sat</Label>
                <AdditionalProperties />
            </Link>
            <Link var1="grade" var2="recommendation_letter" directed=1>
                <Comment>Directed Edge from grade to recommendation_letter</Comment>
                <Label>grad_to_reco</Label>
                <AdditionalProperties />
            </Link>
        </Links>
        <Potential type="Table" role="ConditionalProbability" label=string>
            <Comment>CPDs in the form of table</Comment>
            <AdditionalProperties />
            <!--
                There is no specification in the paper about how the tables should be represented.
            -->
        </Potential>
    </ProbNet>
    <Policies />
    <InferenceOptions />
    <Evidence>
        <EvidenceCase>
            <Finding variable=string state=string stateIndex=integer numericValue=number/>
        </EvidenceCase>
    </Evidence>
</ProbModelXML>

Someone please go through the paper and check if the above example is correct.
@gargshashank5 @abinashpanda

PEP8 not followed in BayesianModel.py

Running pep8 on BayesianModel.py is giving this output:

src/BayesianModel.py:204:80: E501 line too long (105 > 79 characters)
src/BayesianModel.py:220:80: E501 line too long (87 > 79 characters)

Travis build failing

Build failing because of change in function names.

$ nosetests
........E.E
======================================================================
ERROR: test_add_states (test_BayesianModel.TestNodeProperties)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/build/PgmPy/PgmPy/tests/test_BayesianModel.py", line 69, in test_add_states
    self.G.add_states('a', ('test_state_3', 'test_state_1',
AttributeError: 'BayesianModel' object has no attribute 'add_states'
======================================================================
ERROR: test_states_function (test_BayesianModel.TestNodeProperties)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/build/PgmPy/PgmPy/tests/test_BayesianModel.py", line 88, in test_states_function
    self.G.add_states('a', ('test_state_3', 'test_state_1',
AttributeError: 'BayesianModel' object has no attribute 'add_states'
----------------------------------------------------------------------
Ran 11 tests in 0.193s
FAILED (errors=2)

Participation in Scipy India 2013

Scipy India 2013 (scipy.in)

is from 13th December to 15th December. It is a conference providing opportunities to spread the use of the Python programming language in the Scientific Computing community in India.

I was planning on giving a presentation on our library pgmpy. (http://scipy.in/2013/call-for-proposals/). Final date for submission of proposal in 24th November, 2013.

Only submissions with an actual implementation will be considered for presentation (i.e. proposals to implement the code are not acceptable, partial implementations are acceptable so long as they demonstrate the features discussed).

So we have to complete the semester objectives and add some more features in both pgmpy and pgmpy_viz before 20th November.

IMap Class

Create a new class IMap. I-Map is a set of Conditional Independence or Independence assertions.

Methods modifying Factor object

Some of the factor class methods like: reduce, normalize and marginalize modify the object on which they are called.
But we will sometimes be needing to get new objects without modifying the original object like in the case of check_independence and get_independencies methods in JointProbabilityDistribution class.

For making it work I had to do something like this:

if JointProbabilityDistribution.marginal_distribution(deepcopy(self), variable_pair) == \
                    JointProbabilityDistribution.marginal_distribution(deepcopy(self), variable_pair[0]) * \
                    JointProbabilityDistribution.marginal_distribution(deepcopy(self), variable_pair[1]):

I think we will be doing more such operations in future.

Also I agree that the current behavior of the methods of Factor class is what the user would be expecting.

One solution for this that comes to my mind is to have an additional argument for those methods which would control whether the function returns a new object or modifies itself. Like this:
def marginalize(self, variables, inplace=True):

inplace = True will modify the object itself and False will return a new object.

@abinashpanda @pramttl @gargshashank5 What do you think?

Setting of Semester Objectives

After the talk with NSR and his insistence on being able to show applications, I have come up with the following objectives for us.

The basic course structure is divided into Representation, Inference and Learning. We will only finish the Representation part.
That means:

  1. Watching of video lectures till (and including) module 8.
  2. Completing the first three programming assignments.
    ( https://class.coursera.org/pgm-003/assignment/index )
    As you can see, completing the programming assignment will also give us an "application" to showcase.

Correct error in tests

@abinashpanda, @gargshashank5 : Running tests gives this error:

E
======================================================================
ERROR: Failure: ImportError (No module named 'pgmpy.Factor._factor_product')
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/nose/failure.py", line 38, in runTest
    raise self.exc_val.with_traceback(self.tb)
  File "/usr/lib/python3/dist-packages/nose/loader.py", line 413, in loadTestsFromName
    addr.filename, addr.module)
  File "/usr/lib/python3/dist-packages/nose/importer.py", line 47, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "/usr/lib/python3/dist-packages/nose/importer.py", line 94, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "/usr/lib/python3.3/imp.py", line 190, in load_module
    return load_package(name, filename)
  File "/usr/lib/python3.3/imp.py", line 160, in load_package
    return _bootstrap.SourceFileLoader(name, path).load_module(name)
  File "<frozen importlib._bootstrap>", line 584, in _check_name_wrapper
  File "<frozen importlib._bootstrap>", line 1022, in load_module
  File "<frozen importlib._bootstrap>", line 1003, in load_module
  File "<frozen importlib._bootstrap>", line 560, in module_for_loader_wrapper
  File "<frozen importlib._bootstrap>", line 868, in _load_module
  File "<frozen importlib._bootstrap>", line 313, in _call_with_frames_removed
  File "/home/ankur/pgmpy/pgmpy/__init__.py", line 1, in <module>
    from . import BayesianModel
  File "/home/ankur/pgmpy/pgmpy/BayesianModel/__init__.py", line 1, in <module>
    from .BayesianModel import *
  File "/home/ankur/pgmpy/pgmpy/BayesianModel/BayesianModel.py", line 8, in <module>
    from pgmpy.Factor import CPD
  File "/home/ankur/pgmpy/pgmpy/Factor/__init__.py", line 1, in <module>
    from .Factor import *
  File "/home/ankur/pgmpy/pgmpy/Factor/Factor.py", line 6, in <module>
    from pgmpy.Factor._factor_product import _factor_product
ImportError: No module named 'pgmpy.Factor._factor_product'

----------------------------------------------------------------------
Ran 1 test in 0.432s

FAILED (errors=1)

test_class_init_with_data_selfloop failing

...........E......
======================================================================
ERROR: test_class_init_with_data_selfloop (test_BayesianModel.TestModel)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python3.3/dist-packages/networkx/convert.py", line 146, in to_networkx_graph
    return from_edgelist(data,create_using=create_using)
  File "/usr/local/lib/python3.3/dist-packages/networkx/convert.py", line 412, in from_edgelist
    G.add_edges_from(edgelist)
  File "/home/ankur/pgmpy/src/BayesianModel/BayesianModel.py", line 154, in add_edges_from
    if self._check_graph(ebunch, delete_graph=False):
  File "/home/ankur/pgmpy/src/BayesianModel/BayesianModel.py", line 221, in _check_graph
    "allowed", edge)
Exceptions.Exceptions.SelfLoopError: "('Self loops are notallowed', ('a', 'a'))"

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/ankur/pgmpy/tests/test_BayesianModel.py", line 27, in test_class_init_with_data_selfloop
    [('a', 'a')])
  File "/usr/lib/python3.3/unittest/case.py", line 570, in assertRaises
    return context.handle('assertRaises', callableObj, args, kwargs)
  File "/usr/lib/python3.3/unittest/case.py", line 135, in handle
    callable_obj(*args, **kwargs)
  File "/home/ankur/pgmpy/src/BayesianModel/BayesianModel.py", line 35, in __init__
    nx.DiGraph.__init__(self, ebunch)
  File "/usr/local/lib/python3.3/dist-packages/networkx/classes/digraph.py", line 210, in __init__
    convert.to_networkx_graph(data,create_using=self)
  File "/usr/local/lib/python3.3/dist-packages/networkx/convert.py", line 148, in to_networkx_graph
    raise nx.NetworkXError("Input is not a valid edge list")
networkx.exception.NetworkXError: Input is not a valid edge list

----------------------------------------------------------------------
Ran 18 tests in 0.238s

FAILED (errors=1)

Pretty Tables

If get_cpd is called with pretty=True then it should print a table like this:

_________________________________________________________________________
|NAME        |                        Node1                             |
|------------|----------------------------------------------------------|
|Parent1     |          State-A          |          State-B             |
|------------|----------------------------------------------------------|
|Parent2     |     State-C  |  State-D   |    State-C   |   State-D     |
|------------|----------------------------------------------------------| 
|Node1-State1|       P1     |     P2     |      P3      |      P4       |
|            |                                                          |
|Node1-State2|       P5     |     P6     |      P7      |      P8       | 
|_______________________________________________________________________|

Tests failing because Travis can't find isclose method of numpy

Traceback (most recent call last):
  File "/home/travis/build/pgmpy/pgmpy/pgmpy/tests/test_Factor.py", line 292, in setUp
    self.jpd = JPD(['x1', 'x2', 'x3'], [2, 3, 2], values=np.ones(12)/12)
  File "/home/travis/build/pgmpy/pgmpy/pgmpy/Factor/JointProbabilityDistribution.py", line 75, in __init__
    if np.isclose(np.sum(values), 1):
AttributeError: 'module' object has no attribute 'isclose'

@abinashpanda Could you please look into it? I couldn't find anything.

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.