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
.
Løsning
Takk for tilbakemeldingene dine!
single
Spør AI
Spør AI
Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår
Oppsummer dette kapittelet
Explain code
Explain why doesn't solve task
Awesome!
Completion rate improved to 4.76
Try to Evaluate
Sveip for å vise menyen
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
.
Løsning
Takk for tilbakemeldingene dine!
Awesome!
Completion rate improved to 4.76single