All Projects → BayesianFreaks → Scikit Stan

BayesianFreaks / Scikit Stan

Licence: mit
A high-level Bayesian analysis API written in Python

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Scikit Stan

Rhat ess
Rank-normalization, folding, and localization: An improved R-hat for assessing convergence of MCMC
Stars: ✭ 19 (-13.64%)
Mutual labels:  bayesian-inference, bayesian, bayesian-statistics
Autoppl
C++ template library for probabilistic programming
Stars: ✭ 34 (+54.55%)
Mutual labels:  bayesian-inference, bayesian, bayesian-statistics
Bayesian Stats Modelling Tutorial
How to do Bayesian statistical modelling using numpy and PyMC3
Stars: ✭ 480 (+2081.82%)
Mutual labels:  bayesian-inference, bayesian, bayesian-statistics
Dynamichmc.jl
Implementation of robust dynamic Hamiltonian Monte Carlo methods (NUTS) in Julia.
Stars: ✭ 172 (+681.82%)
Mutual labels:  bayesian-inference, bayesian, bayesian-statistics
geostan
Bayesian spatial analysis
Stars: ✭ 40 (+81.82%)
Mutual labels:  bayesian, bayesian-inference, bayesian-statistics
Stan
Stan development repository. The master branch contains the current release. The develop branch contains the latest stable development. See the Developer Process Wiki for details.
Stars: ✭ 2,177 (+9795.45%)
Mutual labels:  bayesian-inference, bayesian, bayesian-statistics
Shinystan
shinystan R package and ShinyStan GUI
Stars: ✭ 172 (+681.82%)
Mutual labels:  bayesian-inference, bayesian, bayesian-statistics
Rstanarm
rstanarm R package for Bayesian applied regression modeling
Stars: ✭ 285 (+1195.45%)
Mutual labels:  bayesian-inference, bayesian, bayesian-statistics
Bayesian Analysis Recipes
A collection of Bayesian data analysis recipes using PyMC3
Stars: ✭ 479 (+2077.27%)
Mutual labels:  bayesian-inference, bayesian, bayesian-statistics
LogDensityProblems.jl
A common framework for implementing and using log densities for inference.
Stars: ✭ 26 (+18.18%)
Mutual labels:  bayesian, bayesian-inference
DynamicHMCExamples.jl
Examples for Bayesian inference using DynamicHMC.jl and related packages.
Stars: ✭ 33 (+50%)
Mutual labels:  bayesian, bayesian-inference
Bda py demos
Bayesian Data Analysis demos for Python
Stars: ✭ 781 (+3450%)
Mutual labels:  bayesian-inference, bayesian
MultiBUGS
Multi-core BUGS for fast Bayesian inference of large hierarchical models
Stars: ✭ 28 (+27.27%)
Mutual labels:  bayesian, bayesian-inference
Bayesian Workshop
Material for a Bayesian statistics workshop
Stars: ✭ 34 (+54.55%)
Mutual labels:  bayesian-inference, bayesian-statistics
Decision Analysis Course
🎓 Uni-Bonn Decision Analysis graduate course, lectures and materials
Stars: ✭ 17 (-22.73%)
Mutual labels:  bayesian-inference, bayesian-statistics
Landmark Detection Robot Tracking SLAM-
Simultaneous Localization and Mapping(SLAM) also gives you a way to track the location of a robot in the world in real-time and identify the locations of landmarks such as buildings, trees, rocks, and other world features.
Stars: ✭ 14 (-36.36%)
Mutual labels:  bayesian-inference, bayesian-statistics
Pytorch Bayesiancnn
Bayesian Convolutional Neural Network with Variational Inference based on Bayes by Backprop in PyTorch.
Stars: ✭ 779 (+3440.91%)
Mutual labels:  bayesian-inference, bayesian-statistics
statistical-rethinking-solutions
Solutions of practice problems from the Richard McElreath's "Statistical Rethinking" book.
Stars: ✭ 60 (+172.73%)
Mutual labels:  bayesian, bayesian-statistics
models
Forecasting 🇫🇷 elections with Bayesian statistics 🥳
Stars: ✭ 24 (+9.09%)
Mutual labels:  bayesian-inference, bayesian-statistics
BayesHMM
Full Bayesian Inference for Hidden Markov Models
Stars: ✭ 35 (+59.09%)
Mutual labels:  bayesian, bayesian-inference

scikit-stan

Build Status codecov MIT license

What is scikit-stan

scikit-stan will enable you to use various bayesian models based on stan(http://mc-stan.org) and pystan with an elegant interface like a scikit-learn or keras.

Demo

import numpy as np

from skstan.regression.linear_models import LogisticRegression

if __name__ == '__main__':
    x = np.array(
        [
            [1,2,3,],
            [1,2,7,],
            [1,0,3,],
            [1,1,3,],
            [3,7,3,],
        ]
    )
    y = np.array([0,0,0,0,1])

    glm = LogisticRegression(shrinkage=10, chains=8)
    fit = glm.fit(x, y)

Then we got result object fit, and field stanfit is a stanfit object of pystan.

print(fit.stanfit)

It gives following

Inference for Stan model: anon_model_f63cd5ccdd67c22034b2490ae4c9cdd1.
4 chains, each with iter=2000; warmup=1000; thin=1; 
post-warmup draws per chain=1000, total post-warmup draws=4000.

           mean se_mean     sd   2.5%    25%    50%    75%  97.5%  n_eff   Rhat
alpha[0]   2.23    0.29   8.88 -14.39  -3.87   2.02   8.07  20.67    966    1.0
alpha[1]   7.81    0.18   5.29  -1.08   4.01   7.48  11.23  19.01    880    1.0
alpha[2]  -9.79    0.22   5.87 -22.91 -13.41  -9.37  -5.38  -0.17    728    1.0
beta      -2.48    0.29    9.8 -22.63  -9.03   -2.3   3.99  16.91   1146    1.0
yp[0]    -13.99    0.32  11.19 -40.69 -20.24 -11.35  -5.42    0.3   1259    1.0
yp[1]    -53.15    1.14  32.08 -128.4 -71.99 -48.46 -29.35  -5.24    790    1.0
yp[2]    -29.61     0.6  16.66 -67.24 -39.44 -27.97  -17.0  -4.37    771    1.0
yp[3]     -21.8    0.44  13.17 -52.98 -29.03 -19.57 -11.91  -3.23    894    1.0
yp[4]     29.51    0.69  24.68   0.58   10.3  23.36  42.72  90.17   1276    1.0
lp__      -2.16    0.05   1.48  -5.93   -2.9  -1.81  -1.07  -0.32    956    1.0

Samples were drawn using NUTS at Thu Apr 13 07:52:33 2017.
For each parameter, n_eff is a crude measure of effective sample size,
and Rhat is the potential scale reduction factor on split chains (at 
convergence, Rhat=1).

Result object of skstan also have prediction methods. Predicted values can be obtained as samples from distribution with a predict_dist method, because it is bayesian model.

yp_dist = fit.predict_dist(x)
print(yp_dist)

Then we got

array([[  2.63886682e-08,   5.23976746e-04,   5.54863097e-05, ...,
          2.46008578e-08,   3.74830192e-01,   3.45994043e-03],
       [  1.07746578e-22,   1.01664809e-18,   4.12813154e-26, ...,
          5.64992544e-19,   7.24386097e-12,   1.75795155e-23],
       [  8.04688037e-22,   4.44522113e-12,   1.42920488e-11, ...,
          7.71565191e-13,   5.13118658e-05,   4.26331280e-05],
       [  4.60810657e-15,   4.82743551e-08,   2.81612678e-08, ...,
          1.37772153e-10,   5.51614998e-03,   3.84594197e-04],
       [  9.99999998e-01,   1.00000000e+00,   1.00000000e+00, ...,
          9.99965378e-01,   1.00000000e+00,   1.00000000e+00]])

So let's check the histgram of first row with pandas.Series.

import pandas as pd
pd.Series(yp_dist[0]).hist(bins=20)

Histgram of first row

If you need a median of samples, you can get it with just predict method

yp = fit.predict(x)
print(yp)

gives

array([  1.17280235e-05,   9.01419773e-22,   7.16023732e-13,
         3.18368664e-09,   1.00000000e+00])

How to install

Install

Installers for the latest released version are available at PyPI.

pip3 install skstan

Install from sources

git clone https://github.com/BayesianFreaks/scikit-stan
cd scikit-stan
python3 setup.py install

Uninstall

pip3 uninstall scikit-stan

Using python2?

Are you joking?

We can't touch you because we are living in the future from you, and you're living in past ages. Please say hello to Nobunaga Oda.

We will always use newest features of the latest version of python, so you should use the latest version of python.

Models

Ready

Regression Models

  • Linear Regrassion
  • Poisson Regression
  • Logistic Regression

Next Steps

Regression Models

  • Gamma Regression
  • GLMM
  • etc...

Time Series Models

  • AR Model
  • MA Model
  • ARMA Model
  • ARIMA Model
  • ARCH Model
  • GARCH Model
  • TAR Model
  • State Space Model
  • or Some Dynamic Regression Models
  • etc...

Clustering Model

  • Gaussian Mixture Model
  • Latent Dirichlet Allocation
  • etc...

Particular Application

  • Modeling about online-advertisement
  • Decompose time series data
  • Empirical Bayesian Estimation
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].