Skip to content

Commit

Permalink
Change name
Browse files Browse the repository at this point in the history
  • Loading branch information
davidnabergoj committed May 20, 2022
1 parent 31f08c7 commit bc778dd
Show file tree
Hide file tree
Showing 13 changed files with 35 additions and 35 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Bootstrap your plot
# Bootplot: bootstrap your plot

**Bootstrap your plot** is a library that lets you easily visualize uncertainty. You only need to provide a function
that generates a plot from your data and pass it to `bootstrapped_plot`. This will generate a static image and an
**Bootplot** is a library that lets you easily visualize uncertainty. You only need to provide a function
that generates a plot from your data and pass it to `bootplot`. This will generate a static image and an
animation of your data uncertainty.

The method works by resampling the original dataset and plotting each bootstrapped sample.
Expand All @@ -14,7 +14,7 @@ line and visualize the uncertainty with the following code:
import numpy as np
from sklearn.linear_model import LinearRegression

from src import bootstrapped_plot
from bootplot import bootplot


def make_linear_regression(data_subset, data_full, ax):
Expand All @@ -41,7 +41,7 @@ if __name__ == '__main__':
dataset[:, 1] = dataset[:, 0] * 1.5 + 2 + noise

# Create image and animation that show uncertainty
bootstrapped_plot(
bootplot(
make_linear_regression,
dataset,
output_image_path='bootstrapped_linear_regression.png',
Expand Down
3 changes: 3 additions & 0 deletions bootplot/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from bootplot.sorting import sort_images, PCASorter, LucasKanadeSorter, HorizontalMassSorter, TravelingSalesmanSorter, \
FarnebackSorter
from bootplot.base import bootplot
24 changes: 12 additions & 12 deletions src/base.py → bootplot/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from tqdm import tqdm
from PIL import Image

from src.sorting import sort_images
from bootplot.sorting import sort_images


def fig_to_array(fig, ax):
Expand Down Expand Up @@ -50,17 +50,17 @@ def decay_images(images, m: int, decay_length: int):
return decayed_images


def bootstrapped_plot(f: callable,
data: np.ndarray,
m: int = 100,
output_size_px: Tuple[int, int] = (512, 512),
output_image_path: Union[str, Path] = None,
output_animation_path: Union[str, Path] = None,
sort_type: str = 'tsp',
sort_kwargs: dict = None,
decay: int = 0,
fps: int = 60,
verbose: bool = False):
def bootplot(f: callable,
data: np.ndarray,
m: int = 100,
output_size_px: Tuple[int, int] = (512, 512),
output_image_path: Union[str, Path] = None,
output_animation_path: Union[str, Path] = None,
sort_type: str = 'tsp',
sort_kwargs: dict = None,
decay: int = 0,
fps: int = 60,
verbose: bool = False):
px_size_inches = 1 / plt.rcParams['figure.dpi']
fig, ax = plt.subplots(figsize=(output_size_px[0] * px_size_inches, output_size_px[1] * px_size_inches))
bootstrapped_matrices = np.stack([
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/sorting.py → bootplot/sorting.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import scipy
import networkx as nx

from src.image_features import compute_hog_features, compute_center_of_mass, compute_center_of_mass_per_component
from bootplot.image_features import compute_hog_features, compute_center_of_mass, compute_center_of_mass_per_component


class Sorter(abc.ABC):
Expand Down
4 changes: 2 additions & 2 deletions demo/bar_chart.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import numpy as np
from src import bootstrapped_plot
from bootplot import bootplot


def make_bar_chart(data_subset, data_full, ax):
Expand All @@ -21,7 +21,7 @@ def make_bar_chart(data_subset, data_full, ax):
np.random.seed(0)

dataset = np.random.binomial(20, 0.3, size=1000)
bootstrapped_plot(
bootplot(
make_bar_chart,
dataset,
m=100,
Expand Down
4 changes: 2 additions & 2 deletions demo/linear_regression.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np
from sklearn.linear_model import LinearRegression

from src import bootstrapped_plot
from bootplot import bootplot


def make_linear_regression(data_subset, data_full, ax):
Expand All @@ -26,7 +26,7 @@ def make_linear_regression(data_subset, data_full, ax):
noise = np.random.randn(len(dataset)) * 2.5
dataset[:, 1] = dataset[:, 0] * 1.5 + 2 + noise

bootstrapped_plot(
bootplot(
make_linear_regression,
dataset,
m=100,
Expand Down
4 changes: 2 additions & 2 deletions demo/multiple_point_plot.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import numpy as np
from src import bootstrapped_plot
from bootplot import bootplot


def make_point_plot(data_subset, data_full, ax):
Expand Down Expand Up @@ -27,7 +27,7 @@ def make_point_plot(data_subset, data_full, ax):
j = float(np.random.randint(n_classes))
dataset[i] = [j, np.random.randn() * j]

bootstrapped_plot(
bootplot(
make_point_plot,
dataset,
m=100,
Expand Down
4 changes: 2 additions & 2 deletions demo/pie_chart.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import numpy as np
from src import bootstrapped_plot
from bootplot import bootplot


def make_pie_chart(data_subset, data_full, ax):
Expand Down Expand Up @@ -30,7 +30,7 @@ def make_pie_chart(data_subset, data_full, ax):

dataset = np.random.binomial(7, 0.2, size=1000)

bootstrapped_plot(
bootplot(
make_pie_chart,
dataset,
m=100,
Expand Down
4 changes: 2 additions & 2 deletions demo/polynomial_regression.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np
from sklearn.linear_model import LinearRegression
from sklearn.preprocessing import PolynomialFeatures
from src import bootstrapped_plot
from bootplot import bootplot


def make_polynomial_regression(data_subset, data_full, ax):
Expand Down Expand Up @@ -30,7 +30,7 @@ def make_polynomial_regression(data_subset, data_full, ax):
noise = np.random.randn(len(dataset)) * 2.5
dataset[:, 1] = dataset[:, 0] * 1.5 + 2 + noise

bootstrapped_plot(
bootplot(
make_polynomial_regression,
dataset,
m=100,
Expand Down
4 changes: 2 additions & 2 deletions demo/single_point_plot.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import numpy as np
from src import bootstrapped_plot
from bootplot import bootplot


def make_plot_demo_point_plot(data_subset, data_full, ax):
Expand All @@ -16,7 +16,7 @@ def make_plot_demo_point_plot(data_subset, data_full, ax):
n_observations = 1000
dataset = np.random.uniform(low=-5.5, high=5.5, size=(n_observations,))

mat = bootstrapped_plot(
mat = bootplot(
make_plot_demo_point_plot,
dataset,
m=100,
Expand Down
4 changes: 2 additions & 2 deletions demo/text.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np
from sklearn.linear_model import LinearRegression
from src import bootstrapped_plot
from bootplot import bootplot


def make_plot_demo_text(data_subset, data_full, ax):
Expand Down Expand Up @@ -32,7 +32,7 @@ def make_plot_demo_text(data_subset, data_full, ax):
noise = np.random.randn(len(dataset)) * 2.5
dataset[:, 1] = (dataset[:, 0] * 1.5 + noise) / 5 + 2.551

bootstrapped_plot(
bootplot(
make_plot_demo_text,
dataset,
m=100,
Expand Down
3 changes: 0 additions & 3 deletions src/__init__.py

This file was deleted.

0 comments on commit bc778dd

Please sign in to comment.