Hi Reader,
How's your January going? I've been playing a lot of Pokémon (the card game) with my 7 year-old... actually I'm the one who's always bugging him to play 😂
Are you a Pokémon fan? Meowscarada ex, anyone?
Introduction to Polars (Practical Business Python)
Have you heard of Polars? In short, it's a high-performance, memory-efficient alternative to pandas. If you're new to Polars, this blog post walks through basic Polars code and compares it to pandas.
When performing supervised Machine Learning, one of the keys to success is effective data preprocessing, which can require a lot of thought and planning.
However, there's a scikit-learn model which has two magical properties that significantly reduce your preprocessing burden. (And you've probably never even heard of it!)
It's called Histogram-Based Gradient Boosted Trees (HGBT). Here are its magical properties:
What exactly does that mean? I'll explain below! 👇
When your training data contains missing values, normally you have to impute all missing values as part of the data preprocessing step. (The only alternative is to drop samples or features with missing values, which can mean losing valuable training data!)
But if you use HGBT, it will handle the missing values without imputation or dropping any data!
Here's a minimal example from the scikit-learn documentation:
Here's a longer example from one of my videos.
Note: Decision Trees also support missing values as of scikit-learn 1.3, and Random Forests support missing values as of scikit-learn 1.4.
When your training data contains unordered categorical features, normally you have to one-hot encode them as part of the data preprocessing step.
But if you use HGBT, it will handle the categorical features without encoding!
Starting in scikit-learn 1.4, HGBT will also infer which features are categorical directly from the data types of a pandas DataFrame!
Here's an example from the scikit-learn documentation:
Here's a longer comparison of native categorical support versus one-hot encoding and ordinal encoding.
If you want to learn more HGBT, check out the scikit-learn user guide.
Or if you're new to scikit-learn, check out one of my FREE scikit-learn courses!
Did you like this week’s tip? Please send it to a friend or share this link on social. It really helps me out! 🙌
See you next Tuesday!
- Kevin
P.S. Microsoft Excel World Championship (with live commentary)
Did someone AWESOME forward you this email? Sign up here to receive Data Science tips every week!
Join 25,000+ intelligent readers and receive AI tips every Tuesday!
Hi Reader, Data School's All-Access Pass is now on sale: Buy the pass for $99 With the All-Access Pass, you get access to ALL of my courses for a year, including every NEW course I launch during your subscription! That includes a secret new course I'll be launching on January 1 🤫 The $99 sale ENDS in one week, on Cyber Monday (November 30). By purchasing now, you'll lock in this discounted price for the lifetime of your subscription, which will get more valuable as I add more courses! Buy the...
Hi Reader, For 12 years, I've been teaching scikit-learn. It's the ideal tool for Machine Learning in Python, given its broad functionality, community support, and high-quality documentation. But there's a HUGE difference between documentation and an effective user manual. That's why I published Master Machine Learning with scikit-learn: I wanted to provide battle-tested guidance for achieving superior Machine Learning results. (Side note: Amazon US is currently offering a 34% discount on my...
Hi Reader, I hope you're having a great September! 🍂 Two quick announcements for you: 1️⃣ I'm working on two mystery courses right now: The first is an ML course, and the second has nothing to do with Data Science! 🤯 Can you guess what the second course is about? 2️⃣ On Monday, I'm raising the price of my Master Machine Learning book from $19 to $29. But until Monday, you can still snag a paperback copy for $19! The ebook will continue to be priced at $19, and you can still read the book...