diff --git a/.github/workflows/notebook_smoke.yml b/.github/workflows/notebook_smoke.yml
index b5e9fd1..312a5df 100644
--- a/.github/workflows/notebook_smoke.yml
+++ b/.github/workflows/notebook_smoke.yml
@@ -1,5 +1,8 @@
name: notebooks
-
+
+env:
+ CI_SMOKE: True
+
on:
pull_request:
branches:
diff --git a/examples/GP_sGP.ipynb b/examples/GP_sGP.ipynb
index dac0f28..b137b25 100644
--- a/examples/GP_sGP.ipynb
+++ b/examples/GP_sGP.ipynb
@@ -1,1162 +1,694 @@
{
- "nbformat": 4,
- "nbformat_minor": 0,
- "metadata": {
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "colab_type": "text",
+ "id": "view-in-github"
+ },
+ "source": [
+ ""
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# For github continuous integration only\n",
+ "# Please ignore if you're running this notebook!\n",
+ "import os\n",
+ "if os.environ.get(\"CI_SMOKE\"):\n",
+ " NUM_WARMUP = 100\n",
+ " NUM_SAMPLES = 100\n",
+ "else:\n",
+ " NUM_WARMUP = 2000\n",
+ " NUM_SAMPLES = 2000"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "NtiDY7RcohrR"
+ },
+ "source": [
+ "# Structured Gaussian Process\n",
+ "\n",
+ "This notebook compares vanilla and structured Gaussian processes for reconstructing and active learning of function characterized by a discontinuous behavior at some \"transition\" point.\n",
+ "\n",
+ "*Prepared by Maxim Ziatdinov (2022). Last updated in October 2023.*"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "vUoeZ9Tin74Q"
+ },
+ "source": [
+ "In the previous [example](https://colab.research.google.com/github/ziatdinovmax/gpax/blob/main/examples/simpleGP.ipynb), we have introduced Gaussian process (GP) operating in a fully Bayesian mode for reconstucting, with quantified uncertainty, an unknown function from sparse measurements. The limitation of the standard GP is that it does not usually allow for the incorporation of prior domain knowledge and can be biased toward a trivial interpolative solution. Recently, we introduced a structured Gaussian Process (sGP), where a classical GP is augmented by a structured probabilistic model of the expected system’s behavior. This approach allows us to balance the flexibility of the non-parametric GP approach with a rigid structure of prior (physical) knowledge encoded into the parametric model. Implementation-wise, this is achieved by substituting a zero prior mean function in GP with a probabilistic model of the expected system's behavior."
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "HdtH0tCPQ2de"
+ },
+ "source": [
+ "## Install & Import"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "86iUwKxLO7qE"
+ },
+ "source": [
+ "Install the latest GPax package from PyPI (this is best practice, as it installs the latest, deployed and tested version)."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
"colab": {
- "name": "GP_sGP.ipynb",
- "provenance": [],
- "collapsed_sections": [],
- "include_colab_link": true
- },
- "kernelspec": {
- "name": "python3",
- "display_name": "Python 3"
- },
- "language_info": {
- "name": "python"
- }
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "VQ1rLUzqha2i",
+ "outputId": "44157aab-4e21-4966-ec79-ccf85cd4bbaa"
+ },
+ "outputs": [],
+ "source": [
+ "!pip install gpax"
+ ]
},
- "cells": [
- {
- "cell_type": "markdown",
- "metadata": {
- "id": "view-in-github",
- "colab_type": "text"
- },
- "source": [
- ""
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "# Structured Gaussian Process\n",
- "\n",
- "This notebook compares vanilla and structured Gaussian processes for reconstructing and active learning of function characterized by a discontinuous behavior at some \"transition\" point.\n",
- "\n",
- "*Prepared by Maxim Ziatdinov (2022)*"
- ],
- "metadata": {
- "id": "NtiDY7RcohrR"
- }
- },
- {
- "cell_type": "markdown",
- "source": [
- "In the previous [example](https://colab.research.google.com/github/ziatdinovmax/gpax/blob/main/examples/simpleGP.ipynb), we have introduced Gaussian process (GP) operating in a fully Bayesian mode for reconstucting, with quantified uncertainty, an unknown function from sparse measurements. The limitation of the standard GP is that it does not usually allow for the incorporation of prior domain knowledge and can be biased toward a trivial interpolative solution. Recently, we introduced a structured Gaussian Process (sGP), where a classical GP is augmented by a structured probabilistic model of the expected system’s behavior. This approach allows us to balance the flexibility of the non-parametric GP approach with a rigid structure of prior (physical) knowledge encoded into the parametric model. Implementation-wise, this is achieved by substituting a zero prior mean function in GP with a probabilistic model of the expected system's behavior."
- ],
- "metadata": {
- "id": "vUoeZ9Tin74Q"
- }
- },
- {
- "cell_type": "markdown",
- "source": [
- "Install GPax:"
- ],
- "metadata": {
- "id": "Tbu3IG5bn4Xy"
- }
- },
- {
- "cell_type": "code",
- "metadata": {
- "colab": {
- "base_uri": "https://localhost:8080/"
- },
- "id": "VQ1rLUzqha2i",
- "outputId": "1264b71a-e46b-4ea0-a36a-c12f1f828fed"
- },
- "source": [
- "!pip install -q git+https://github.com/ziatdinovmax/gpax"
- ],
- "execution_count": 1,
- "outputs": [
- {
- "output_type": "stream",
- "name": "stdout",
- "text": [
- "\u001b[K |████████████████████████████████| 291 kB 4.6 MB/s \n",
- "\u001b[K |████████████████████████████████| 342 kB 38.6 MB/s \n",
- "\u001b[?25h Building wheel for gpax (setup.py) ... \u001b[?25l\u001b[?25hdone\n"
- ]
- }
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "id": "vygoK7MTjJWB"
- },
- "source": [
- "Imports:"
- ]
- },
- {
- "cell_type": "code",
- "metadata": {
- "id": "KtGDc11Ehh7r"
- },
- "source": [
- "import gpax\n",
- "import numpy as np\n",
- "import matplotlib.pyplot as plt\n",
- "\n",
- "gpax.utils.enable_x64()"
- ],
- "execution_count": 2,
- "outputs": []
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "id": "ZSaWCRHJPukv"
- },
- "source": [
- "## Standard and structured GP"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "id": "D6vVHZKpxse_"
- },
- "source": [
- "We consider noisy observations of a discontinuous function... "
- ]
- },
- {
- "cell_type": "code",
- "metadata": {
- "id": "LF2l_UcBtaDT",
- "colab": {
- "base_uri": "https://localhost:8080/",
- "height": 400
- },
- "outputId": "4736900d-f587-449b-b37d-609bc98ed028"
- },
- "source": [
- "def piecewise1(x: np.ndarray, params) -> np.ndarray:\n",
- " return np.piecewise(\n",
- " x,\n",
- " [x < params[\"t\"], x >= params[\"t\"]],\n",
- " [lambda x: x**params[\"beta1\"], lambda x: x**params[\"beta2\"]])\n",
- "\n",
- "\n",
- "NUM_INIT_POINTS = 15 # number of observation points\n",
- "NOISE_LEVEL = 0.1\n",
- "PARAMS = {\"t\": 1.7, \"beta1\": 4.5, \"beta2\": 2.5}\n",
- "\n",
- "np.random.seed(1)\n",
- "X = np.random.uniform(0, 3, NUM_INIT_POINTS)\n",
- "y = piecewise1(X, PARAMS) + np.random.normal(0., NOISE_LEVEL, NUM_INIT_POINTS)\n",
- "\n",
- "X_test = np.linspace(0, 3, 200)\n",
- "\n",
- "_, ax = plt.subplots(dpi=100) \n",
- "ax.scatter(X, y, alpha=0.5, c='k', marker='x', label=\"Noisy observations\")\n",
- "ax.legend()\n",
- "ax.set_xlabel(\"$x$\")\n",
- "ax.set_ylabel(\"$y$\")\n",
- "ax.set_xlim(0, 3)"
- ],
- "execution_count": 8,
- "outputs": [
- {
- "output_type": "execute_result",
- "data": {
- "text/plain": [
- "(0.0, 3.0)"
- ]
- },
- "metadata": {},
- "execution_count": 8
- },
- {
- "output_type": "display_data",
- "data": {
- "text/plain": [
- "