bootplot


Namebootplot JSON
Version 0.0.14 PyPI version JSON
download
home_pagehttps://github.com/davidnabergoj/bootplot
Summarybootplot is a package for black-box uncertainty visualization.
upload_time2025-07-30 22:28:47
maintainerNone
docs_urlNone
authorDavid Nabergoj, Erik Štrumbelj,
requires_python>=3.8
licenseMIT
keywords bootplot visualization uncertainty bootstrap
VCS
bugtrack_url
requirements numpy imageio imageio-ffmpeg matplotlib tqdm pillow scipy scikit-image networkx scikit-learn opencv-python pandas
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ![logo](https://raw.githubusercontent.com/davidnabergoj/bootplot/master/logo.png)

[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/davidnabergoj/bootplot/blob/main/LICENSE)
[![Documentation Status](https://readthedocs.org/projects/bootplot/badge/?version=latest)](https://bootplot.readthedocs.io/en/latest/?badge=latest)
[![build](https://github.com/davidnabergoj/bootplot/actions/workflows/build.yml/badge.svg)](https://github.com/davidnabergoj/bootplot/actions/workflows/build.yml)
[![tests](https://github.com/davidnabergoj/bootplot/actions/workflows/tests.yml/badge.svg)](https://github.com/davidnabergoj/bootplot/actions/workflows/tests.yml)

**bootplot** is a package for black-box uncertainty visualization. 
By providing a dataset and a plotting function, **bootplot** automatically generates a static image and an animation of your uncertainty.

The method works by resampling the original dataset using bootstrap and plotting each bootstrapped sample.
The plots are then combined into a single image or an animation.
**bootplot** is also especially useful when dealing with small datasets, since it
relies on the bootstrap method which robustly estimates uncertainty using resampling.

**bootplot** supports datasets represented as numpy arrays or pandas dataframes. 
Supported image output formats include popular formats such as JPG, PNG, BMP. Supported animation formats include popular formats such as GIF and MP4.
<!--For a complete list of formats, see the [Pillow documentation](https://pillow.readthedocs.io/en/stable/handbook/image-file-formats.html) and the [FFMPEG documentation](https://ffmpeg.org/ffmpeg-formats.html).-->

## Installation

**bootplot** requires Python version 3.8 or greater. You can install it using:

```
pip install bootplot
```

Alternatively, you can install **bootplot** using:

```
git clone https://github.com/davidnabergoj/bootplot
cd bootplot
python setup.py install
```

## Example

Suppose we have some data and their corresponding targets. We can model our targets with a regression
line and visualize the uncertainty with the following code:

```python 
import numpy as np
from sklearn.linear_model import LinearRegression

from bootplot import bootplot


def plot_regression(data_subset, data_full, ax):
    # Plot full dataset
    ax.scatter(data_full[:, 0], data_full[:, 1])

    # Plot regression line trained on the subset
    lr = LinearRegression()
    lr.fit(data_subset[:, 0].reshape(-1, 1), data_subset[:, 1])
    ax.plot([-10, 10], lr.predict([[-10], [10]]), c='r')
    
    # Show root mean squared error in a text box
    rmse = np.sqrt(np.mean(np.square(data_subset[:, 1] - lr.predict(data_subset[:, 0].reshape(-1, 1)))))
    bbox_kwargs = dict(facecolor='none', edgecolor='black', pad=10.0)
    ax.text(x=0, y=-8, s=f'RMSE: {rmse:.4f}', fontsize=12, ha='center', bbox=bbox_kwargs)

    ax.set_xlim(-10, 10)
    ax.set_ylim(-10, 10)

if __name__ == '__main__':
    np.random.seed(0)

    # Dataset to be modeled
    dataset = np.random.randn(100, 2)
    noise = np.random.randn(len(dataset)) * 2.5
    dataset[:, 1] = dataset[:, 0] * 1.5 + 2 + noise

    # Create image and animation that show uncertainty
    bootplot(
        plot_regression,
        dataset,
        output_image_path='demo_image.png',
        output_animation_path='demo_animation.gif',
        verbose=True
    )
```

This will generate a static image and an animation, as shown below.
The static image on points shows the full scattered dataset in blue and regression lines that correspond to each
bootstrapped sample of the dataset in red.
The spread of regression lines represents uncertainty according to the bootstrap process.
We can also see the uncertainty in root mean squared error (RMSE).
We see that only the first digit of RMSE is significant, since the decimal part is blurred.
The animation on the right displays uncertainty by iterating over a sequence of plots containing regression lines.

<table>
    <tr>
        <td><img src="https://raw.githubusercontent.com/davidnabergoj/bootplot/master/demo_image.png"></td>
        <td><img src="https://raw.githubusercontent.com/davidnabergoj/bootplot/master/demo_animation.gif"></td>
    </tr>
</table>

See the [examples](examples) folder for more examples, including bar charts, point plots, polynomial regression models, pie charts, text plots and pandas dataframes.

## Documentation

Read the documentation and check out tutorials at https://bootplot.readthedocs.io/en/latest/

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/davidnabergoj/bootplot",
    "name": "bootplot",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "bootplot, visualization, uncertainty, bootstrap",
    "author": "David Nabergoj, Erik \u0160trumbelj,",
    "author_email": "davidnabergoj4@gmail.com,",
    "download_url": "https://files.pythonhosted.org/packages/29/e6/b591f052de32a93e01c8fc6e23a7d69291876be70d6fded9ef044c61e006/bootplot-0.0.14.tar.gz",
    "platform": null,
    "description": "![logo](https://raw.githubusercontent.com/davidnabergoj/bootplot/master/logo.png)\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/davidnabergoj/bootplot/blob/main/LICENSE)\n[![Documentation Status](https://readthedocs.org/projects/bootplot/badge/?version=latest)](https://bootplot.readthedocs.io/en/latest/?badge=latest)\n[![build](https://github.com/davidnabergoj/bootplot/actions/workflows/build.yml/badge.svg)](https://github.com/davidnabergoj/bootplot/actions/workflows/build.yml)\n[![tests](https://github.com/davidnabergoj/bootplot/actions/workflows/tests.yml/badge.svg)](https://github.com/davidnabergoj/bootplot/actions/workflows/tests.yml)\n\n**bootplot** is a package for black-box uncertainty visualization. \nBy providing a dataset and a plotting function, **bootplot** automatically generates a static image and an animation of your uncertainty.\n\nThe method works by resampling the original dataset using bootstrap and plotting each bootstrapped sample.\nThe plots are then combined into a single image or an animation.\n**bootplot** is also especially useful when dealing with small datasets, since it\nrelies on the bootstrap method which robustly estimates uncertainty using resampling.\n\n**bootplot** supports datasets represented as numpy arrays or pandas dataframes. \nSupported image output formats include popular formats such as JPG, PNG, BMP. Supported animation formats include popular formats such as GIF and MP4.\n<!--For a complete list of formats, see the [Pillow documentation](https://pillow.readthedocs.io/en/stable/handbook/image-file-formats.html) and the [FFMPEG documentation](https://ffmpeg.org/ffmpeg-formats.html).-->\n\n## Installation\n\n**bootplot** requires Python version 3.8 or greater. You can install it using:\n\n```\npip install bootplot\n```\n\nAlternatively, you can install **bootplot** using:\n\n```\ngit clone https://github.com/davidnabergoj/bootplot\ncd bootplot\npython setup.py install\n```\n\n## Example\n\nSuppose we have some data and their corresponding targets. We can model our targets with a regression\nline and visualize the uncertainty with the following code:\n\n```python \nimport numpy as np\nfrom sklearn.linear_model import LinearRegression\n\nfrom bootplot import bootplot\n\n\ndef plot_regression(data_subset, data_full, ax):\n    # Plot full dataset\n    ax.scatter(data_full[:, 0], data_full[:, 1])\n\n    # Plot regression line trained on the subset\n    lr = LinearRegression()\n    lr.fit(data_subset[:, 0].reshape(-1, 1), data_subset[:, 1])\n    ax.plot([-10, 10], lr.predict([[-10], [10]]), c='r')\n    \n    # Show root mean squared error in a text box\n    rmse = np.sqrt(np.mean(np.square(data_subset[:, 1] - lr.predict(data_subset[:, 0].reshape(-1, 1)))))\n    bbox_kwargs = dict(facecolor='none', edgecolor='black', pad=10.0)\n    ax.text(x=0, y=-8, s=f'RMSE: {rmse:.4f}', fontsize=12, ha='center', bbox=bbox_kwargs)\n\n    ax.set_xlim(-10, 10)\n    ax.set_ylim(-10, 10)\n\nif __name__ == '__main__':\n    np.random.seed(0)\n\n    # Dataset to be modeled\n    dataset = np.random.randn(100, 2)\n    noise = np.random.randn(len(dataset)) * 2.5\n    dataset[:, 1] = dataset[:, 0] * 1.5 + 2 + noise\n\n    # Create image and animation that show uncertainty\n    bootplot(\n        plot_regression,\n        dataset,\n        output_image_path='demo_image.png',\n        output_animation_path='demo_animation.gif',\n        verbose=True\n    )\n```\n\nThis will generate a static image and an animation, as shown below.\nThe static image on points shows the full scattered dataset in blue and regression lines that correspond to each\nbootstrapped sample of the dataset in red.\nThe spread of regression lines represents uncertainty according to the bootstrap process.\nWe can also see the uncertainty in root mean squared error (RMSE).\nWe see that only the first digit of RMSE is significant, since the decimal part is blurred.\nThe animation on the right displays uncertainty by iterating over a sequence of plots containing regression lines.\n\n<table>\n    <tr>\n        <td><img src=\"https://raw.githubusercontent.com/davidnabergoj/bootplot/master/demo_image.png\"></td>\n        <td><img src=\"https://raw.githubusercontent.com/davidnabergoj/bootplot/master/demo_animation.gif\"></td>\n    </tr>\n</table>\n\nSee the [examples](examples) folder for more examples, including bar charts, point plots, polynomial regression models, pie charts, text plots and pandas dataframes.\n\n## Documentation\n\nRead the documentation and check out tutorials at https://bootplot.readthedocs.io/en/latest/\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "bootplot is a package for black-box uncertainty visualization.",
    "version": "0.0.14",
    "project_urls": {
        "Bug Tracker": "https://github.com/davidnabergoj/bootplot/issues",
        "Download": "https://github.com/davidnabergoj/bootplot/releases",
        "Homepage": "https://github.com/davidnabergoj/bootplot"
    },
    "split_keywords": [
        "bootplot",
        " visualization",
        " uncertainty",
        " bootstrap"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "6e2dc07f85324f25243db0829cafe8f6652b53c0363e24185132e492f695ffcf",
                "md5": "398b13c5c105e466cb2c2b3c657900e5",
                "sha256": "6de86070baa1a968c2370a8ad1cb88a32dfd7472c059492f24290141c3d06379"
            },
            "downloads": -1,
            "filename": "bootplot-0.0.14-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "398b13c5c105e466cb2c2b3c657900e5",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 14988,
            "upload_time": "2025-07-30T22:28:46",
            "upload_time_iso_8601": "2025-07-30T22:28:46.390655Z",
            "url": "https://files.pythonhosted.org/packages/6e/2d/c07f85324f25243db0829cafe8f6652b53c0363e24185132e492f695ffcf/bootplot-0.0.14-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "29e6b591f052de32a93e01c8fc6e23a7d69291876be70d6fded9ef044c61e006",
                "md5": "1d0c1b2c9df09a6276611ad02535a3ef",
                "sha256": "5b85d5960f3cf0aaca9a31d25cd4071c3fffbc5dd4b93f1fbdcffd88f88c3588"
            },
            "downloads": -1,
            "filename": "bootplot-0.0.14.tar.gz",
            "has_sig": false,
            "md5_digest": "1d0c1b2c9df09a6276611ad02535a3ef",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 14113,
            "upload_time": "2025-07-30T22:28:47",
            "upload_time_iso_8601": "2025-07-30T22:28:47.543000Z",
            "url": "https://files.pythonhosted.org/packages/29/e6/b591f052de32a93e01c8fc6e23a7d69291876be70d6fded9ef044c61e006/bootplot-0.0.14.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-30 22:28:47",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "davidnabergoj",
    "github_project": "bootplot",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "numpy",
            "specs": [
                [
                    "<",
                    "2"
                ],
                [
                    ">=",
                    "1.3"
                ]
            ]
        },
        {
            "name": "imageio",
            "specs": [
                [
                    "~=",
                    "2.9.0"
                ]
            ]
        },
        {
            "name": "imageio-ffmpeg",
            "specs": [
                [
                    "==",
                    "0.4.7"
                ]
            ]
        },
        {
            "name": "matplotlib",
            "specs": [
                [
                    ">=",
                    "3"
                ]
            ]
        },
        {
            "name": "tqdm",
            "specs": [
                [
                    "~=",
                    "4.64.0"
                ]
            ]
        },
        {
            "name": "pillow",
            "specs": [
                [
                    ">=",
                    "8"
                ]
            ]
        },
        {
            "name": "scipy",
            "specs": [
                [
                    ">=",
                    "1.5"
                ]
            ]
        },
        {
            "name": "scikit-image",
            "specs": [
                [
                    ">=",
                    "0.17"
                ]
            ]
        },
        {
            "name": "networkx",
            "specs": [
                [
                    ">=",
                    "2.7.1"
                ]
            ]
        },
        {
            "name": "scikit-learn",
            "specs": [
                [
                    ">=",
                    "0.24"
                ]
            ]
        },
        {
            "name": "opencv-python",
            "specs": [
                [
                    "~=",
                    "4.5.5"
                ]
            ]
        },
        {
            "name": "pandas",
            "specs": [
                [
                    "~=",
                    "1.4.3"
                ]
            ]
        }
    ],
    "lcname": "bootplot"
}
        
Elapsed time: 0.85726s