R 中的特征缩放
Feature scaling in R
我想使用 caret 包扩展我的功能
我的数据集是 train[1:10]: 自变量
train[11]: 是我的因变量
我使用下面的代码来缩放我的 10 个自变量:
library(caret)
# calculate the pre-process parameters from the dataset
preprocessParams <- preProcess(train[,1:10], method = "range")
# transform the dataset using the parameters
train_Scaled <-predict(pp, train[,1:10])
# summarize the transformed dataset
summary(train_Scaled)
因此,我的 train_Scaled 数据框将缩放 10 个我想要的自变量,但不再有因变量。如何将因变量附加到新的 train_Scaled 数据框?谢谢!
cbind(train_Scaled, train[,11])
我想使用 caret 包扩展我的功能 我的数据集是 train[1:10]: 自变量 train[11]: 是我的因变量
我使用下面的代码来缩放我的 10 个自变量:
library(caret)
# calculate the pre-process parameters from the dataset
preprocessParams <- preProcess(train[,1:10], method = "range")
# transform the dataset using the parameters
train_Scaled <-predict(pp, train[,1:10])
# summarize the transformed dataset
summary(train_Scaled)
因此,我的 train_Scaled 数据框将缩放 10 个我想要的自变量,但不再有因变量。如何将因变量附加到新的 train_Scaled 数据框?谢谢!
cbind(train_Scaled, train[,11])