how to assign back categorical variables to train and test data after training and testing using inverse_transform?
If you are using ordinal data
Use this to encode
  
from sklearn.preprocessing import OrdinalEncoder
oe=OrdinalEncoder()
social['Gender']=oe.fit_transform(social[['Gender']])

Use this to decode
social['Gender']=oe.inverse_transform(social[['Gender']])



If you are using nominal variables
Use this to encode
from sklearn.preprocessing import OneHotEncoder
  
ohe = OneHotEncoder()

temp_var= ohe.fit_transform(social[['Gender']]) 

Use this to decode
temp_var2=ohe.inverse_transform(temp_var)


Hope it helps