Я пытаюсь построить некоторые данные для бинарной модели, используя Python, но на графике нет никаких данных, и я не понимаю, почему, у меня нет ошибок, код работает очень быстро, результаты для бинарного режима верны, они показывают мне правильные данные, но не отображают графики, и я не понимаю, почему ... Это мой код python, я получаю ключевую ошибку для ['a cc ']:
#Building and Training the Neural Network
from keras.models import Sequential
from keras.layers import Dense
from keras.optimizers import Adam
# convert into binary classification problem - heart disease or no heart disease
Y_train_binary = y_train.copy()
Y_test_binary = y_test.copy()
Y_train_binary[Y_train_binary > 0] = 1
Y_test_binary[Y_test_binary > 0] = 1
print(Y_train_binary[:20])
def create_binary_model():
# create model
model = Sequential()
model.add(Dense(16, input_dim=13, kernel_initializer='normal', activation='relu'))
model.add(Dense(8, kernel_initializer='normal', activation='relu'))
model.add(Dense(1, activation='sigmoid'))
# Compile model
adam = Adam(lr=0.001)
model.compile(loss='binary_crossentropy', optimizer=adam, metrics=['accuracy'])
return model
binary_model = create_binary_model()
print(binary_model.summary())
# fit the binary model on the training data
history=binary_model.fit(X_train, Y_train_binary, validation_data=(X_test, Y_test_binary), epochs=200, batch_size=10, verbose = 10)
import matplotlib.pyplot as plt
# Model accuracy, here the graph it's not plotted
plt.plot(history.history['acc'])
plt.plot(history.history['val_acc'])
plt.title('Model Accuracy')
plt.ylabel('accuracy')
plt.xlabel('epoch')
plt.legend(['train', 'test'])
plt.show()
# Model Losss, here the graph it's not plotted
plt.plot(history.history['loss'])
plt.plot(history.history['val_loss'])
plt.title('Model Loss')
plt.ylabel('loss')
plt.xlabel('epoch')
plt.legend(['train', 'test'])
plt.show()
# generate classification report using predictions for categorical model
from sklearn.metrics import classification_report, accuracy_score
# generate classification report using predictions for binary model
binary_pred = np.round(binary_model.predict(X_test)).astype(int)
print('Results for Binary Model')
print(accuracy_score(Y_test_binary, binary_pred))
print(classification_report(Y_test_binary, binary_pred))
Вот как выглядит график на данный момент, мои данные не отображаются: ![Graph right now](https://i.stack.imgur.com/fqqFK.png)
и вот так должен выглядеть как ...: ![expected output](https://i.stack.imgur.com/hfQD7.png)