Giter Site home page Giter Site logo

posterior / distributions Goto Github PK

View Code? Open in Web Editor NEW

This project forked from forcedotcom/distributions

16.0 16.0 8.0 1.69 MB

Low-level primitives for collapsed Gibbs sampling in python and C++

License: BSD 3-Clause "New" or "Revised" License

CMake 1.50% Makefile 0.58% C++ 39.30% Shell 0.26% Python 32.55% HTML 0.08% Cython 25.73%
bayesian-inference gibbs-sampling machine-learning python

distributions's People

Contributors

cap avatar dpfau avatar emilyfertig avatar fritzo avatar jglidden-salesforce avatar tdhopper avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

distributions's Issues

Math bug in dbg.models.niw.Group.merge()

def merge(self, shared, source):
    self.count += source.count
    self.sum_x += source.sum_x
    self.sum_xxT += source.sum_xxT  # FIXME This ignores the difference in .sum_x parts.

For a possibly correct implementation in 1d, see the nich implementation.

discrete_goodness_of_fit bounds error

distributions/util.py line 113

for sample in samples:
    counts[min(int(bin_count * sample), bin_count - 1)] += 1
return multinomial_goodness_of_fit(probs, counts, len(samples), plot=plot)

protoc autogenerated files should not be in the git repository

When running make, the following error message is thrown

[  6%] Building CXX object
src/CMakeFiles/distributions_shared.dir/io/schema.pb.cc.o In file included from
/distributions/src/io/schema.pb.cc:4:0:
distributions/src/../include/distributions/io/schema.pb.h:17:2: error: #error
This file was generated by an older version of protoc which is
incompatible with your Protocol Buffer headers Please regenerate this
file with a newer version of protoc.

distributions/src/../include/distributions/io/schema.pb.h:18:2: error: #error
This file was generated by an older version of protoc which is
incompatible with your Protocol Buffer headers Please regenerate this
file with a newer version of protoc.

/distributions/src/../include/distributions/io/schema.pb.h:19:2: error: #error
This file was generated by an older version of protoc which is
incompatible with your Protocol Buffer headers Please regenerate this
file with a newer version of protoc.

make[3]: *** [src/CMakeFiles/distributions_shared.dir/io/schema.pb.cc.o] Error 1
make[3]: Leaving directory `distributions/build/python' make[2]: ***
[src/CMakeFiles/distributions_shared.dir/all] Error 2 make[2]: Leaving directory
`distributions/build/python' make[1]: *** [all] Error 2 make[1]: Leaving
directory `distributions/build/python' make: *** [python_cc] Error 2

The solution is to remove the offending file, and rebuild schema.pb.h using make protobuf:

$ rm distributions/include/distributions/io/schema.pb.h
$ make protobuf

Now running make is successful.

Sampling bug in C++ Normal Inverse Wishart

The new stronger statistical tests indicate a bug in the C++ version of Normal-Inverse-Wishart sampler. I assume the bug is in the sampling code in random.hpp (python sampler and scorer agree as per test_models.py:test_sample_value, and python and c++ scoring agree as per test_model_flavors.py:test_group, pointing to C++ sampling as the culprit.

This is now disabled in unit tests.

Segfault in dpd mixture

$ nosetests -v distributions/tests/test_models.py
....
distributions.tests.test_models.test_mixture_runs('lp.models.dpd',) ... Segmentation fault

$ uname -a
Linux desk 3.13.0-43-generic #72-Ubuntu SMP Mon Dec 8 19:35:06 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

Numpy deprecation test suite failure on Ubuntu 16.04

Using make all results in two failures in the distributions test suite:

======================================================================
ERROR: distributions.tests.test_util.test_scores_to_probs
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/venv/local/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/posterior/distributions/distributions/tests/test_util.py", line 38, in test_scores_to_probs
    probs = scores_to_probs(scores)
  File "/posterior/distributions/distributions/util.py", line 34, in scores_to_probs
    probs = numpy.exp(scores, out=scores)
TypeError: ufunc 'exp' output (typecode 'd') could not be coerced to provided output parameter (typecode 'l') according to the casting rule ''same_kind''

======================================================================
FAIL: distributions.tests.test_models.test_add_remove('lp.models.niw',)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/venv/local/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/posterior/distributions/distributions/tests/test_models.py", line 104, in test_one_model
    test_fun(module, EXAMPLE)
  File "/posterior/distributions/distributions/tests/test_models.py", line 246, in test_add_remove
    err_msg='p(x1,...,xn) != p(x1) p(x2|x1) p(xn|...)')
  File "/posterior/distributions/distributions/tests/util.py", line 120, in assert_close
    assert_less(diff, tol * norm, msg)
AssertionError: p(x1,...,xn) != p(x1) p(x2|x1) p(xn|...) off by 0.163564845877% = 0.00525343418121
-------------------- >> begin captured stdout << ---------------------
example 1/4
example 2/4
example 3/4
p(x1,...,xn) != p(x1) p(x2|x1) p(xn|...)
actual = -1.10329115391
expected = -1.10854458809

--------------------- >> end captured stdout << ----------------------

----------------------------------------------------------------------
Ran 292 tests in 55.957s

FAILED (SKIP=15, errors=1, failures=1)
make: *** [test_cy] Error 1

The numpy error in distributions.tests.test_util.test_scores_to_probs is due to deprecation: numpy/numpy#6464

Not sure why the probabilities are failing.

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.