Code

Kaggle Target Variable Logarithmic Transformation

To train a model using the Logarithmic Root Mean Squared Error (Log RMSE) implicitly, the target variable (such as SalePrice) can be transformed directly within the data loader. By applying a logarithmic function to the label tensor before feeding it to the model (e.g., using torch.log or np.log), the model's standard loss function (such as squared loss) will naturally optimize for relative error. In practice, this logged target tensor is reshaped into a column vector, such as (-1, 1), to maintain compatibility with the expected input dimensions of deep learning APIs.

0

1

Updated 2026-05-07

Contributors are:

Who are from:

Tags

D2L

Dive into Deep Learning @ D2L