So, I am trying to make a linear regression model for predicting car prices for which I have the following data set: Data Set
Since the unique values are a lot for the categorical features, I label encoded the categorical features and converted the data set like this: Modified Data Set
Thereafter, I scaled the continuous features ( Engine, Power) like so:
# Scaling continuous features (No scaling for categorical variables)
X_train[['Engine', 'Power']] = scale.fit_transform(X_train[['Engine', 'Power']])
est = sm.OLS(y_train,X_train).fit()
print(est.summary())
X_test[['Engine', 'Power']] = scale.transform(X_test[['Engine', 'Power']])
y_predicted = est.predict(X_test)
y_predicted.sort_values()
# R2 value for y_test and y_predictions
from sklearn.metrics import r2_score
r2 = r2_score(y_test, y_predicted)
print(r2)
and got an R2 value of 84.8% compared to 33.5% if I also scaled label encoded features. I want to know why this happened? Also, my predicted values using this model on testing data is resulting in negative prices as well and most of these prices are not predicted well with the R2 score of predicted and true data being 68%.