# Linear Regression bad results after log transformation

I have a dataset that has the following columns:

The variable I'm trying to predict is "rent".

My dataset looks a lot similar to what happens in this notebook. I tried to normalize the rent column and the area column using log transformation since both columns had a positive skewness. Here's the rent column and area column distribution before and after the log transformation.

Before:

After:

I thought after these changes my regression models would improve and in fact they did, except for Linear Regression.

If I don't do any type of transformations the models underperform. When I only transform the rent column all models improve including Linear Regression, but when I transform the rent column and the area column Linear Regression has a terrible result with a MAPE of 2521729.47.

Not transforming area MAPE results:

Transforming area MAPE results:

Can anyone tell me what's probably happening or guide me through any type of testing or verifications to understand what's happening to linear regression? Am I wrong to transform those columns even if the models are improving?

Edit:

After testing the models by removing and adding columns, I found that linear regression goes crazy after I insert the neighborhood column (which contains 66 neighborhoods) and create dummy columns. When I create this dummy variables the number of columns goes to 77, while the dataset has only around 3000 rows.

My thoughts are that after transforming the column into dummy columns the data becomes very sparse and with too many features for only 3000 rows, and that's why Linear Regression has this bad performance and Lasso Regression doesn't. Besides that, I should probably still use the other models since they perform well after the changes.

Am I correct?

• The results are so much worse that I suspect a bug or convergence failure. Could you provide some code, maybe minimized (reduce the feature set while keeping this behavior)? Apr 22, 2021 at 14:10
• After you comment I did some testing adding and removing variables, please check my Edit and tell me what you think :) Apr 23, 2021 at 1:37
• I can understand that dummy-encoding the neighborhood in this situation could cause overfitting, and that lasso would therefore outperform ordinary linear regression. But that the issue only happens when log-transforming the area variable is still surprising, as is the scale to which the dummy variables hurt performance. Apr 23, 2021 at 15:31
• I see, any suggestion or thoughts or this issue? Apr 23, 2021 at 22:59

Sparsity: Yes, you might have a neighborhood category in your test set, that does not exist in your training set (or has only a few examples). In this case predictions for that category might be very bad. Though this does not explain why you don't have high MAPE when you don't transform area.
• Yes, perhaps taking the log of area caused some unlucky observations to get very high Absolute Percentage Error. For me log(rent) ~ log(area) linear model makes more sense. It means "if you add 1% to area, estimate of rent will get +x%. log(rent) ~ area linear model means "if you add 1 m2 to area, rent estimate will get +x%". I guess when 100 m2 increases to 200 m2 rent approximately doubles. But when 500 m2 increases to 600 m2, there's no double rent. May 6, 2021 at 15:58