While using scikit-learn, one often imports multiple metrics to evaluate a model. Although there is nothing wrong with this practice, it makes the code inelegant and cluttered - with the initial few lines of the file overloaded with imports. Instead of importing the metrics individually, you can use the 𝐠𝐞𝐭_𝐬𝐜𝐨𝐫𝐞𝐫() method. Here, you can pass the metric's name as a string, and it returns a scorer object for you.
An Elegant Way to Import Metrics From Sklearn
An Elegant Way to Import Metrics From Sklearn
An Elegant Way to Import Metrics From Sklearn
While using scikit-learn, one often imports multiple metrics to evaluate a model. Although there is nothing wrong with this practice, it makes the code inelegant and cluttered - with the initial few lines of the file overloaded with imports. Instead of importing the metrics individually, you can use the 𝐠𝐞𝐭_𝐬𝐜𝐨𝐫𝐞𝐫() method. Here, you can pass the metric's name as a string, and it returns a scorer object for you.