简体   繁体   中英

R: Caret Package preProcess()

I am fairly new to data modelling and R, I wonder if anyone could give me some advice.

I am using R to replicate a model I have built in SPSS modeller with the view of then trying to improve it. Currently I am building a basic linear model using the caret package.

I have used preProcess() to scale and centre my numeric fields, including the numeric variable which the model is predicting.

preProcValues <- preProcess(Data_Numeric, method = c("center", "scale"))
Data_PreProc <- predict(preProcValues, Data_Numeric)

When I produce the model I find that this pre-processing results in a more accurate model, however, I am unsure how to take the scaled and centred result and get a 'result'. The model is used as a pricing tool so I need to unscale and centre it if that makes sense?

For centering , the sample mean is subtracted while the centered values are divided by the standard deviation for scaling .

It'd be easily recovered from the following relationships.

  • data
  • centered = data - mean(data)
  • scaled = centered / sd(data)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM