A log transformation changes a numeric variable by applying a logarithm. It is a practical response to a strongly right-skewed target: a few very large values stretch the scale, compressing the bulk of the distribution into an unreadable lower range. For positive prices, no offset is needed; when zero or negative values occur, add a constant first to move values into the positive range. section 4.2.1
Use histograms and boxplots to decide whether the transformation helps. Applied to listing prices, the transformed histogram becomes more symmetric and the boxplot becomes easier to inspect. The transformation does not remove every extreme observation: outliers can remain in both tails, so it is a change of representation rather than a guarantee of clean data. section 4.2.1
Transform a positive price target
Use NumPy's log1p to transform price values and inspect the result. The paired plots compare the transformed histogram with a boxplot, making it easy to check whether the long right tail has become more manageable. section 4.2.1
np.log1p(data["price"]).hist(bins=20) data[["price"]].apply(lambda x: np.log1p(x)).boxplot()
This listing applies np.log1p to price, then plots a histogram and boxplot of the transformed values. section 4.2.1
For a linear regression baseline, transforming a positive target can help avoid infeasible zero or negative predictions. It is one possible remedy, not a requirement for the baseline: the baseline's purpose is to reveal data challenges and provide a comparison for more sophisticated models. section 7.2.3
Log transformations also matter when interpreting SHAP output from a multiplicative model. To reconstruct an original prediction from those SHAP values, exponentiate the values and multiply them; the reconstruction may differ slightly because of approximation and small errors. section 7.3

