MyNixOS website logo
Description

Non-Parametric Sampling with Parallel Monte Carlo.

An implementation of a non-parametric statistical model using a parallelised Monte Carlo sampling scheme. The method implemented in this package allows non-parametric inference to be regularized for small sample sizes, while also being more accurate than approximations such as variational Bayes. The concentration parameter is an effective sample size parameter, determining the faith we have in the model versus the data. When the concentration is low, the samples are close to the exact Bayesian logistic regression method; when the concentration is high, the samples are close to the simplified variational Bayes logistic regression. The method is described in full in the paper Lyddon, Walker, and Holmes (2018), "Nonparametric learning from Bayesian models with randomized objective functions" <arXiv:1806.11544>.

PosteriorBootstrap

Project Status: Inactive – The project has reached a stable, usable state but is no longer being actively developed; support/maintenance will be provided as time allows. CRAN Status CRAN Downloads Package check Codecov test coverage

Bayesian learning is built on an assumption that the model space contains a true reflection of the data generating mechanism. This assumption can be problematic in complex data environments. By using a Bayesian non-parametric approach to learning, we no longer have to assume that the model is true.

This package implements a non-parametric statistical model using a parallelised Monte Carlo sampling scheme. The method implemented in this package allows non-parametric inference to be regularized for small sample sizes, while also being more accurate than approximations such as variational Bayes.

The concentration parameter is an effective sample size parameter, determining the faith we have in the model versus the data. When the concentration is low, the samples are close to the exact Bayesian logistic regression method; when the concentration is high, the samples are close to the simplified variational Bayes logistic regression.

Installation

This package is available on CRAN. The latest release can be installed using

install.packages("PosteriorBootstrap")

If you prefer to use the bleeding edge version, you can install from Github with devtools:

requireNamespace("devtools", quietly = TRUE)
devtools::install_github("https://github.com/alan-turing-institute/PosteriorBootstrap/")

Example usage and graphical result from the paper

Please see the provided vignette (at vignettes/PosteriorBootstrap.Rmd) for an example usage of the package to fit a logistic regression model to the Statlog German Credit dataset.

The vignette reproduces Figure 2, page 8, from Lyddon, Walker, and Holmes (2018), "Nonparametric learning from Bayesian models with randomized objective functions" (32nd Conference on Neural Information Processing Systems, Montréal, Canada). The vignette is limited to a concentration parameter of c = 500 and the figure below reproduces the one from the paper with the same concentration parameters.

Figure 2 from the paper, showing the tuning of the sampling close to exactinference or variational inference

The figure above shows the advantage of the package: one can tune the proximity of the sampling method to exact inference (Bayesian logistic regression) with a low c or to approximate inference (variational inference) with high c, or anywhere in between. As mentioned in page 3 of the paper, the concentration parameter c is an effective sample size, governing the trust we have in the parametric model.

Issues and bug reports

For any bug reports or feature requests, please open an issue on Github.

Parallelisation

The calculation of the expected speedup depends on the number of bootstrap samples and the number of processors. It also depends on the system: it is larger on macOS than on Linux, with some variation depending on the version of R. Please note that parallelisation is currently unsupported on Windows.

Fixing the number of samples corresponds to Ahmdal's law, or the speedup in the task as a function of the number of processors. The speedup S_latency of N processors is defined as the duration of the task with one core divided by the duration of the task with N processors. When using 100, 1000 and 10000 samples, the following speed-ups were observed:

Parallelisation speedup

Inverting Ahmdal's law gives the proportion of the execution time that is parallelisable from the speedup:

where S_latency is the execution speedup for the whole task (as defined above), and s is the speedup for the part of the task that can be parallelised. In this case, s is simply equal to the number of cores used, so repeatedly measuring S_latency for several choices of number of cores gives this plot:

Parallelisation proportion

The proportion of the code that can be parallelised is high, and higher the large the bootstrap samples, and always below 1. For large samples with n_bootstrap = 10000, the values are close to 100%.

Reproducing the results on Azure

To run the results in this section automatically, you'll need a Microsoft Azure subscription (one of the free subscriptions for example) and the Azure Command-Line Interface (CLI). You will need to login to your Azure account with the Azure CLI:

az login

then follow the instructions. You will need to create a resource group on portal.azure.com and make note of the name of the resource group. The default name of the resource group is PB for PosteriorBootstrap.

Then run the following on a shell with current directory at the root of the repository for deploying on a new machine:

azure/deploy.sh -g=<name of resource group> -k=<path to your private key>

or, to deploy on an existing machine:

azure/deploy.sh -i=<IP address> -g=<name of resource group> -k=<path to your private key>

The path to your private key defaults to ~/.ssh/azure if you do not specify it, and the public key is that path with the suffix .pub.

If you need to generate a private-public key pair, run:

ssh-keygen -t rsa -b 4096 -f ~/.ssh/azure
Metadata

Version

0.1.2

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows