3.4.8.2. 決定木のパフォーマンス測定

学習セットでテストすると過学習を示します。

データを取得します

from sklearn.datasets import fetch_california_housing
data = fetch_california_housing(as_frame=True)

モデルの訓練とテスト

予想の関数として予想されるプロット

import matplotlib.pyplot as plt
plt.figure(figsize=(4, 3))
plt.scatter(expected, predicted)
plt.plot([0, 5], [0, 5], "--k")
plt.axis("tight")
plt.xlabel("True price ($100k)")
plt.ylabel("Predicted price ($100k)")
plt.tight_layout()
plot measuring performance

エラーはほとんどありません!

これは出来過ぎです: 訓練データでモデルをテストしています、 これは一般化の尺度ではありません。

The results are not valid

Total running time of the script: (0 minutes 1.239 seconds)

Gallery generated by Sphinx-Gallery