Boxplot
Model Accuracy
ML model performance comparison.
Output
Python
import matplotlib.pyplot as plt
import numpy as np
COLORS = {'rf': '#10B981', 'xgb': '#6366F1', 'nn': '#F59E0B', 'svm': '#EC4899', 'median': '#FFFFFF', 'background': '#FFFFFF', 'text': '#1E293B', 'text_muted': '#64748B', 'grid': '#F1F5F9'}
np.random.seed(42)
rf = np.clip(np.random.normal(0.92, 0.02, 30), 0.85, 0.98)
xgb = np.clip(np.random.normal(0.94, 0.015, 30), 0.88, 0.98)
nn = np.clip(np.random.normal(0.91, 0.025, 30), 0.82, 0.97)
svm = np.clip(np.random.normal(0.88, 0.03, 30), 0.78, 0.95)
fig, ax = plt.subplots(figsize=(10, 6), dpi=100)
ax.set_facecolor(COLORS['background'])
fig.patch.set_facecolor(COLORS['background'])
bp = ax.boxplot([rf, xgb, nn, svm], widths=0.5, patch_artist=True, showfliers=False,
medianprops=dict(color=COLORS['median'], linewidth=2))
colors = [COLORS['rf'], COLORS['xgb'], COLORS['nn'], COLORS['svm']]
for patch, color in zip(bp['boxes'], colors):
patch.set_facecolor(color)
patch.set_edgecolor('white')
ax.set_xticklabels(['Random Forest', 'XGBoost', 'Neural Net', 'SVM'])
ax.set_ylim(0.75, 1.0)
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
ax.spines['left'].set_color(COLORS['grid'])
ax.spines['bottom'].set_color(COLORS['grid'])
ax.yaxis.grid(True, color=COLORS['grid'], linewidth=1, zorder=0)
ax.set_axisbelow(True)
ax.tick_params(axis='both', colors=COLORS['text_muted'], labelsize=9, length=0, pad=8)
ax.set_ylabel('Accuracy', fontsize=10, color=COLORS['text'], labelpad=10)
plt.tight_layout()
plt.show()
Library
Matplotlib
Category
Statistical
☕