I cannot use "PermutationImportance"

380 views Asked by At

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?

0

There are 0 answers