Last active
February 3, 2022 00:11
-
-
Save PedroArSp/ab3339335e04144c6248536221d16a17 to your computer and use it in GitHub Desktop.
python sklearn para calculo de metricas lineais
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from sklearn.metrics import r2_score, mean_absolute_error, mean_squared_error | |
| def show_metricas(y_test,y_pred,rounding:int = 3): | |
| m = { | |
| "MAE":("Erro Absoluto Médio [MAE]" , mean_absolute_error), | |
| "MSE":("Erro Quadratico Médio [MSE]",mean_squared_error), | |
| "RMSE":("variancia", lambda x,y :(mean_squared_error(x,y,squared=False))), | |
| "R2":("R^2", r2_score), | |
| "MAPE":("MAPE", lambda x,y: ((abs(x-y)/x).mean())) | |
| } | |
| #preenche a matriz de resultados chamando os metodos | |
| ret = {tag: round(m[tag][1](y_test,y_pred),rounding) for tag in m} | |
| print('Métricas para a Previsão:') | |
| for tag in m: | |
| print(f'{m[tag][0]}: {ret[tag]}') | |
| return ret |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment