Why is 99% accuracy useless? Precision, recall and F1 explained

Why is 99% accuracy useless? Precision, recall and F1 explained

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.

How many bins should a histogram have?

How many bins should a histogram have?

Too few bins hide the shape of your data, too many turn it into noise. Here is what the common bin rules (sqrt, Sturges, Freedman–Diaconis, auto) actually return, tested with NumPy.

TL;DR — There is no single right number. Start with bins="auto" in NumPy or matplotlib, which picks a width from the data, then compare it with one coarser and one finer setting before you draw conclusions. If the data has a long tail, change the scale (for example, a log axis) instead of fighting with the bin count.

What is a token, and why do LLMs count tokens instead of words?

What is a token, and why do LLMs count tokens instead of words?

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.

Min-max scaling vs standardization: when should you use which?

Min-max scaling vs standardization: when should you use which?

MinMaxScaler or StandardScaler? A tested answer with scikit-learn: which models need scaling at all, what outliers do to each scaler, and when RobustScaler is the better pick.

TL;DR — Use standardization (StandardScaler) as the default for distance- and gradient-based models, and min-max scaling (MinMaxScaler) when you need values in a fixed range such as 0 to 1. If your data has outliers, neither works well; use RobustScaler. Tree-based models don’t need scaling at all.

What breaks when you upgrade to pandas 3.0?

What breaks when you upgrade to pandas 3.0?

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 is a histogram?

What is a histogram?

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.

Applying Deep Learning to Airbnb Search: lessons from the paper

Applying Deep Learning to Airbnb Search: lessons from the paper

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.

What is a data governance framework? (with a runnable data quality check)

What is a data governance framework? (with a runnable data quality check)

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.

Self Attention에 대해 공부

Self Attention에 대해 공부

Transformer에 기초, 핵심 부분에 대해 알아보자

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.

Pagination