{ "info": { "author": "scikit-stan development team", "author_email": "scikit-stan@googlegroups.com", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "Intended Audience :: Science/Research", "Programming Language :: Python", "Programming Language :: Python :: 3.6", "Topic :: Scientific/Engineering :: Mathematics" ], "description": "scikit-stan\n===========\n\n|Build Status| |codecov|\n\nWhat is scikit-stan\n-------------------\n\n``scikit-stan`` will enable you to use various bayesian models based on\n``stan``\\ (http://mc-stan.org) and ``pystan`` with a elegant interface\nlike a ``scikit-learn`` or ``keras``.\n\nDemo\n----\n\n.. code:: python\n\n import numpy as np\n\n from skstan.regression.linear_models import LogisticRegression\n\n if __name__ == '__main__':\n x = np.array(\n [\n [1,2,3,],\n [1,2,7,],\n [1,0,3,],\n [1,1,3,],\n [3,7,3,],\n ]\n )\n y = np.array([0,0,0,0,1])\n\n glm = LogisticRegression(shrinkage=10, chains=8)\n fit = glm.fit(x, y)\n\nThen we got result object ``fit``, and field ``stanfit`` is a stanfit\nobject of pystan.\n\n.. code:: python\n\n print(fit.stanfit)\n\nIt gives following\n\n::\n\n Inference for Stan model: anon_model_f63cd5ccdd67c22034b2490ae4c9cdd1.\n 4 chains, each with iter=2000; warmup=1000; thin=1; \n post-warmup draws per chain=1000, total post-warmup draws=4000.\n\n mean se_mean sd 2.5% 25% 50% 75% 97.5% n_eff Rhat\n alpha[0] 2.23 0.29 8.88 -14.39 -3.87 2.02 8.07 20.67 966 1.0\n alpha[1] 7.81 0.18 5.29 -1.08 4.01 7.48 11.23 19.01 880 1.0\n alpha[2] -9.79 0.22 5.87 -22.91 -13.41 -9.37 -5.38 -0.17 728 1.0\n beta -2.48 0.29 9.8 -22.63 -9.03 -2.3 3.99 16.91 1146 1.0\n yp[0] -13.99 0.32 11.19 -40.69 -20.24 -11.35 -5.42 0.3 1259 1.0\n yp[1] -53.15 1.14 32.08 -128.4 -71.99 -48.46 -29.35 -5.24 790 1.0\n yp[2] -29.61 0.6 16.66 -67.24 -39.44 -27.97 -17.0 -4.37 771 1.0\n yp[3] -21.8 0.44 13.17 -52.98 -29.03 -19.57 -11.91 -3.23 894 1.0\n yp[4] 29.51 0.69 24.68 0.58 10.3 23.36 42.72 90.17 1276 1.0\n lp__ -2.16 0.05 1.48 -5.93 -2.9 -1.81 -1.07 -0.32 956 1.0\n\n Samples were drawn using NUTS at Thu Apr 13 07:52:33 2017.\n For each parameter, n_eff is a crude measure of effective sample size,\n and Rhat is the potential scale reduction factor on split chains (at \n convergence, Rhat=1).\n\nResult object of ``skstan`` also have prediction methods. Predicted\nvalues can be obtained as samples from distribution with a\n``predict_dist`` method, because it is bayesian model.\n\n.. code:: python\n\n yp_dist = fit.predict_dist(x)\n print(yp_dist)\n\nThen we got\n\n::\n\n array([[ 2.63886682e-08, 5.23976746e-04, 5.54863097e-05, ...,\n 2.46008578e-08, 3.74830192e-01, 3.45994043e-03],\n [ 1.07746578e-22, 1.01664809e-18, 4.12813154e-26, ...,\n 5.64992544e-19, 7.24386097e-12, 1.75795155e-23],\n [ 8.04688037e-22, 4.44522113e-12, 1.42920488e-11, ...,\n 7.71565191e-13, 5.13118658e-05, 4.26331280e-05],\n [ 4.60810657e-15, 4.82743551e-08, 2.81612678e-08, ...,\n 1.37772153e-10, 5.51614998e-03, 3.84594197e-04],\n [ 9.99999998e-01, 1.00000000e+00, 1.00000000e+00, ...,\n 9.99965378e-01, 1.00000000e+00, 1.00000000e+00]])\n\nSo let's check the histgram of first row with ``pandas.Series``.\n\n.. code:: python\n\n import pandas as pd\n pd.Series(yp_dist[0]).hist(bins=20)\n\n.. figure:: image/hist.png\n :alt: Histgram of first row\n\n Histgram of first row\nIf you need a median of samples, you can get it with just ``predict``\nmethod\n\n.. code:: python\n\n yp = fit.predict(x)\n print(yp)\n\ngives\n\n::\n\n array([ 1.17280235e-05, 9.01419773e-22, 7.16023732e-13,\n 3.18368664e-09, 1.00000000e+00])\n\nHow to install\n--------------\n\nInstall\n~~~~~~~\n\n.. code:: sh\n\n git clone https://github.com/BayesianFreaks/scikit-stan\n cd scikit-stan\n python3 setup.py install\n\nUninstall\n~~~~~~~~~\n\n.. code:: sh\n\n pip3 uninstall scikit-stan\n\nUsing python2?\n==============\n\nAre you joking?\n\nWe can't touch you because we are living in the future from you, and\nyou're living in past ages. Please say hello to Nobunaga Oda.\n\nWe will always use newest features of the latest version of python, so\nyou should use the latest version of python.\n\nModels\n======\n\nReady\n-----\n\nRegression Models\n~~~~~~~~~~~~~~~~~\n\n- Linear Regrassion\n- Poisson Regression\n- Logistic Regression\n\nNext Steps\n----------\n\nRegression Models\n~~~~~~~~~~~~~~~~~\n\n- Gamma Regression\n- GLMM\n- etc...\n\nTime Series Models\n~~~~~~~~~~~~~~~~~~\n\n- AR Model\n- MA Model\n- ARMA Model\n- ARIMA Model\n- ARCH Model\n- GARCH Model\n- TAR Model\n- State Space Model\n- or Some Dynamic Regression Models\n- etc...\n\nClustering Model\n~~~~~~~~~~~~~~~~\n\n- Gaussian Mixture Model\n- Latent Dirichlet Allocation\n- etc...\n\nParticular Application\n~~~~~~~~~~~~~~~~~~~~~~\n\n- Modeling about online-advertisement\n- Decompose time series data\n- Empirical Bayesian Estimation\n\n.. |Build Status| image:: https://travis-ci.org/BayesianFreaks/scikit-stan.svg?branch=master\n :target: https://travis-ci.org/BayesianFreaks/scikit-stan\n.. |codecov| image:: https://codecov.io/gh/BayesianFreaks/scikit-stan/branch/master/graph/badge.svg\n :target: https://codecov.io/gh/BayesianFreaks/scikit-stan", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://skstan.org/latest/doc/", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "skstan", "package_url": "https://pypi.org/project/skstan/", "platform": "", "project_url": "https://pypi.org/project/skstan/", "project_urls": { "Homepage": "https://skstan.org/latest/doc/" }, "release_url": "https://pypi.org/project/skstan/0.0.0.dev2/", "requires_dist": null, "requires_python": "", "summary": "Various bayesian models based on stan and pystan with a elegant interface like a scikit-learn or keras.", "version": "0.0.0.dev2" }, "last_serial": 3235925, "releases": { "0.0.0.dev2": [ { "comment_text": "", "digests": { "md5": "d95b222eaff2d9661afd585dda12cf7e", "sha256": "d36092bc140e443508952a4b8c59689942d940eb71ba3c52182cd01bd8ed3961" }, "downloads": -1, "filename": "skstan-0.0.0.dev2.tar.gz", "has_sig": false, "md5_digest": "d95b222eaff2d9661afd585dda12cf7e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7038, "upload_time": "2017-10-09T10:05:28", "url": "https://files.pythonhosted.org/packages/c9/30/2d4e4d0d175dc0d7fadb74b86e82d15a496d2e848ff9b4c8b156db7f12b0/skstan-0.0.0.dev2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "d95b222eaff2d9661afd585dda12cf7e", "sha256": "d36092bc140e443508952a4b8c59689942d940eb71ba3c52182cd01bd8ed3961" }, "downloads": -1, "filename": "skstan-0.0.0.dev2.tar.gz", "has_sig": false, "md5_digest": "d95b222eaff2d9661afd585dda12cf7e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7038, "upload_time": "2017-10-09T10:05:28", "url": "https://files.pythonhosted.org/packages/c9/30/2d4e4d0d175dc0d7fadb74b86e82d15a496d2e848ff9b4c8b156db7f12b0/skstan-0.0.0.dev2.tar.gz" } ] }