Skip to content

Instantly share code, notes, and snippets.

y_pred = model.predict_classes(X_test)
y_pred
print(classification_report(y_true,y_pred))
y_pred = model.predict_classes(X_test)
y_true = np.argmax(y_test, axis = 1)
cf=confusion_matrix(y_true, y_pred)
sns.heatmap(cf, annot=True)
model.evaluate(X_test, y_test)
plot_learningCurve(history, 400)
def plot_learningCurve(history, epoch):
# Plot training & validation accuracy values
epoch_range = range(1, epoch+1)
plt.plot(epoch_range, history.history['acc'])
plt.plot(epoch_range, history.history['val_acc'])
plt.title('Model accuracy')
plt.ylabel('Accuracy')
plt.xlabel('Epoch')
plt.legend(['Train', 'Val'], loc='upper left')
plt.show()
history = model.fit(X_train, y_train,
epochs=400,
validation_data=(X_test, y_test),
verbose=1,
)
model.summary()
model.compile(loss='categorical_crossentropy',
optimizer=Adam(0.0001),
metrics=['acc'])
model = tf.keras.models.Sequential([
tf.keras.layers.Dense(256, input_shape=(9,), activation='relu'),
tf.keras.layers.BatchNormalization(),
tf.keras.layers.Dropout(0.3),
tf.keras.layers.Dense(256, activation='relu'),
tf.keras.layers.BatchNormalization(),
tf.keras.layers.Dropout(0.3),