{ "info": { "author": "Colin Carroll", "author_email": "colcarroll@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6" ], "description": "|Build Status| |Coverage Status|\n\n========\nsampled\n========\n\n\n*Decorator for reusable models in PyMC3*\n\nProvides syntactic sugar for reusable models with PyMC3. This lets you separate creating a generative model from using the model.\n\nHere is an example of creating a model:\n\n::\n\n import numpy as np\n import pymc3 as pm\n from sampled import sampled\n\n @sampled\n def linear_model(X, y):\n shape = X.shape\n X = pm.Normal('X', mu=np.mean(X, axis=0), sd=np.std(X, axis=0), shape=shape)\n coefs = pm.Normal('coefs', mu=np.zeros(shape[1]), sd=np.ones(shape[1]), shape=shape[1])\n pm.Normal('y', mu=np.dot(X, coefs), sd=np.ones(shape[0]), shape=shape[0])\n\nNow here is how to use the model:\n::\n\n X = np.random.normal(size=(1000, 10))\n w = np.random.normal(size=10)\n y = X.dot(w) + np.random.normal(scale=0.1, size=1000)\n\n with linear_model(X=X, y=y):\n sampled_coefs = pm.sample(draws=1000, tune=500)\n\n np.allclose(sampled_coefs.get_values('coefs').mean(axis=0), w, atol=0.1) # True\n\nYou can also use this to build graphical networks -- here is a continuous version of the `STUDENT` example from Koller and Friedman's \"Probabilistic Graphical Models\", chapter 3:\n\n::\n\n @sampled\n def student():\n difficulty = pm.Beta('difficulty', alpha=5, beta=5)\n intelligence = pm.Beta('intelligence', alpha=5, beta=5)\n SAT = pm.Beta('SAT', alpha=20 * intelligence, beta=20 * (1 - intelligence))\n grade_avg = 0.5 + 0.5 * tt.sqrt((1 - difficulty) * intelligence)\n grade = pm.Beta('grade', alpha=20 * grade_avg, beta=20 * (1 - grade_avg))\n recommendation = pm.Binomial('recommendation', n=1, p=0.7 * grade)\n\nObservations may be passed into any node, and we can observe how that changes posterior expectations:\n\n::\n\n # no prior knowledge\n with student():\n prior = pm.sample(draws=1000, tune=500)\n\n prior.get_values('recommendation').mean() # 0.502\n\n # 99th percentile SAT score --> higher chance of a recommendation\n with student(SAT=0.99):\n good_sats = pm.sample(draws=1000, tune=500)\n\n good_sats.get_values('recommendation').mean() # 0.543\n\n # A good grade in a hard class --> very high chance of recommendation\n with student(difficulty=0.99, grade=0.99):\n hard_class_good_grade = pm.sample(draws=1000, tune=500)\n\n hard_class_good_grade.get_values('recommendation').mean() # 0.705\n\n\n**References**\n\n* Koller, Daphne, and Nir Friedman. *Probabilistic graphical models: principles and techniques.* MIT press, 2009.\n\n.. |Build Status| image:: https://travis-ci.org/ColCarroll/sampled.svg?branch=master\n :target: https://travis-ci.org/ColCarroll/sampled\n.. |Coverage Status| image:: https://coveralls.io/repos/github/ColCarroll/sampled/badge.svg?branch=master\n :target: https://coveralls.io/github/ColCarroll/sampled?branch=master", "description_content_type": null, "docs_url": null, "download_url": null, "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/ColCarroll/sampled", "keywords": null, "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "sampled", "package_url": "https://pypi.org/project/sampled/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/sampled/", "project_urls": { "Homepage": "https://github.com/ColCarroll/sampled" }, "release_url": "https://pypi.org/project/sampled/0.1.2/", "requires_dist": null, "requires_python": null, "summary": "Decorator for reusable models in PyMC3", "version": "0.1.2" }, "last_serial": 2923344, "releases": { "0.0.1": [], "0.1.0": [], "0.1.1": [ { "comment_text": "", "digests": { "md5": "bef20a240d312e0bf318108c89271fe2", "sha256": "b06bb37d464371d0d0ddcc39c6ac74b009be0915c2eeaca26c80dc1e8e6ae032" }, "downloads": -1, "filename": "sampled-0.1.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "bef20a240d312e0bf318108c89271fe2", "packagetype": "bdist_wheel", "python_version": "3.6", "requires_python": null, "size": 4910, "upload_time": "2017-06-01T02:33:39", "url": "https://files.pythonhosted.org/packages/bb/56/f2fdc2425fac0ef798cb2045a5a2edf8fc54285d87a336403fc755eeb2ef/sampled-0.1.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "b1c9a3a95526bb81807c9089c4247045", "sha256": "8dfe7d3a7b530cd56ffcc16cbf4c94ed30c7a236c90b639a58abac74fe1a4df0" }, "downloads": -1, "filename": "sampled-0.1.1.tar.gz", "has_sig": false, "md5_digest": "b1c9a3a95526bb81807c9089c4247045", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3367, "upload_time": "2017-06-01T02:34:24", "url": "https://files.pythonhosted.org/packages/3e/66/b7f4904c6127a5a4ac5bd754b6ed13688f30b076c6b97ae956371219f664/sampled-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "f1e6901fb10e0e304ff30d51d8443d38", "sha256": "9aa5c6a96f63862d344f65c9fd1fbbe34cf61057cde4c3401da21f22e1468ebb" }, "downloads": -1, "filename": "sampled-0.1.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "f1e6901fb10e0e304ff30d51d8443d38", "packagetype": "bdist_wheel", "python_version": "3.6", "requires_python": null, "size": 4913, "upload_time": "2017-06-04T00:07:45", "url": "https://files.pythonhosted.org/packages/53/f1/2f9de51aee389c3932d682b5a9cfdd3acc55d5d1cb8069449b68340755bb/sampled-0.1.2-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "32453efcc964198e5eb6ade8cabc00f4", "sha256": "aeedde577c4e787a91d5ae3510d2d0733c9d72f381e75fee1c8d98fb365ad4c9" }, "downloads": -1, "filename": "sampled-0.1.2.tar.gz", "has_sig": false, "md5_digest": "32453efcc964198e5eb6ade8cabc00f4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3368, "upload_time": "2017-06-04T00:07:55", "url": "https://files.pythonhosted.org/packages/9a/ff/9ba6fce1125f1cd2b9a9daeb49d8a0e0c868661c652e8e560ae46eb614fa/sampled-0.1.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "f1e6901fb10e0e304ff30d51d8443d38", "sha256": "9aa5c6a96f63862d344f65c9fd1fbbe34cf61057cde4c3401da21f22e1468ebb" }, "downloads": -1, "filename": "sampled-0.1.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "f1e6901fb10e0e304ff30d51d8443d38", "packagetype": "bdist_wheel", "python_version": "3.6", "requires_python": null, "size": 4913, "upload_time": "2017-06-04T00:07:45", "url": "https://files.pythonhosted.org/packages/53/f1/2f9de51aee389c3932d682b5a9cfdd3acc55d5d1cb8069449b68340755bb/sampled-0.1.2-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "32453efcc964198e5eb6ade8cabc00f4", "sha256": "aeedde577c4e787a91d5ae3510d2d0733c9d72f381e75fee1c8d98fb365ad4c9" }, "downloads": -1, "filename": "sampled-0.1.2.tar.gz", "has_sig": false, "md5_digest": "32453efcc964198e5eb6ade8cabc00f4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3368, "upload_time": "2017-06-04T00:07:55", "url": "https://files.pythonhosted.org/packages/9a/ff/9ba6fce1125f1cd2b9a9daeb49d8a0e0c868661c652e8e560ae46eb614fa/sampled-0.1.2.tar.gz" } ] }