Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors
Filter by Categories
About Article
Analyze Data
Archive
Best Practices
Better Outputs
Blog
Code Optimization
Code Quality
Command Line
Daily tips
Dashboard
Data Analysis & Manipulation
Data Engineer
Data Visualization
DataFrame
Delta Lake
DevOps
DuckDB
Environment Management
Feature Engineer
Git
Jupyter Notebook
LLM
LLM
Machine Learning
Machine Learning
Machine Learning & AI
Manage Data
MLOps
Natural Language Processing
NumPy
Pandas
Polars
PySpark
Python Tips
Python Utilities
Python Utilities
Scrape Data
SQL
Testing
Time Series
Tools
Visualization
Visualization & Reporting
Workflow & Automation
Workflow Automation

Feature Engineer

Encode Rare Labels with Feature-engine

When dealing with features with high cardinality, you might want to mark the rare categories as “Other”. Feature-engine’s RareLabelEncoder makes it easy for you to do so.

In the code above, we use RareLabelEncoder to replace categories with the frequency below 0.05 in the column “education” with “Other”.

Link to Feature-engine.

My previous tips on feature engineering.
Favorite

Encode Rare Labels with Feature-engine Read More »

Snorkel — Programmatically Build Training Data in Python

Imagine you try to determine whether a job posting is fake or not. You come up with 4 different assumptions about a fake job posting. How do you test which of these features are the most accurate in predicting fraud?

This PDF below shows how you can use Snorkel AI to test different assumptions with ease.

My full article about Snorkel.

Link to Snorkel.
Favorite

Snorkel — Programmatically Build Training Data in Python Read More »

Similarity Encoding for Dirty Categories Using dirty_cat

When encoding categorical variables, you might want to capture the similarities among these categories such as ‘Master Police Officer’ and ‘Police Officer III’. If so, use dirty-cat.

In the code above, I use dirty-cat’s SimilarityEncoder to encode the titles while capturing their similarities.

The correlation matrix shows how similar two labels are using the encoded values. We can see that the similarity between ‘Master Police Officer’ and ‘Police Officer III’ is 0.86.

Link to dirty-cat.

Link to my full article about dirty-cat.
Favorite

Similarity Encoding for Dirty Categories Using dirty_cat Read More »

Datacommons: Get Statistics about a Location in One Line of Code

If you want to get some interesting statistics about a location in one line of code, try Datacommons.Datacommons is a publicly available data from open sources (census.gov, cdc.gov, data.gov, etc.). In the example above, I used Datacommons to get the median income in California over time.

Find other interesting statistics using Datacommons here.

Link to Datacommons.
Favorite

Datacommons: Get Statistics about a Location in One Line of Code Read More »

fastai’s cont_cat_split: Get a DataFrame’s Continuous and Categorical Variables Based on Their Cardinality

To get a DataFrame’s continuous and categorical variables based on their cardinality, use fastai’s cont_cat_split method.
If a column consists of integers, but its cardinality is smaller than the max_card parameter, it is considered as a category variable.
Find an example of this method above.
Link to the source code.
Link to the documentation.Favorite

fastai’s cont_cat_split: Get a DataFrame’s Continuous and Categorical Variables Based on Their Cardinality Read More »

0
    0
    Your Cart
    Your cart is empty
    Scroll to Top

    Work with Khuyen Tran

    Work with Khuyen Tran