ファイル: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
W3C grn 
このSVGのソースコードは正しい
Created with Matplotlib-logo 
この ベクター画像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:ja:クリエイティブ・コモンズ
表示
このファイルはクリエイティブ・コモンズ 表示 3.0 非移植ライセンスのもとに利用を許諾されています。
あなたは以下の条件に従う場合に限り、自由に
  • 共有 – 本作品を複製、頒布、展示、実演できます。
  • 再構成 – 二次的著作物を作成できます。
あなたの従うべき条件は以下の通りです。
  • 表示 – あなたは適切なクレジットを表示し、ライセンスへのリンクを提供し、変更があったらその旨を示さなければなりません。これらは合理的であればどのような方法で行っても構いませんが、許諾者があなたやあなたの利用行為を支持していると示唆するような方法は除きます。

キャプション

このファイルの内容を1行で記述してください

このファイルに描写されている項目

題材

11 5 2009

ファイルの履歴

過去の版のファイルを表示するには、その版の日時をクリックしてください。

日付と時刻サムネイル寸法利用者コメント
現在の版2009年5月12日 (火) 04:332009年5月12日 (火) 04:33時点における版のサムネイル720 × 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

以下の​ 2 ページがこのファイルを使用しています:

グローバルなファイル使用状況

以下に挙げる他のウィキがこの画像を使っています: