
3.4
散布図
■
55
plt.title("The Bias-Variance Tradeoff")
plt.show()
バリアンス
バイアスの平方
全誤差
バイアス
-
バリアンストレードオフ
モデルの複雑さ
図3-6 凡例付きの折れ線グラフ
3.4
散布図
散布図は、
2
つのデータの関係を可視化するのに適しています。例えば図3-7 は 、ユ ー
ザの友達の数と
1
日当たりサイトを使う時間(分)との関連を表しています。
friends = [ 70, 65, 72, 63, 71, 64, 60, 64, 67]
minutes = [175, 170, 205, 120, 220, 130, 105, 145, 190]
labels = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i']
plt.scatter(friends, minutes)
#
各点のラベル
for label, friend_count, minute_count in zip(labels, friends, minutes):
plt.annotate(label,
xy=(friend_count, minute_count), #
各点にラベルを付加する
xytext=(5, -5), #
ただし、位置は少し横にずらす
textcoords='offset points')
plt.title("Daily Minutes vs. Number of Friends")
plt.xlabel("# ...