<jupyter_start><jupyter_text>Mean Squared Error (MSE) MSE = $\frac{1}{n} \sum_{i=1}^{n}(y_i - \hat{y}_i)^2$  MSE $\in [0, \inf)$<jupyter_code>def own_mean_squared_error(y_true, y_pred):
    n = len(y_true)
    se = np.array([(y_true[i] - y_pred[i])**2 for i in range(n)])
    mse = np.mean(se)
    return mse
y_pred_test = regr.predict(x_test)

own_mean_squared_error(y_test, y_pred_test)
from sklearn.metrics import mean_squared_error
y_pred_test = regr.predict(x_test)

mean_squared_error(y_test, y_pred_test)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15526802218114602, 'fraction_numerical': 0.009242144177449169, 'mean_word_length': 5.948717948717949, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '543646', 'license': 'MIT', 'n_tokens_mistral': 254, 'n_tokens_neox': 242, 'n_words': 39, 'path': 'Chapter6_MLProblems/ErrorFunction/ErrorFunction_MSE.ipynb', 'repo_name': 'tomex74/UdemyML', 'size': '541'}