Loading
Loading
Data without visualization is blind numbers. Matplotlib transforms those numbers into charts that instantly reveal patterns.
import matplotlib.pyplot as plt
fig, ax = plt.subplots(figsize=(8, 5))
ax.plot([1, 2, 3, 4], [10, 20, 15, 25])
ax.set_title("Chart Title")
ax.set_xlabel("X Axis")
ax.set_ylabel("Y Axis")
plt.tight_layout()
plt.show()
epochs = range(1, 11)
train_loss = [2.5, 1.8, 1.3, 1.0, 0.8, 0.65, 0.55, 0.48, 0.43, 0.40]
val_loss = [2.6, 2.0, 1.5, 1.2, 1.0, 0.90, 0.85, 0.82, 0.80, 0.79]
fig, ax = plt.subplots(figsize=(9, 5))
ax.plot(epochs, train_loss, label="Train", color="blue", lw=2)
ax.plot(epochs, val_loss, label="Validation", color="orange", lw=2, ls="--")
ax.set_title("Training vs Validation Loss")
ax.legend(); ax.grid(True, alpha=0.3)
plt.show()
models = ["GPT-4", "Claude", "Gemini", "Llama 3"]
scores = [91.2, 93.7, 90.5, 88.9]
fig, ax = plt.subplots(figsize=(8, 5))
ax.bar(models, scores,
color=["#4285F4","#FF6B35","#34A853","#EA4335"])
ax.set_title("AI Model Performance Comparison")
ax.set_ylim(85, 97)
plt.show()
import numpy as np
np.random.seed(42)
experience = np.random.randint(1, 15, 50)
salary = experience * 1200 + np.random.randn(50) * 2000
fig, ax = plt.subplots(figsize=(8, 5))
ax.scatter(experience, salary, alpha=0.7, s=80)
ax.set_title("Experience vs Salary")
plt.show()
scores = np.random.normal(loc=75, scale=12, size=200)
fig, ax = plt.subplots(figsize=(8, 5))
ax.hist(scores, bins=20, color="#4A90E2", edgecolor="white")
ax.axvline(scores.mean(), color="red", ls="--", lw=2)
ax.set_title("Student Score Distribution")
plt.show()
fig, axes = plt.subplots(1, 2, figsize=(12, 5))
axes[0].plot(range(10), [x**2 for x in range(10)])
axes[1].bar(["A","B","C"], [30,50,20])
plt.tight_layout(); plt.show()
fig.savefig("chart.png", dpi=150, bbox_inches="tight")
# ─── لوحة تحليل نموذج AI الشاملة ───
import matplotlib.pyplot as plt
import numpy as np
np.random.seed(42)
epochs = np.arange(1, 31)
train_loss = 2.5 * np.exp(-0.15 * epochs) + np.random.randn(30) * 0.03
val_loss = 2.5 * np.exp(-0.13 * epochs) + np.random.randn(30) * 0.04 + 0.1
train_acc = 1 - train_loss / 3
val_acc = 1 - val_loss / 3
models_cmp = ["GPT-4", "Claude", "Gemini", "Llama 3", "Mistral"]
acc_cmp = [91.2, 93.7, 90.5, 88.9, 87.1]
conf_mat = np.array([[45,3,2],[4,38,3],[1,2,42]])
fig, axes = plt.subplots(2, 2, figsize=(14, 9))
fig.suptitle("لوحة تحليل النموذج الشاملة", fontsize=15, fontweight="bold")
# 1. Loss curves
axes[0,0].plot(epochs, train_loss, label="Train", color="#2196F3", lw=2)
axes[0,0].plot(epochs, val_loss, label="Val", color="#FF5722", lw=2, ls="--")
axes[0,0].set_title("منحنى الـ Loss")
axes[0,0].legend(); axes[0,0].grid(True, alpha=0.3)
# 2. Accuracy curves
axes[0,1].plot(epochs, train_acc*100, label="Train", color="#4CAF50", lw=2)
axes[0,1].plot(epochs, val_acc*100, label="Val", color="#9C27B0", lw=2, ls="--")
axes[0,1].set_title("منحنى الدقة")
axes[0,1].legend(); axes[0,1].grid(True, alpha=0.3)
# 3. Model comparison
clrs = ["#4285F4","#FF6B35","#34A853","#EA4335","#673AB7"]
bars = axes[1,0].bar(models_cmp, acc_cmp, color=clrs)
for b, s in zip(bars, acc_cmp):
axes[1,0].text(b.get_x()+b.get_width()/2, b.get_height()+0.1,
f"{s}%", ha="center", fontsize=8, fontweight="bold")
axes[1,0].set_title("مقارنة النماذج"); axes[1,0].set_ylim(84, 97)
axes[1,0].tick_params(axis="x", labelsize=8)
# 4. Confusion matrix
im = axes[1,1].imshow(conf_mat, cmap="Blues")
axes[1,1].set_title("Confusion Matrix")
cls = ["Cat","Dog","Bird"]
axes[1,1].set_xticks(range(3)); axes[1,1].set_xticklabels(cls)
axes[1,1].set_yticks(range(3)); axes[1,1].set_yticklabels(cls)
for i in range(3):
for j in range(3):
axes[1,1].text(j, i, conf_mat[i,j], ha="center", va="center",
fontweight="bold",
color="white" if conf_mat[i,j] > 30 else "black")
plt.colorbar(im, ax=axes[1,1])
plt.tight_layout()
plt.savefig("model_dashboard.png", dpi=120, bbox_inches="tight")
plt.show()
print("✅ تم حفظ اللوحة في model_dashboard.png")