<jupyter_start><jupyter_text>L14 - Model evaluation (bias decomp mse loss)---- Instructor: <NAME> (<EMAIL>)- Course website: https://www.dalcimar.com/disciplinas/aprendizado-de-maquina- Bibliography: based on lectures of Dr. <NAME><jupyter_code>import numpy as np

from sklearn.tree import DecisionTreeClassifier
from sklearn.tree import DecisionTreeRegressor
from sklearn import datasets

from sklearn.model_selection import train_test_split
pip install mlxtend --upgrade --no-deps
from mlxtend.evaluate import bias_variance_decomp<jupyter_output><empty_output><jupyter_text>Regression loss (MSE loss)<jupyter_code>boston = datasets.load_boston()
X = boston.data[:,:]
y = boston.target
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.1, random_state=11)

tree = DecisionTreeRegressor(random_state=1)
avg_expected_loss, avg_bias, avg_var = bias_variance_decomp(
    tree, X_train, y_train, X_test, y_test, 
    loss='mse', num_rounds=3,
    random_seed=1)

print('Avarage expected loss: %.3f' %avg_expected_loss)
print('Avarage bias^2: %.3f' %avg_bias)
print('Avarage variance: %.3f' %avg_var)<jupyter_output>Avarage expected loss: 16.990
Avarage bias^2: 9.962
Avarage variance: 7.028
{'fraction_non_alphanumeric': 0.11194029850746269, 'fraction_numerical': 0.022388059701492536, 'mean_word_length': 6.591194968553459, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '537644', 'license': 'MIT', 'n_tokens_mistral': 466, 'n_tokens_neox': 439, 'n_words': 100, 'path': 'L14_model evaluation/code/L14_bias decomp mse loss.ipynb', 'repo_name': 'pedrogomes-dev/MA28CP-Intro-to-Machine-Learning', 'size': '1239'}