'How to plot partial dependence plot with tensorflow
I have gru model, with 5 input variables and 4 output variables.
lstm_model = Sequential()
lstm_model.add(GRU(25, input_shape=(X_train.shape[1],X_train.shape[2]), activation='tanh',recurrent_activation='sigmoid' ,kernel_initializer='RandomUniform', kernel_regularizer=regularizers.l2(0.01),return_sequences=False))
lstm_model.add(Dense(13,activation='tanh',kernel_initializer='RandomUniform'))
lstm_model.add(Dense(4))
sgd = optimizers.SGD(lr=0.01, decay=1e-6, momentum=0.9, nesterov=True)
lstm_model.compile(loss='mean_squared_error', optimizer='Adam' ,metrics=[metrics.MeanAbsoluteError(name="mean_absolute_error", dtype=None)])
I want to plot PDP for each of the output variables. I am using the following code:
from sklearn.inspection import plot_partial_dependence
disp=plot_partial_dependence(lstm_model, X_train,target=1, verbose =1, features=[0,1,2,3,4],feature_names=f_columns)
This code give error:
NotFittedError: This Sequential instance is not fitted yet. Call 'fit' with appropriate arguments before using this estimator.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
