On data with 1% fraud, a model that never predicts fraud scores 99% accuracy. Tested with scikit-learn: what precision, recall and F1 show instead, and how the decision threshold trades one for the other.
TL;DR ā When one class is rare, accuracy mostly measures how common the other class is. On a test set with 1% fraud, a model that always says ānot fraudā scored 0.990 accuracy and caught zero fraud. Look at recall (how much of the rare class you catch) and precision (how many of your alarms are real) instead.
For 1,000 normal values the common rules give 11 (Sturges), 20 (Rice, Scott), 27 (FreedmanāDiaconis, NumPy auto) or 32 (square root) bins. Start with NumPyās auto rule, then check one coarser and one finer setting.
For 1,000 normal values the common rules suggest 11 (Sturges), 20 (Rice, Scott), 27 (FreedmanāDiaconis) and 32 (square root) bins. A good starting point is bins="auto" in NumPy or matplotlib, which picks a width from the data (27 bins here). Then draw one coarser and one finer version: a peak or gap that shows up at only one bin count is probably noise. If the data has a long tail, change the scale (for example, a log axis) before you touch the bin count.
LLMs read text as tokens, not words or characters. We counted tokens for English, Korean, code and numbers across four tokenizers: the same Korean sentence ranged from 22 to 82 tokens.
TL;DR ā A token is a chunk of text, often a word piece, that a language model reads as one unit. Prices, context limits and speed are all measured in tokens. The same meaning can cost very different numbers of tokens: in our test, one Korean sentence took 22 tokens with a modern tokenizer and 82 with an older one.
StandardScaler for KNN, SVM, linear models and PCA; MinMaxScaler when you need a 0ā1 range; RobustScaler when there are outliers; nothing for tree models. Tested in scikit-learn: scaling lifts KNN from 0.691 to 0.950.
Use standardization (StandardScaler) as the default for distance- and gradient-based models such as KNN, SVM, linear models and PCA. Use min-max scaling (MinMaxScaler) when a model or input format needs values in a fixed range such as 0 to 1. One extreme value squeezes the normal values together under both; RobustScaler handles that case. Tree-based models donāt need scaling at all.
Chained assignment stops updating your DataFrame, strings get a new dtype, and datetimes switch to microseconds. Tested side by side on pandas 2.3.3 and 3.0.6.
TL;DR ā The most dangerous change in pandas 3.0 is that chained assignment like df["col"][mask] = 0 no longer updates df. You get a warning, not an error, so a script can keep running with wrong data. Also check any code that relies on object dtype for strings or converts datetimes to integers.
What a histogram shows, how to read its shape (symmetric, skewed, bimodal), how it differs from a bar chart, and when to use something else. Includes a short Python example with real output.
Corrected October 2026: The history section said Pearson invented the chart and named it a āhistorical diagramā. Pearson coined the word, but he said himself the chart was already common, and the āhistoricalā origin of the name is a well-known myth. That section is fixed. The Python example promised in the intro was missing; it is now added (run with NumPy 2.5.3 and Matplotlib 3.11.2), along with a few broken bullet lists and typos.
My notes on Airbnbās paper āApplying Deep Learning To Airbnb Searchā: why their first neural net barely matched GBDT, what LambdaRank changed, and the ideas that failed (listing IDs, multi-task learning).
So I spent the weekend diving into how Airbnb tackled their search ranking problem, and honestly, itās fascinating how much trial and error went into it.
The six parts of a data governance framework in plain words, and what they look like in practice: a 30-line pandas check where every rule has an owner and a tolerance. Tested with pandas 3.0.
Rewritten October 2026: The first version (April 2025) only listed the parts of a framework in general terms. I rewrote it around one question, what a framework looks like when you actually run it, and added a small pandas example with real output.
Added September 2026: This post was written in 2023 and reflects the tools and library versions available at that time. Installation steps, APIs, and version numbers may have changed since.
Corrected September 2026: The worked example used a different K matrix than the code; it now uses K = [[1, 2], [2, 3]] in both, and K^T replaces a typo (K^2). Section 3.2 wrongly said self-attentionās cost does not depend on sentence length; the score matrix is n Ć n, so cost grows with the square of the length.