Unscale predicted value for Neural Network (Keras package)

Refresh

February 2019

Views

29 time

1

partition of data

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]

normalize my data**

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 

Model

This is my model

library(keras)
model <- keras_model_sequential()
model %>%
        layer_dense(units = 5, activation = 'relu', input_shape = c(10)) %>%
        layer_dense(units = 1)

I get good output but the problem I am having is un-scaling the data. Someone please HELP. I am new coder. I've tried

unscale(vals, norm.data, col.ids)

and got the following error

Error in scale.default(data, center = FALSE, scale = 1/scale) : length of 'scale' must equal the number of columns of 'x'

0 answers