Discover more from Daily Dose of Data Science
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.
Thanks for reading Daily Dose of Data Science! Subscribe for free to learn something new and insightful about Python and Data Science every day. Also, get a Free Data Science PDF (250+ pages) with 200+ tips.
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.