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.
Read more here: Scikit-learn page.
Read this post on LinkedIn.
I like to explore, experiment, and write about data science concepts and tools. You could connect with me on LinkedIn.