0
$\begingroup$

I want to build a neural network with a data input of 15-18 variables. I want to use the model for anomaly detection based on the reconstruction error. I've done some tutorials now but the data was always already given so I have to do the very first step on my own now. Thus, I wonder, how do I handle the multivariate data?

I see three options:

  • 1) Build a single neural network for each variable (univariate)
  • 2) Build a neural network with a single outcome based on all multivariate input variables
  • 3) Build a neural network with a multivariate output based on a multivariate input.

1) and 2) is quite cumbersome I'd say. But is 3) even possible? If so, what do I have to take into account? Will the outcome variable then just be a data frame, or some other type like a certain array or so?

$\endgroup$
1
$\begingroup$

I do not understand your problem, the first layer, i.e. input layer, of your neural net must have a size equal to the number of variables you have. The last layer, i.e. output layer, must have a size which is equal to the number of values you want to predict. Please be kind and tell me what you want to know more specifically, if my answer doesn't satisfy you.

| improve this answer | |
$\endgroup$
  • $\begingroup$ I guess this is the answer I was looking for. Most of the tutorials only handle image reconstruction so I'm used to that instead of handling single/multiple variables. Let's assume I use Keras and I want to construct the first layer for 5 variables, how would it look like? "model.add(Dense(number_neurons, input_shape(5,), activation = 'some_function'))" ? $\endgroup$ – Ben Sep 27 '19 at 5:33
  • $\begingroup$ Assuming a multilayer perceptron and a regression problem, the following code would try to solve it : model = Sequential() model.add(Dense(units= number_neurons, input_dim=number_variable_first_layer, activation = 'relu') model.add(units=number_neurons, activation='relu') model.add(units=number_variable_to_predict) Here, the neural network is a perceptron with 1 input layer 2 hidden layers and 1 output layer. Do not forget to compile it : model.compile(optimizer='rmsprop', loss='mean_squared_error'). Then you can fit and predict. One would also use Dropout to avoid over-fitting $\endgroup$ – kakarotto Sep 27 '19 at 12:57
  • $\begingroup$ I would advise you to follow as many tutorials as possible you can find there : machinelearningmastery.com $\endgroup$ – kakarotto Sep 27 '19 at 13:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.