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? Sturges, √n and Freedman–Diaconis compared

How many bins should a histogram have? Sturges, √n and Freedman–Diaconis compared

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.

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.

MinMaxScaler vs StandardScaler: which scaler should you use?

MinMaxScaler vs StandardScaler: which scaler should you use?

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.

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