R 中神经网络的数据标准化
Data Standardisation for Neural Network in R
我在 SPSS 22 中构建了一个多层感知器神经网络。我在 R 中使用 "neuralnet" 包进行了同样的尝试,但结果并不理想。
SPSS 在执行训练之前标准化数据,我想知道:
- "neuralnet" 包是否执行任何类型的标准化?我在它的指南中找不到。
- 根据SPSS指南here,标准化流程如下:
Subtract the mean and divide by the standard deviation, (x−mean)/s.
在 R 中是否有可以做到这一点的最佳函数?由于方法很简单,我可以自己实现缩放,但是由于数据元素和记录的数量很大,效率可能不高。
或者我应该使用另一个神经网络包,比如 "monmlp"?自动标准化数据?
非常感谢
如果您需要标准化数据框中的多列(称之为 foo
),这可能会有用:
# Index of columns to standardize
cols <- c(1,2,3,4)
# Standardize
library(plyr)
standardize <- function(x) as.numeric((x - mean(x)) / sd(x))
foo[cols] <- plyr::colwise(standardize)(foo[cols])
我在 SPSS 22 中构建了一个多层感知器神经网络。我在 R 中使用 "neuralnet" 包进行了同样的尝试,但结果并不理想。 SPSS 在执行训练之前标准化数据,我想知道:
- "neuralnet" 包是否执行任何类型的标准化?我在它的指南中找不到。
- 根据SPSS指南here,标准化流程如下:
Subtract the mean and divide by the standard deviation, (x−mean)/s.
在 R 中是否有可以做到这一点的最佳函数?由于方法很简单,我可以自己实现缩放,但是由于数据元素和记录的数量很大,效率可能不高。
或者我应该使用另一个神经网络包,比如 "monmlp"?自动标准化数据?
非常感谢
如果您需要标准化数据框中的多列(称之为 foo
),这可能会有用:
# Index of columns to standardize
cols <- c(1,2,3,4)
# Standardize
library(plyr)
standardize <- function(x) as.numeric((x - mean(x)) / sd(x))
foo[cols] <- plyr::colwise(standardize)(foo[cols])