Dynamically updating plots in Jupyter notebooks, e.g. for visualizing training progress.
Project description
trainplot
Dynamically updating plots in Jupyter notebooks, e.g. for visualizing training progress. Inspired by livelossplot. In comparison, trainplot has fewer options, but aims to be easier to use with better jupyter notebook support.
Trainplot outputs the matplotlib figure to an ipywidgets.Output
widget, so it doesn't interfere with other outputs like tqdm
or print statements. To avoid wasting resources and flickering, the figure is only updated with a given update_period
.
Installation
pip install trainplot
Usage
In your Jupyter notebook import it using:
from trainplot import TrainPlot
Then you can use it like this:
trainplot = TrainPlot()
for i in range(100):
trainplot(i = i+random.random()*10, root = i**.5*3)
time.sleep(0.1)
trainplot.close()
It also works with tqdm
and printing:
trainplot = TrainPlot()
for i in trange(50):
trainplot(i=i, root=i**.5)
if i % 10 == 0:
print(f'currently at {i} iterations')
time.sleep(0.1)
trainplot.close()
You can also add a bunch of custumizations, e.g.:
trainplot = TrainPlot(
update_period=.2,
fig_args=dict(nrows=2, ncols=2, figsize=(10, 8), gridspec_kw={'height_ratios': [1, 1], 'width_ratios': [1, 1]}),
plot_pos={'loss': (0, 0, 0), 'accuracy': (0, 1, 0), 'val_loss': (1, 0, 0), 'val_accuracy': (1, 1, 0)},
plot_args={'loss': {'color': 'orange'}, 'accuracy': {'color': 'green'}, 'val_loss': {'color': 'orange', 'label': 'validation loss'}, 'val_accuracy': {'color': 'green', 'label': 'validation accuracy'}},
)
for i in range(100, 200):
trainplot(step=i, loss=(i/100-2)**4, accuracy=i/2, val_loss=(i/100-2.1)**4, val_accuracy=i/2.1)
time.sleep(0.1)
trainplot.close()
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for trainplot-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0218b7ebabd83980e89823f4aad51fc04d4abd3fbd5a9d7d343f1ef0784d6609 |
|
MD5 | 52cbef9f398f70b1cb1318182466f277 |
|
BLAKE2b-256 | b980b72b1fbd7b902de006012f19972cca86a983bf4c1a428c6cac821ad9f677 |