I have done a Yeo Johnson transformation by using preprocess from caret package. I have predicted the Target Variable using linear regression. Now I want to reverse the transformation for both the Target and the predicted values. I know this question has been answered before but I still couldn't solve my problem. This question was answered here-: Revert transformation preprocess caret and here-: https://rdrr.io/github/jknowles/ModelEWS/src/R/exportPrep.R I couldn't modify it for Yeo Johnson.
Link to dataset-:https://drive.google.com/file/d/1MePcWhe9zghozgZ90flRMBBTH0wR-aJ0/view?usp=sharing
#Yeo Johnson transformation through preprocess in caret package
#calculating transforming parameters
normModel<-preProcess(dataset[,-c(4,39,40)], method="YeoJohnson")
#Excluding categorical variables
#transform the dataset using the parameters
norm.dataset<-predict(normModel, dataset[,-c(4,39,40)])
norm.dataset<-cbind(dataset[,c(4,39,40)], norm.dataset)
#Paritioning the data into training and test dataset
set.seed(2000)
n=nrow(norm.dataset)
split= sample(c(TRUE, FALSE), n, replace=TRUE, prob=c(0.70, 0.30))
ptrain = norm.dataset[split, ]
ptest = norm.dataset[!split,]
#After treating outliers, imputing missing values and performing factor analysis, we perform regression
#Linear model for prediction
fmla <- as.formula(paste("Target.Variable ~ ", paste(colnames(ptrain[,-1]), collapse=" +")))
linearmod<-lm(formula = fmla, data = ptrain)
summary(linearmod)
ptest$lmPred <- predict(linearmod, ptest)