FDAMDD Binary Classification Dashboard

DrugBank database
MolPort database
Python script number 84 to build the frequency distribution graph of the FDAMDD_c parameter on DrugBank molecules.
import matplotlib.pyplot as plt
import matplotlib.colors as mcolors
from matplotlib.patches import Patch
import numpy as np
from scipy.interpolate import PchipInterpolator

# 1. Original Data (FDAMDD - Categorical)
bins_mdd_c = np.array([0, 0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 1.0])
freq_mdd_c = np.array([3.10, 12.95, 7.56, 5.39, 4.03, 3.57, 3.52, 3.48, 3.06, 2.51, 3.27, 3.10, 2.93, 3.86, 4.76, 4.37, 5.31, 5.90, 7.64, 7.13, 2.55])

# 2. Dynamic Statistical Calculations
mean_val = np.average(bins_mdd_c, weights=freq_mdd_c)

# PCHIP Interpolation
interpolator = PchipInterpolator(bins_mdd_c, freq_mdd_c)
x_fit = np.linspace(0, 1.0, 500)
y_fit = np.clip(interpolator(x_fit), 0, None)

# 3. Colors
def get_colors(bins):
    return ['#008000' if b < 0.4 else '#FFD700' if b <= 0.7 else '#B22222' for b in bins]

colors_hex = get_colors(bins_mdd_c)
face_colors = [mcolors.to_rgba(c, alpha=0.60) for c in colors_hex]
edge_colors = [mcolors.to_rgba(c, alpha=0.90) for c in colors_hex]

# 4. Plot
plt.figure(figsize=(7, 6))

plt.bar(bins_mdd_c, freq_mdd_c,
        width=0.04,
        color=face_colors,
        edgecolor=edge_colors,
        linewidth=1.5,
        zorder=2)

# 5. Labels (FIX aquí)
plt.xlabel(r'FDAMDD Probability Score (Threshold: $\leq$ 0.01 mmol/kg/day)', fontsize=12)
plt.ylabel('% Frequency', fontsize=12)
plt.title('Binary Classification: Maximum Recommended Daily Dose', fontsize=14)

# 6. Legend (FIX aquí)
legend_elements = [
    Patch(facecolor=mcolors.to_rgba('#008000', 0.6), edgecolor='#008000', label='Negative (> 0.01 mmol/kg/d)'),
    Patch(facecolor=mcolors.to_rgba('#FFD700', 0.6), edgecolor='#FFD700', label='Borderline Probability'),
    Patch(facecolor=mcolors.to_rgba('#B22222', 0.6), edgecolor='#B22222', label=r'Positive ($\leq$ 0.01 mmol/kg/d)')
]

plt.legend(handles=legend_elements, loc='upper right', framealpha=0.95, fontsize=10)

# Axes
plt.grid(axis='y', linestyle=':', alpha=0.7, zorder=0)
plt.xlim(-0.05, 1.05)
plt.ylim(0, 14)

plt.tight_layout()
plt.show()