Raincloud Plot

Machine Learning Model Accuracy by Algorithm

Cross-validation accuracy across ML models

Output
Machine Learning Model Accuracy by Algorithm
Python
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import ptitprince as pt

np.random.seed(112)
BG_COLOR = '#0a0a0f'
TEXT_COLOR = 'white'
COLORS = ['#5314E6', '#27D3F5', '#F5B027', '#F5276C']

models = ['Random Forest', 'XGBoost', 'Neural Net', 'SVM']
data = pd.DataFrame({
    'Accuracy': np.concatenate([
        np.random.beta(40, 8, 50) * 100,
        np.random.beta(45, 7, 50) * 100,
        np.random.beta(42, 9, 50) * 100,
        np.random.beta(38, 10, 50) * 100
    ]),
    'Model': ['Random Forest']*50 + ['XGBoost']*50 + ['Neural Net']*50 + ['SVM']*50
})

fig, ax = plt.subplots(figsize=(10, 6), facecolor=BG_COLOR)
ax.set_facecolor(BG_COLOR)

pt.RainCloud(x='Model', y='Accuracy', data=data, palette=COLORS,
             bw=.2, width_viol=.6, ax=ax, orient='h', alpha=.65,
             dodge=True, pointplot=False, move=.2)

ax.set_xlabel('Accuracy (%)', fontsize=12, color=TEXT_COLOR, fontweight='500')
ax.set_ylabel('Algorithm', fontsize=12, color=TEXT_COLOR, fontweight='500')
ax.set_title('ML Model Accuracy Comparison', fontsize=14, color=TEXT_COLOR, fontweight='bold', pad=15)

ax.tick_params(colors='#888', labelsize=10)
for spine in ax.spines.values():
    spine.set_color('#333')

plt.tight_layout()
plt.show()
Library

Matplotlib

Category

Statistical

Did this help you?

Support PyLucid to keep it free & growing

Support