セクション 5. 章 2
single
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.
タスク
スワイプしてコーディングを開始
Let’s evaluate the model from the previous task:
- [Line #30] Import
mean_squared_errorfor calculating metrics fromscikit.metrics. - [Line #31] Find MSE using method
mean_squared_error()andY_test,y_test_predicted2as the parameters, assign it to the variableMSE, round the result to second digit. - [Line #32] Print the variable
MSE. - [Line #35] Import
r2_scorefromscikit.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.
解答
すべて明確でしたか?
フィードバックありがとうございます!
セクション 5. 章 2
single
AIに質問する
AIに質問する
何でも質問するか、提案された質問の1つを試してチャットを始めてください