aNet.ai
Data Science/Learning path
0day streak0XP · Lv 1
← 4. From Clean Data to Useful Predictions
Lesson 5.5 6 min · 131 words

Log transformation and trees

A log transform compresses large positive differences while keeping the order. In this course, log1p(x) means ln(1+x) for nonnegative counts.

For nonnegative counts, log1p(x)=ln(1+x): 0 becomes 0, 9 becomes about 2.303 and 99 about 4.605. The +1 permits zero. The transformation preserves order, compresses large gaps, and changes differences, ratios and units. It does not automatically make a variable normal or repair invalid records.

An ordinary threshold decision tree uses order rather than Euclidean distance. The rule score<75 becomes z<0 under the saved score scale, with identical decisions: 70 Stay, 80 Withdraw, 79 Withdraw. Thus scaling is often unnecessary for ordinary numerical tree splits. This is not a claim that every model or implementation behaves identically under every transformation.

Choose transformation based on the question, feature meaning and model. Standardisation uses training spread; min-max uses training endpoints; log compresses a long numerical tail. Preserve original measurements and the reason for transformation.

Sources: W4 PDF pp. 2-42; L4 Tasks 1-7. All fixed worked values here were recalculated from the supplied examples. These toy rules are teaching devices, not deployable student-support recommendations.

Practice problems

Supplementary study questions on the lecture concepts — not verbatim exam questions. Each answer counts toward spaced review.

1. Conceptual understanding

Definitions and distinctions.

Question 1 of 6 · +5 XP

What is log1p(0)?

Question 2 of 6 · +5 XP

What does log1p do for nonnegative counts?

2. Application

Apply the concept to a case or calculation.

Question 3 of 6 · Log calculation · +5 XP

What is log1p(9), approximately?

Question 4 of 6 · Order · +5 XP

For nonnegative counts 9<99, what happens after log1p?

3. Interpretation and limitations

Evaluate assumptions and justify conclusions.

Question 5 of 6 · Shape · +5 XP

Does a log transform guarantee a normal distribution?

Question 6 of 6 · Tree splits · +5 XP

Why can monotone scaling preserve a threshold tree's split?

Explain it in writing

Self-checked, not marked. Write a few sentences, then compare with the example answer. Your writing is saved as you type.

Show an example answer

The added one makes zero map to ln(1)=0. Ordinary ln(0) is undefined. The transformation still needs to match the variable and task.

Check: did you answer the question, use evidence or working, and avoid claiming more than the evidence supports?

Show an example answer

A tree uses ordered comparisons with cutoffs. A monotone rescaling can move the cutoffs while preserving the same split. Euclidean distance directly depends on numerical gaps.

Check: did you answer the question, use evidence or working, and avoid claiming more than the evidence supports?

Practice this topic
Saved in this browser as you type.
aNet.ai · Data Science Fundamentals · Weeks 1–5 · practice material, not an official examProgress saved in this browser