Boxplot

Neural Network Loss

Training loss distribution across model architectures

Output
Neural Network Loss
Python
import matplotlib.pyplot as plt
import numpy as np

np.random.seed(42)
models = ['ResNet', 'VGG', 'Transformer', 'LSTM', 'GAN']
data = [
    np.random.lognormal(-2, 0.5, 200),
    np.random.lognormal(-1.8, 0.6, 200),
    np.random.lognormal(-2.2, 0.4, 200),
    np.random.lognormal(-1.5, 0.7, 200),
    np.random.lognormal(-1, 0.8, 200)
]

fig, ax = plt.subplots(figsize=(10, 6), dpi=100)
ax.set_facecolor('#0a0a0f')
fig.patch.set_facecolor('#0a0a0f')

colors = ['#F5276C', '#F54927', '#F5B027', '#27D3F5', '#6CF527']
bp = ax.boxplot(data, widths=0.6, patch_artist=True, showfliers=False,
                medianprops=dict(color='white', linewidth=2))

for patch, color in zip(bp['boxes'], colors):
    patch.set_facecolor(color)
    patch.set_alpha(0.75)
    patch.set_edgecolor(color)
for i, color in enumerate(colors):
    bp['whiskers'][i*2].set_color(color)
    bp['whiskers'][i*2+1].set_color(color)
    bp['caps'][i*2].set_color(color)
    bp['caps'][i*2+1].set_color(color)

ax.set_yscale('log')
ax.set_xticklabels(models)
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
ax.spines['left'].set_color('#333333')
ax.spines['bottom'].set_color('#333333')
ax.yaxis.grid(True, color='#1a1a2e', linewidth=0.5, zorder=0)
ax.set_axisbelow(True)
ax.tick_params(axis='both', colors='#888888', labelsize=9, length=0, pad=8)
ax.set_ylabel('Training Loss (log)', fontsize=11, color='white', fontweight='500')
ax.set_title('Neural Network Training Loss Comparison', fontsize=14, color='white', fontweight='bold', pad=15)

plt.tight_layout()
plt.show()
Library

Matplotlib

Category

Statistical

Did this help you?

Support PyLucid to keep it free & growing

Support