Try to Evaluate
Let’s see which model is better using the metrics we already know.
MSE:
123from sklearn.metrics import mean_squared_error print(mean_squared_error(Y_test, y_test_predicted).round(2)) print(mean_squared_error(Y_test, y_test_predicted2).round(2))
Output:
0.28
0.27
MAE:
123from sklearn.metrics import mean_absolute_error print(mean_absolute_error(Y_test, y_test_predicted).round(2)) print(mean_absolute_error(Y_test, y_test_predicted2).round(2))
Output:
0.45
0.43
R-squared:
123from sklearn.metrics import r2_score print(r2_score(Y_test, y_test_predicted).round(2)) print(r2_score(Y_test, y_test_predicted2).round(2))
Output:
0.53
0.55
As a general rule, the more features a model includes, the lower the MSE (RMSE) and MAE will be. However, be careful about including too many features. Some of them may be extremely random, degrading the model's interpretability.
Swipe to start coding
Let’s evaluate the model from the previous task:
- [Line #30] Import
mean_squared_error
for calculating metrics fromscikit.metrics
. - [Line #31] Find MSE using method
mean_squared_error()
andY_test
,y_test_predicted2
as the parameters, assign it to the variableMSE
, round the result to second digit. - [Line #32] Print the variable
MSE
. - [Line #35] Import
r2_score
fromscikit.metrics
. - [Line #36] Find R-squared and assign it to the variable
r_squared
, round the result to second digit. - [Line #37] Print the variable
r_squared
.
Solución
¡Gracias por tus comentarios!
single
Pregunte a AI
Pregunte a AI
Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla
Awesome!
Completion rate improved to 4.76
Try to Evaluate
Desliza para mostrar el menú
Let’s see which model is better using the metrics we already know.
MSE:
123from sklearn.metrics import mean_squared_error print(mean_squared_error(Y_test, y_test_predicted).round(2)) print(mean_squared_error(Y_test, y_test_predicted2).round(2))
Output:
0.28
0.27
MAE:
123from sklearn.metrics import mean_absolute_error print(mean_absolute_error(Y_test, y_test_predicted).round(2)) print(mean_absolute_error(Y_test, y_test_predicted2).round(2))
Output:
0.45
0.43
R-squared:
123from sklearn.metrics import r2_score print(r2_score(Y_test, y_test_predicted).round(2)) print(r2_score(Y_test, y_test_predicted2).round(2))
Output:
0.53
0.55
As a general rule, the more features a model includes, the lower the MSE (RMSE) and MAE will be. However, be careful about including too many features. Some of them may be extremely random, degrading the model's interpretability.
Swipe to start coding
Let’s evaluate the model from the previous task:
- [Line #30] Import
mean_squared_error
for calculating metrics fromscikit.metrics
. - [Line #31] Find MSE using method
mean_squared_error()
andY_test
,y_test_predicted2
as the parameters, assign it to the variableMSE
, round the result to second digit. - [Line #32] Print the variable
MSE
. - [Line #35] Import
r2_score
fromscikit.metrics
. - [Line #36] Find R-squared and assign it to the variable
r_squared
, round the result to second digit. - [Line #37] Print the variable
r_squared
.
Solución
¡Gracias por tus comentarios!
Awesome!
Completion rate improved to 4.76single