<jupyter_start><jupyter_text>Estatística - Erros - Fundamentos * Calculando erros de valores previstos e reais utilizando a biblioteca NumPy* @CursoDS_ProfDanilo* Prof. Dr. <NAME>* <EMAIL><jupyter_code>import numpy as np
valores_reais = np.array([1.1,1.5,2.4,2.9,3.1,3.5,3.7,4.2,4.5,4.9,5.5,5.9,6.2,6.7,7.5,8.5,8.7,8.9])
valores_previstos = np.array([1.13,1.46,2.394,3.011,3.114,3.522,3.689,4.154,4.566,5.001,5.545,5.993,6.194,6.712,7.554,8.434,8.721,8.995])<jupyter_output><empty_output><jupyter_text>Erro absoluto médio ![image.png](attachment:image.png)<jupyter_code>erros = np.abs(valores_reais - valores_previstos)
print(erros)
soma_erros = np.sum(erros)
print(soma_erros)
MAE = soma_erros/len(valores_reais)
print("MAE = {:0.3f}".format(MAE))<jupyter_output><empty_output><jupyter_text>Erro quadrático médio ![image.png](attachment:image.png)<jupyter_code>erro_quadratico = (np.array(valores_reais) - np.array(valores_previstos))**2.0
erro_quadratico
soma_erro_quadratico = np.sum(erro_quadratico)
soma_erro_quadratico
MSE = soma_erro_quadratico/len(valores_reais)
print("MSE = {:0.4f}".format(MSE))<jupyter_output><empty_output><jupyter_text>Raiz do erro quadrático médio ![image.png](attachment:image.png)<jupyter_code>RMSE = np.sqrt(MSE)
print("RMSE = {:0.3f}".format(RMSE))<jupyter_output><empty_output><jupyter_text>Erro logaritmico quadrático médio ![image.png](attachment:image.png)<jupyter_code>erro_log_quadratico = (np.log(valores_reais+1)-np.log(valores_previstos+1))**2.0
soma_erro_log_quadratico = np.sum(erro_log_quadratico)
MSLE = soma_erro_log_quadratico/len(valores_reais)
print("MSLE = {:0.5f}".format(MSLE))<jupyter_output><empty_output><jupyter_text>Raiz do erro logaritmico quadrático médio ![image.png](attachment:image.png)<jupyter_code>RMSLE = np.sqrt(MSLE)
print("RMSLE = {:0.3f}".format(RMSLE))<jupyter_output><empty_output><jupyter_text>Erro absoluto percentual médio ![image.png](attachment:image.png)<jupyter_code>soma_erro_percentual = np.sum(np.abs(erros)/valores_previstos)
MAPE = soma_erro_percentual*100/len(valores_reais)
print("MAPE = {:0.2f}%".format(MAPE))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1671361502347418, 'fraction_numerical': 0.05962441314553991, 'mean_word_length': 9.497536945812808, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 31, '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': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '395916', 'license': 'MIT', 'n_tokens_mistral': 1042, 'n_tokens_neox': 982, 'n_words': 89, 'path': 'Data_Science/Estatistica/Erros_Fundamentos.ipynb', 'repo_name': 'maledicente/cursos', 'size': '2168'}