posterior / distributions Goto Github PK
View Code? Open in Web Editor NEWThis project forked from forcedotcom/distributions
Low-level primitives for collapsed Gibbs sampling in python and C++
License: BSD 3-Clause "New" or "Revised" License
This project forked from forcedotcom/distributions
Low-level primitives for collapsed Gibbs sampling in python and C++
License: BSD 3-Clause "New" or "Revised" License
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.
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.
Cannot install distributions using command 'pip install distributions' for python2 on Ubuntu 18.04
It says /usr/bin/ld: cannot find -ldistributions_shared
error: command 'x86_64-linux-gnu-g++' failed with exit status 1
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)
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.
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.
discrete_goodness_of_fit does not raise error when too few samples are in top 10 bins (an error that is correctly raised in density_goodness_of_fit)
$ 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
I recently tried building distributions for aarch64, but the code seems quite specific to x86. Does a port exist/is there one planned for aarch64?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.