Giter Site home page Giter Site logo

cwgp's Introduction

Compositionally Warped Gaussian Processes

This package is dedicated to realizing methods used in this paper.

TLDR;

A package that transforms anything to a Gaussian process.

Installation

pip install CWGP

Quick Start

Let's randomly generate 100 numbers following an exponential distribution.

import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt

exp = np.random.exponential(scale=5, size=50)
idx = np.arange(50)

We now instantiate a CWGP class consisting of 3 Sinh-Arcsinh transformations.

from cwgp.cwgp import CWGP

compgp = CWGP(["sa","box_cox"])

We then fit our data into the model. This minimizes the negative log likelihood function and stores the corresponding parameters for us.

compgp.fit(exp, idx)

To get the parameters, we do

params = compgp.phi.res.x

We then transform the data via

t_exp, d = compgp.phi.comp_phi(params, exp)
sns.distplot(t_exp)
plt.show()

Let's make a QQ-plot and see how Gaussian it is.

from scipy import stats

stats.probplot(t_exp, dist="norm", plot=plt)
plt.show()

The inverse function is also implemented.

inv_t_exp = compgp.phi.inv_comp_phi(params, t_exp)
fig, ax = plt.subplots(1, 2)
sns.distplot(inv_t_exp, ax=ax[0])
sns.distplot(exp, ax=ax[1])
plt.show()

The one on the left is the one being transformed and transformed-back, and the one on the right is the original distribution. They should be exactly the same.

Transformations

Sinh-Arcsinh (sa)

from cwgp.transformations import sa

Arcsinh (asinh)

from cwgp.transformations import asinh

Box-Cox (box_cox)

from cwgp.transformations import box_cox

Sinh-Arcsinh and Affine (SAL)

from cwgp.transformations import sal

cwgp's People

Contributors

andy971022 avatar

Stargazers

 avatar Yang Liu avatar Sagabong avatar  avatar  avatar  avatar  avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.