ملف:Traintest.svg

محتويات الصفحة غير مدعومة بلغات أخرى.
من ويكيبيديا، الموسوعة الحرة

الملف الأصلي(ملف SVG، أبعاده 720 × 270 بكسل، حجم الملف: 35 كيلوبايت)

ملخص

الوصف
English: Plots showing a training set and a test set from the same statistical population. Two curves are fit to the training set, one of which is an overfit. By plotting these curves with the test data, the overfitting can be seen.
التاريخ
المصدر عمل شخصي
المؤلف Skbkekas
إصدارات أخرى

[عدل]

SVG منشأ الملف
InfoField
 
الشيفرة المصدرية لهذا الرسم المتجه صالحة.
 
هذا الرسم المتجهي أُنشئ بواسطة Matplotlib
نص برمجي مصدري
InfoField

Python code

import numpy as np
import matplotlib.pyplot as plt

m = 0.2 ## mesh on the abscissa
s = 3 ## standard deviation of errors

def pdesign(X, d):
    """Generate a polynomial design matrix on X of order d."""
    V = X[:,np.newaxis]
    F = [V**k for k in range(d+1)]
    D = np.concatenate(F, axis=1)
    return D

def regfit(Y, D):
    """Regress Y on D using least squares."""
    U,S,Vt = np.linalg.svd(D,0)
    V = np.transpose(Vt)
    return np.dot(U, np.dot(np.transpose(U), Y))

X = np.arange(-2, 2, m, dtype=np.float64)

D1 = pdesign(X, 3)
D2 = pdesign(X, 13)

EY = X + X**3
Y1 = EY + np.random.normal(size=len(X))*s
Y2 = EY + np.random.normal(size=len(X))*s

Yhat1 = regfit(Y1, D1)
Yhat2 = regfit(Y1, D2)

plt.clf()
plt.figure(figsize=(8,3))
ax1 = plt.axes([0.06,0.1,0.4,0.8])
plt.title("Training set")
plt.plot(X, Y1, 'o')
plt.hold(True)
plt.plot(X, Yhat1, '-', color='green')
plt.plot(X, Yhat2, '-', color='orange')
ax1.set_ylim(-10, 10)
ax1.set_xticks([-2,-1,0,1,2])
ax2 = plt.axes([0.56,0.1,0.4,0.8])
plt.title("Test set")
plt.plot(X, Y2, 'o')
plt.plot(X, Yhat1, '-', color='green')
plt.plot(X, Yhat2, '-', color='orange')
ax2.set_xticks([-2,-1,0,1,2])
ax2.set_ylim(-10, 10)
plt.savefig("traintest.png")
plt.savefig("traintest.svg")

print ((Yhat1-Y1)**2).mean()
print ((Yhat2-Y1)**2).mean()

print ((Yhat1-Y2)**2).mean()
print ((Yhat2-Y2)**2).mean()

ترخيص

أنا، صاحب حقوق التأليف والنشر لهذا العمل، أنشر هذا العمل تحت الرخصة التالية:
w:ar:مشاع إبداعي
نسب العمل إلى مُؤَلِّفه
يحقُّ لك:
  • مشاركة العمل – نسخ العمل وتوزيعه وبثُّه
  • إعادة إنتاج العمل – تعديل العمل
حسب الشروط التالية:
  • نسب العمل إلى مُؤَلِّفه – يلزم نسب العمل إلى مُؤَلِّفه بشكل مناسب وتوفير رابط للرخصة وتحديد ما إذا أجريت تغييرات. بالإمكان القيام بذلك بأية طريقة معقولة، ولكن ليس بأية طريقة تشير إلى أن المرخِّص يوافقك على الاستعمال.

الشروحات

أضف شرحاً من سطر واحد لما يُمثِّله هذا الملف

العناصر المصورة في هذا الملف

يُصوِّر

١١ مايو 2009

تاريخ الملف

اضغط على زمن/تاريخ لرؤية الملف كما بدا في هذا الزمن.

زمن/تاريخصورة مصغرةالأبعادمستخدمتعليق
حالي04:33، 12 مايو 2009تصغير للنسخة بتاريخ 04:33، 12 مايو 2009720 × 270 (35 كيلوبايت)Skbkekas{{Information |Description={{en|1=Plots showing a training set and a test set from the same statistical population. Two curves are fit to the training set, one of which is an overfit. By plotting these curves with the test data, the overfitting can be s

الصفحة التالية تستخدم هذا الملف:

الاستخدام العالمي للملف

الويكيات الأخرى التالية تستخدم هذا الملف: