set.seed(1234)
ind <- sample(2, nrow(bronx_data), replace = T, prob = c(.7,.3))
train <- bronx_data[ind==1,2:11]
test <- bronx_data[ind==2,2:11]
train_target <- bronx_data[ind==1,1]
test_target <- bronx_data[ind==2,1]
m <- colMeans(train)
s <- apply(train, 2, sd)
train <- scale(train, center = m, scale = s)
test <- scale(test, center = m, scale = s) # use same mean and sd obtained form train data
这是我的模特
library(keras)
model <- keras_model_sequential()
model %>%
layer_dense(units = 5, activation = 'relu', input_shape = c(10)) %>%
layer_dense(units = 1)
我得到了很好的输出,但是我遇到的问题是无法缩放数据。有人请帮助。我是新编码员。 我已经尝试过
unscale(vals, norm.data, col.ids)
并出现以下错误
scale.default中的错误。默认值(数据,中心= FALSE,scale = 1 / scale):“ scale”的长度必须等于“ x”的列数