0

I'm trying to use the permutation importance of eli5 to check the importance of the variables. But I get the following error.

perm = PermutationImportance(model, random_state=1, scoring=mae_scorer)
perm.fit([X_test, X_spec_test], y_test)

ValueError: could not broadcast input array from shape (2079,20,28,2) into shape (2079)

This model inserts an Dense layer in the middle of the CNN, so we pass two inputs in an array([X_test, X_spec_test]). Normal training and validation can be done with the following code without any problems.

fit = model.fit([X_train, X_spec_train], y_train, epochs=epochs, batch_size=batch_size, validation_data = ([X_test, X_spec_test], y_test), verbose=1)
y_train_pred = model.predict([X_train, X_spec_train])

The form of each variable is as follows:

X_test.shape is (2079, 20, 28, 2)

X_spec_test.shape is (2079, 45)

y_test.shape is (2079,)

The input layer of the model is defined as follows.

input1 = Input(shape=(X_train.shape[1], X_train.shape[2], X_train.shape[3]]))
input2 = Input(shape=(X_spec_trainshape[1],))

How do I get rid of the error?

desertnaut
  • 57,590
  • 26
  • 140
  • 166
shimokin
  • 3
  • 4
  • Okay; do those shapes actually make sense? Should the operation be possible with data of those shapes, according to your understanding of the theory? I have no idea, but it comes across like you really have a question about the underlying theory, rather than about writing the code. – Karl Knechtel Oct 16 '20 at 07:39
  • This code should work according to my understanding of this method, but couldn't work. I would like to know how to write a code... By the way, I referred to a below information. https://www.kaggle.com/dansbecker/permutation-importance – shimokin Oct 19 '20 at 08:16

0 Answers0