Modelo logístico de predicción en tf.keras#

Introducción#

En esta lección construimos un modelo predictivo de regresión logística usando los datos de cáncer de la Universidad de Wisconsin.

Usaremos las funciones de activación relu y sigmoid y el regularizador Dropout. Adicionalmente introducimos el modo 2 de escribir un modelo Sequential.

Finalmente se construye una matriz de confusión para el problema.

Importar módulos#

try:
  %tensorflow_version 2.x
except Exception:
  pass
from __future__ import absolute_import, division, print_function, unicode_literals
#
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import tensorflow as tf
#
from tensorflow.keras.models import Sequential
#
from tensorflow.keras.layers import Dense, Dropout
#
from tensorflow.keras.utils import plot_model
#
from sklearn.preprocessing import LabelEncoder
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from sklearn.metrics import confusion_matrix
#
print(tf.__version__)
2.9.1

Funciones de activación#

Logística o sigmoide#

Dada la salida del sumador, digamos \(y=\mathbf{w}'\mathbf{x} +b\), la función de activación sigmoid está definida por:

\[ sigmoid(y) = \frac{1}{1+\exp(-y)} \]

Entonces, esta función de activación transforma cualquier número real en un número en el intervalo \((0,1)\), de tal manera que puede ser interpretado como una probabilidad.

Relu#

Dada la salida del sumador, digamos \(y=\mathbf{w}'\mathbf{x} +b\), la función de activación relu está definida por:

\[\begin{split} relu(y) = \begin{cases} &0, \text{ si } y\le 0,\\ &y, \text{ en otro caso } \end{cases} \end{split}\]

Regularizadores#

Dropout#

Usaremos el regularizador Dropout. Dropout paper. Este regularizador deja por fuera del entrenamiento en cada epoch un porcentaje de las neuronas de la capa, escogidas de forma aleatoria en cada epoch. Por ejemplo Dropout(0.1) deja el \(10\%\) de las neuronas por fuera del entrenamiento en cada epoch. En el artículo muestran que en muchos casos este regularizador funciona mejor que los clásicos L1 y L2.

El conjunto de datos cáncer de seno Wisconsin#

Puede descargar los datos en kaggle- cancer de seno-Wisconsin.

Meta-información sobre los datos#

  1. ID number

  2. Diagnosis (M = maligno, B = benigno)

Se calculan diez características de valor real para cada núcleo celular:

  • radius (media de las distancias desde el centro a los puntos del perímetro)

  • texture (desviación estándar de los valores de la escala de grises)

  • perimeter

  • area

  • smoothness (variación local en las longitudes de los radios)

  • compactness (perímetro ^ 2 / área - 1.0)

  • concavity (severidad de las porciones cóncavas del contorno)

  • concave points (número de porciones cóncavas del contorno)

  • symmetry

  • fractal dimension («aproximación de la línea de costa» - 1)

La media, el error estándar y el «peor» o el mayor (la media de los tres valores más grandes) de estas características se calcularon para cada imagen, lo que resultó en 30 características. Por ejemplo, el campo 3 es Radio medio, el campo 13 es Radio SE, el campo 23 es Peor radio.

Todos los valores de las características se recodifican con cuatro dígitos significativos.

Datos faltantes: ninguno.

Distribución de clases: 357 benignos, 212 malignos.

Lectura de datos#

Separa entrada (features) y salida#

# Importando la data
data = pd.read_csv('https://raw.githubusercontent.com/AprendizajeProfundo/Libro-Fundamentos/main/Machine_Learning/Datos/breast_cancer/data.csv')
del data['Unnamed: 32']

Preprocesamiento#

x = data.iloc[:,2:].values # extrae como tensores numpy
y = data.iloc[:,1].values

Recodifica la variable objetivo#

labelencoder_y = LabelEncoder()
y = labelencoder_y.fit_transform(y)

Divide los datos. Entrenamiento y test#

x_train, x_test, y_train, y_test = train_test_split(x, y, test_size = 0.1, random_state = 0)
x_test.shape
(57, 30)

Normaliza los datos#

sc = StandardScaler()
x_train = sc.fit_transform(x_train)
x_test = sc.transform(x_test)

Crea el modelo Sequential modo 2#

classifier = Sequential()
## Adiciona capas una por una
classifier.add(Dense(units=16, activation='relu', input_shape=(30,)))
# Adiciona dropout para prevenir overfitting (regularización)
classifier.add(Dropout(0.1)) # 10% en cada época
classifier.add(Dense(units=16, activation='relu'))
# Adiciona dropout para prevenir overfitting (regularización)
classifier.add(Dropout(0.1))
classifier.add(Dense(units=1, activation='sigmoid'))

Compila#

classifier.compile(optimizer='adam', loss='binary_crossentropy', metrics=['accuracy'])
classifier.summary()
plot_model(classifier, to_file='../Imagenes/cancer_seno.png', 
           show_shapes=True)
Model: "sequential"
_________________________________________________________________
 Layer (type)                Output Shape              Param #   
=================================================================
 dense (Dense)               (None, 16)                496       
                                                                 
 dropout (Dropout)           (None, 16)                0         
                                                                 
 dense_1 (Dense)             (None, 16)                272       
                                                                 
 dropout_1 (Dropout)         (None, 16)                0         
                                                                 
 dense_2 (Dense)             (None, 1)                 17        
                                                                 
=================================================================
Total params: 785
Trainable params: 785
Non-trainable params: 0
_________________________________________________________________
You must install pydot (`pip install pydot`) and install graphviz (see instructions at https://graphviz.gitlab.io/download/) for plot_model/model_to_dot to work.

Entrenamiento#

history = classifier.fit(x_train, y_train, batch_size=32, epochs=150, validation_split = 0.2)
Epoch 1/150
 1/13 [=>............................] - ETA: 11s - loss: 0.6142 - accuracy: 0.8125

13/13 [==============================] - 1s 33ms/step - loss: 0.5775 - accuracy: 0.8093 - val_loss: 0.5312 - val_accuracy: 0.8544
Epoch 2/150
 1/13 [=>............................] - ETA: 0s - loss: 0.5310 - accuracy: 0.8750

13/13 [==============================] - 0s 8ms/step - loss: 0.4954 - accuracy: 0.9144 - val_loss: 0.4541 - val_accuracy: 0.8835
Epoch 3/150
 1/13 [=>............................] - ETA: 0s - loss: 0.4323 - accuracy: 0.9062

13/13 [==============================] - 0s 7ms/step - loss: 0.4121 - accuracy: 0.9169 - val_loss: 0.3821 - val_accuracy: 0.9320
Epoch 4/150
 1/13 [=>............................] - ETA: 0s - loss: 0.3890 - accuracy: 0.9375

13/13 [==============================] - 0s 8ms/step - loss: 0.3482 - accuracy: 0.9438 - val_loss: 0.3186 - val_accuracy: 0.9320
Epoch 5/150
 1/13 [=>............................] - ETA: 0s - loss: 0.2733 - accuracy: 0.9062

13/13 [==============================] - 0s 10ms/step - loss: 0.2848 - accuracy: 0.9389 - val_loss: 0.2631 - val_accuracy: 0.9417
Epoch 6/150
 1/13 [=>............................] - ETA: 0s - loss: 0.3811 - accuracy: 0.8750

11/13 [========================>.....] - ETA: 0s - loss: 0.2380 - accuracy: 0.9517

13/13 [==============================] - 0s 13ms/step - loss: 0.2425 - accuracy: 0.9511 - val_loss: 0.2183 - val_accuracy: 0.9515
Epoch 7/150
 1/13 [=>............................] - ETA: 0s - loss: 0.2052 - accuracy: 0.9688

13/13 [==============================] - 0s 9ms/step - loss: 0.2069 - accuracy: 0.9487 - val_loss: 0.1853 - val_accuracy: 0.9612
Epoch 8/150
 1/13 [=>............................] - ETA: 0s - loss: 0.1957 - accuracy: 0.9375

11/13 [========================>.....] - ETA: 0s - loss: 0.1729 - accuracy: 0.9460

13/13 [==============================] - 0s 12ms/step - loss: 0.1676 - accuracy: 0.9511 - val_loss: 0.1605 - val_accuracy: 0.9612
Epoch 9/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0819 - accuracy: 1.0000

13/13 [==============================] - 0s 9ms/step - loss: 0.1517 - accuracy: 0.9658 - val_loss: 0.1414 - val_accuracy: 0.9709
Epoch 10/150
 1/13 [=>............................] - ETA: 0s - loss: 0.1745 - accuracy: 0.9375

13/13 [==============================] - 0s 9ms/step - loss: 0.1408 - accuracy: 0.9633 - val_loss: 0.1260 - val_accuracy: 0.9709
Epoch 11/150
 1/13 [=>............................] - ETA: 0s - loss: 0.2834 - accuracy: 0.9062

 9/13 [===================>..........] - ETA: 0s - loss: 0.1328 - accuracy: 0.9549

13/13 [==============================] - 0s 15ms/step - loss: 0.1279 - accuracy: 0.9584 - val_loss: 0.1145 - val_accuracy: 0.9709
Epoch 12/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0924 - accuracy: 1.0000

13/13 [==============================] - 0s 12ms/step - loss: 0.1171 - accuracy: 0.9731 - val_loss: 0.1051 - val_accuracy: 0.9709
Epoch 13/150
 1/13 [=>............................] - ETA: 0s - loss: 0.1213 - accuracy: 0.9688

13/13 [==============================] - 0s 9ms/step - loss: 0.1136 - accuracy: 0.9682 - val_loss: 0.0981 - val_accuracy: 0.9709
Epoch 14/150
 1/13 [=>............................] - ETA: 0s - loss: 0.1147 - accuracy: 0.9375

13/13 [==============================] - 0s 9ms/step - loss: 0.1090 - accuracy: 0.9609 - val_loss: 0.0934 - val_accuracy: 0.9709
Epoch 15/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0639 - accuracy: 1.0000

13/13 [==============================] - 0s 8ms/step - loss: 0.1041 - accuracy: 0.9682 - val_loss: 0.0882 - val_accuracy: 0.9709
Epoch 16/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0473 - accuracy: 1.0000

13/13 [==============================] - 0s 8ms/step - loss: 0.0971 - accuracy: 0.9731 - val_loss: 0.0836 - val_accuracy: 0.9709
Epoch 17/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0831 - accuracy: 0.9688

13/13 [==============================] - 0s 7ms/step - loss: 0.0882 - accuracy: 0.9756 - val_loss: 0.0803 - val_accuracy: 0.9709
Epoch 18/150
 1/13 [=>............................] - ETA: 0s - loss: 0.1621 - accuracy: 0.9375

13/13 [==============================] - 0s 6ms/step - loss: 0.0976 - accuracy: 0.9707 - val_loss: 0.0769 - val_accuracy: 0.9709
Epoch 19/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0903 - accuracy: 0.9688

13/13 [==============================] - 0s 6ms/step - loss: 0.0837 - accuracy: 0.9804 - val_loss: 0.0754 - val_accuracy: 0.9709
Epoch 20/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0435 - accuracy: 1.0000

13/13 [==============================] - 0s 8ms/step - loss: 0.0892 - accuracy: 0.9829 - val_loss: 0.0731 - val_accuracy: 0.9709
Epoch 21/150
 1/13 [=>............................] - ETA: 0s - loss: 0.1747 - accuracy: 0.9375

13/13 [==============================] - 0s 7ms/step - loss: 0.0846 - accuracy: 0.9731 - val_loss: 0.0720 - val_accuracy: 0.9709
Epoch 22/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0741 - accuracy: 0.9688

13/13 [==============================] - 0s 8ms/step - loss: 0.0804 - accuracy: 0.9756 - val_loss: 0.0671 - val_accuracy: 0.9709
Epoch 23/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0685 - accuracy: 1.0000

13/13 [==============================] - 0s 7ms/step - loss: 0.0788 - accuracy: 0.9780 - val_loss: 0.0643 - val_accuracy: 0.9709
Epoch 24/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0316 - accuracy: 1.0000

13/13 [==============================] - 0s 8ms/step - loss: 0.0739 - accuracy: 0.9804 - val_loss: 0.0622 - val_accuracy: 0.9709
Epoch 25/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0457 - accuracy: 1.0000

13/13 [==============================] - 0s 9ms/step - loss: 0.0777 - accuracy: 0.9853 - val_loss: 0.0601 - val_accuracy: 0.9709
Epoch 26/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0453 - accuracy: 1.0000

13/13 [==============================] - 0s 9ms/step - loss: 0.0714 - accuracy: 0.9780 - val_loss: 0.0573 - val_accuracy: 0.9709
Epoch 27/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0316 - accuracy: 1.0000

13/13 [==============================] - 0s 9ms/step - loss: 0.0662 - accuracy: 0.9878 - val_loss: 0.0566 - val_accuracy: 0.9709
Epoch 28/150
 1/13 [=>............................] - ETA: 0s - loss: 0.1155 - accuracy: 0.9688

13/13 [==============================] - 0s 6ms/step - loss: 0.0836 - accuracy: 0.9829 - val_loss: 0.0566 - val_accuracy: 0.9709
Epoch 29/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0100 - accuracy: 1.0000

13/13 [==============================] - 0s 8ms/step - loss: 0.0671 - accuracy: 0.9853 - val_loss: 0.0565 - val_accuracy: 0.9709
Epoch 30/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0462 - accuracy: 0.9688

13/13 [==============================] - 0s 11ms/step - loss: 0.0699 - accuracy: 0.9804 - val_loss: 0.0554 - val_accuracy: 0.9709
Epoch 31/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0579 - accuracy: 1.0000

13/13 [==============================] - 0s 7ms/step - loss: 0.0626 - accuracy: 0.9902 - val_loss: 0.0537 - val_accuracy: 0.9709
Epoch 32/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0340 - accuracy: 1.0000

13/13 [==============================] - 0s 6ms/step - loss: 0.0666 - accuracy: 0.9804 - val_loss: 0.0531 - val_accuracy: 0.9709
Epoch 33/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0750 - accuracy: 0.9688

13/13 [==============================] - 0s 8ms/step - loss: 0.0729 - accuracy: 0.9804 - val_loss: 0.0530 - val_accuracy: 0.9806
Epoch 34/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0214 - accuracy: 1.0000

13/13 [==============================] - 0s 8ms/step - loss: 0.0567 - accuracy: 0.9902 - val_loss: 0.0530 - val_accuracy: 0.9806
Epoch 35/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0406 - accuracy: 1.0000

10/13 [======================>.......] - ETA: 0s - loss: 0.0593 - accuracy: 0.9812

13/13 [==============================] - 0s 11ms/step - loss: 0.0576 - accuracy: 0.9804 - val_loss: 0.0520 - val_accuracy: 0.9806
Epoch 36/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0407 - accuracy: 1.0000

13/13 [==============================] - 0s 7ms/step - loss: 0.0684 - accuracy: 0.9853 - val_loss: 0.0521 - val_accuracy: 0.9806
Epoch 37/150
 1/13 [=>............................] - ETA: 0s - loss: 0.1055 - accuracy: 0.9688

13/13 [==============================] - 0s 8ms/step - loss: 0.0562 - accuracy: 0.9878 - val_loss: 0.0509 - val_accuracy: 0.9806
Epoch 38/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0137 - accuracy: 1.0000

13/13 [==============================] - 0s 7ms/step - loss: 0.0564 - accuracy: 0.9853 - val_loss: 0.0488 - val_accuracy: 0.9806
Epoch 39/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0929 - accuracy: 0.9375

13/13 [==============================] - 0s 7ms/step - loss: 0.0581 - accuracy: 0.9829 - val_loss: 0.0471 - val_accuracy: 0.9709
Epoch 40/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0867 - accuracy: 0.9688

13/13 [==============================] - 0s 7ms/step - loss: 0.0576 - accuracy: 0.9829 - val_loss: 0.0478 - val_accuracy: 0.9709
Epoch 41/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0205 - accuracy: 1.0000

13/13 [==============================] - 0s 6ms/step - loss: 0.0619 - accuracy: 0.9853 - val_loss: 0.0475 - val_accuracy: 0.9806
Epoch 42/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0470 - accuracy: 1.0000

13/13 [==============================] - 0s 8ms/step - loss: 0.0675 - accuracy: 0.9829 - val_loss: 0.0465 - val_accuracy: 0.9806
Epoch 43/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0407 - accuracy: 0.9688

13/13 [==============================] - 0s 9ms/step - loss: 0.0520 - accuracy: 0.9853 - val_loss: 0.0486 - val_accuracy: 0.9806
Epoch 44/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0347 - accuracy: 1.0000

13/13 [==============================] - 0s 8ms/step - loss: 0.0583 - accuracy: 0.9853 - val_loss: 0.0476 - val_accuracy: 0.9806
Epoch 45/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0739 - accuracy: 0.9688

13/13 [==============================] - 0s 7ms/step - loss: 0.0438 - accuracy: 0.9902 - val_loss: 0.0478 - val_accuracy: 0.9806
Epoch 46/150
 1/13 [=>............................] - ETA: 0s - loss: 0.1358 - accuracy: 0.9688

13/13 [==============================] - 0s 9ms/step - loss: 0.0525 - accuracy: 0.9902 - val_loss: 0.0478 - val_accuracy: 0.9806
Epoch 47/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0333 - accuracy: 1.0000

12/13 [==========================>...] - ETA: 0s - loss: 0.0479 - accuracy: 0.9896

13/13 [==============================] - 0s 10ms/step - loss: 0.0464 - accuracy: 0.9902 - val_loss: 0.0480 - val_accuracy: 0.9806
Epoch 48/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0097 - accuracy: 1.0000

13/13 [==============================] - 0s 7ms/step - loss: 0.0537 - accuracy: 0.9853 - val_loss: 0.0484 - val_accuracy: 0.9806
Epoch 49/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0349 - accuracy: 1.0000

13/13 [==============================] - 0s 7ms/step - loss: 0.0525 - accuracy: 0.9878 - val_loss: 0.0463 - val_accuracy: 0.9806
Epoch 50/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0040 - accuracy: 1.0000

13/13 [==============================] - 0s 8ms/step - loss: 0.0465 - accuracy: 0.9878 - val_loss: 0.0479 - val_accuracy: 0.9806
Epoch 51/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0707 - accuracy: 0.9688

13/13 [==============================] - 0s 7ms/step - loss: 0.0433 - accuracy: 0.9853 - val_loss: 0.0486 - val_accuracy: 0.9806
Epoch 52/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0083 - accuracy: 1.0000

13/13 [==============================] - 0s 10ms/step - loss: 0.0521 - accuracy: 0.9853 - val_loss: 0.0466 - val_accuracy: 0.9806
Epoch 53/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0180 - accuracy: 1.0000

13/13 [==============================] - 0s 7ms/step - loss: 0.0462 - accuracy: 0.9878 - val_loss: 0.0439 - val_accuracy: 0.9806
Epoch 54/150
 1/13 [=>............................] - ETA: 0s - loss: 0.1411 - accuracy: 0.9688

13/13 [==============================] - 0s 7ms/step - loss: 0.0536 - accuracy: 0.9829 - val_loss: 0.0441 - val_accuracy: 0.9806
Epoch 55/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0454 - accuracy: 1.0000

13/13 [==============================] - 0s 9ms/step - loss: 0.0424 - accuracy: 0.9878 - val_loss: 0.0436 - val_accuracy: 0.9806
Epoch 56/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0248 - accuracy: 1.0000

11/13 [========================>.....] - ETA: 0s - loss: 0.0407 - accuracy: 0.9915

13/13 [==============================] - 0s 13ms/step - loss: 0.0458 - accuracy: 0.9902 - val_loss: 0.0446 - val_accuracy: 0.9806
Epoch 57/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0093 - accuracy: 1.0000

13/13 [==============================] - 0s 9ms/step - loss: 0.0421 - accuracy: 0.9902 - val_loss: 0.0449 - val_accuracy: 0.9806
Epoch 58/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0172 - accuracy: 1.0000

13/13 [==============================] - 0s 8ms/step - loss: 0.0606 - accuracy: 0.9829 - val_loss: 0.0459 - val_accuracy: 0.9806
Epoch 59/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0986 - accuracy: 0.9688

13/13 [==============================] - 0s 10ms/step - loss: 0.0501 - accuracy: 0.9829 - val_loss: 0.0464 - val_accuracy: 0.9806
Epoch 60/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0126 - accuracy: 1.0000

13/13 [==============================] - 0s 9ms/step - loss: 0.0490 - accuracy: 0.9902 - val_loss: 0.0437 - val_accuracy: 0.9806
Epoch 61/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0156 - accuracy: 1.0000

13/13 [==============================] - 0s 9ms/step - loss: 0.0472 - accuracy: 0.9853 - val_loss: 0.0432 - val_accuracy: 0.9806
Epoch 62/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0237 - accuracy: 1.0000

13/13 [==============================] - 0s 8ms/step - loss: 0.0405 - accuracy: 0.9902 - val_loss: 0.0451 - val_accuracy: 0.9806
Epoch 63/150
 1/13 [=>............................] - ETA: 0s - loss: 0.1147 - accuracy: 0.9688

13/13 [==============================] - 0s 8ms/step - loss: 0.0402 - accuracy: 0.9927 - val_loss: 0.0457 - val_accuracy: 0.9806
Epoch 64/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0063 - accuracy: 1.0000

13/13 [==============================] - 0s 7ms/step - loss: 0.0457 - accuracy: 0.9902 - val_loss: 0.0459 - val_accuracy: 0.9806
Epoch 65/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0061 - accuracy: 1.0000

13/13 [==============================] - 0s 7ms/step - loss: 0.0387 - accuracy: 0.9804 - val_loss: 0.0451 - val_accuracy: 0.9806
Epoch 66/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0234 - accuracy: 1.0000

13/13 [==============================] - 0s 7ms/step - loss: 0.0425 - accuracy: 0.9853 - val_loss: 0.0459 - val_accuracy: 0.9806
Epoch 67/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0542 - accuracy: 0.9688

13/13 [==============================] - 0s 5ms/step - loss: 0.0401 - accuracy: 0.9902 - val_loss: 0.0478 - val_accuracy: 0.9806
Epoch 68/150
 1/13 [=>............................] - ETA: 0s - loss: 0.1639 - accuracy: 0.9688

13/13 [==============================] - 0s 7ms/step - loss: 0.0406 - accuracy: 0.9902 - val_loss: 0.0460 - val_accuracy: 0.9806
Epoch 69/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0403 - accuracy: 0.9688

13/13 [==============================] - 0s 5ms/step - loss: 0.0394 - accuracy: 0.9878 - val_loss: 0.0420 - val_accuracy: 0.9806
Epoch 70/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0768 - accuracy: 0.9688

13/13 [==============================] - 0s 7ms/step - loss: 0.0419 - accuracy: 0.9878 - val_loss: 0.0422 - val_accuracy: 0.9806
Epoch 71/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0191 - accuracy: 1.0000

13/13 [==============================] - 0s 7ms/step - loss: 0.0395 - accuracy: 0.9878 - val_loss: 0.0420 - val_accuracy: 0.9806
Epoch 72/150
 1/13 [=>............................] - ETA: 0s - loss: 0.1536 - accuracy: 0.9688

10/13 [======================>.......] - ETA: 0s - loss: 0.0646 - accuracy: 0.9750

13/13 [==============================] - 0s 10ms/step - loss: 0.0548 - accuracy: 0.9804 - val_loss: 0.0418 - val_accuracy: 0.9806
Epoch 73/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0123 - accuracy: 1.0000

13/13 [==============================] - 0s 7ms/step - loss: 0.0347 - accuracy: 0.9927 - val_loss: 0.0422 - val_accuracy: 0.9806
Epoch 74/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0758 - accuracy: 0.9688

13/13 [==============================] - 0s 8ms/step - loss: 0.0384 - accuracy: 0.9878 - val_loss: 0.0431 - val_accuracy: 0.9806
Epoch 75/150
 1/13 [=>............................] - ETA: 0s - loss: 0.1166 - accuracy: 0.9688

13/13 [==============================] - 0s 7ms/step - loss: 0.0495 - accuracy: 0.9853 - val_loss: 0.0433 - val_accuracy: 0.9806
Epoch 76/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0087 - accuracy: 1.0000

13/13 [==============================] - 0s 7ms/step - loss: 0.0347 - accuracy: 0.9878 - val_loss: 0.0417 - val_accuracy: 0.9806
Epoch 77/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0431 - accuracy: 0.9688

13/13 [==============================] - 0s 7ms/step - loss: 0.0406 - accuracy: 0.9878 - val_loss: 0.0427 - val_accuracy: 0.9806
Epoch 78/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0180 - accuracy: 1.0000

13/13 [==============================] - 0s 7ms/step - loss: 0.0375 - accuracy: 0.9927 - val_loss: 0.0412 - val_accuracy: 0.9806
Epoch 79/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0174 - accuracy: 1.0000

13/13 [==============================] - 0s 7ms/step - loss: 0.0369 - accuracy: 0.9853 - val_loss: 0.0399 - val_accuracy: 0.9806
Epoch 80/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0032 - accuracy: 1.0000

13/13 [==============================] - 0s 7ms/step - loss: 0.0378 - accuracy: 0.9878 - val_loss: 0.0397 - val_accuracy: 0.9806
Epoch 81/150
 1/13 [=>............................] - ETA: 0s - loss: 0.1500 - accuracy: 0.9375

13/13 [==============================] - 0s 6ms/step - loss: 0.0370 - accuracy: 0.9853 - val_loss: 0.0398 - val_accuracy: 0.9806
Epoch 82/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0248 - accuracy: 1.0000

13/13 [==============================] - 0s 8ms/step - loss: 0.0335 - accuracy: 0.9927 - val_loss: 0.0389 - val_accuracy: 0.9806
Epoch 83/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0438 - accuracy: 1.0000

13/13 [==============================] - 0s 9ms/step - loss: 0.0331 - accuracy: 0.9878 - val_loss: 0.0377 - val_accuracy: 0.9806
Epoch 84/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0769 - accuracy: 0.9688

13/13 [==============================] - 0s 7ms/step - loss: 0.0410 - accuracy: 0.9878 - val_loss: 0.0389 - val_accuracy: 0.9806
Epoch 85/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0071 - accuracy: 1.0000

13/13 [==============================] - 0s 7ms/step - loss: 0.0368 - accuracy: 0.9878 - val_loss: 0.0384 - val_accuracy: 0.9806
Epoch 86/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0084 - accuracy: 1.0000

13/13 [==============================] - 0s 7ms/step - loss: 0.0399 - accuracy: 0.9878 - val_loss: 0.0392 - val_accuracy: 0.9806
Epoch 87/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0707 - accuracy: 0.9688

13/13 [==============================] - 0s 8ms/step - loss: 0.0395 - accuracy: 0.9829 - val_loss: 0.0428 - val_accuracy: 0.9806
Epoch 88/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0111 - accuracy: 1.0000

13/13 [==============================] - 0s 8ms/step - loss: 0.0312 - accuracy: 0.9927 - val_loss: 0.0440 - val_accuracy: 0.9806
Epoch 89/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0254 - accuracy: 1.0000

13/13 [==============================] - 0s 8ms/step - loss: 0.0242 - accuracy: 0.9927 - val_loss: 0.0416 - val_accuracy: 0.9806
Epoch 90/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0401 - accuracy: 0.9688

13/13 [==============================] - 0s 6ms/step - loss: 0.0336 - accuracy: 0.9853 - val_loss: 0.0404 - val_accuracy: 0.9806
Epoch 91/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0223 - accuracy: 1.0000

13/13 [==============================] - 0s 7ms/step - loss: 0.0310 - accuracy: 0.9927 - val_loss: 0.0400 - val_accuracy: 0.9806
Epoch 92/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0029 - accuracy: 1.0000

13/13 [==============================] - 0s 8ms/step - loss: 0.0317 - accuracy: 0.9878 - val_loss: 0.0396 - val_accuracy: 0.9806
Epoch 93/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0228 - accuracy: 1.0000

13/13 [==============================] - 0s 8ms/step - loss: 0.0419 - accuracy: 0.9853 - val_loss: 0.0400 - val_accuracy: 0.9806
Epoch 94/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0228 - accuracy: 1.0000

13/13 [==============================] - 0s 7ms/step - loss: 0.0319 - accuracy: 0.9878 - val_loss: 0.0411 - val_accuracy: 0.9806
Epoch 95/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0093 - accuracy: 1.0000

13/13 [==============================] - 0s 7ms/step - loss: 0.0366 - accuracy: 0.9878 - val_loss: 0.0414 - val_accuracy: 0.9806
Epoch 96/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0231 - accuracy: 1.0000

13/13 [==============================] - 0s 7ms/step - loss: 0.0363 - accuracy: 0.9902 - val_loss: 0.0419 - val_accuracy: 0.9806
Epoch 97/150
 1/13 [=>............................] - ETA: 0s - loss: 0.1060 - accuracy: 0.9375

13/13 [==============================] - 0s 6ms/step - loss: 0.0374 - accuracy: 0.9829 - val_loss: 0.0414 - val_accuracy: 0.9806
Epoch 98/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0999 - accuracy: 0.9688

13/13 [==============================] - 0s 7ms/step - loss: 0.0329 - accuracy: 0.9878 - val_loss: 0.0402 - val_accuracy: 0.9806
Epoch 99/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0082 - accuracy: 1.0000

13/13 [==============================] - 0s 8ms/step - loss: 0.0370 - accuracy: 0.9902 - val_loss: 0.0384 - val_accuracy: 0.9806
Epoch 100/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0293 - accuracy: 0.9688

13/13 [==============================] - 0s 7ms/step - loss: 0.0276 - accuracy: 0.9902 - val_loss: 0.0371 - val_accuracy: 0.9806
Epoch 101/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0608 - accuracy: 0.9688

13/13 [==============================] - 0s 9ms/step - loss: 0.0279 - accuracy: 0.9902 - val_loss: 0.0383 - val_accuracy: 0.9806
Epoch 102/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0493 - accuracy: 0.9688

13/13 [==============================] - 0s 9ms/step - loss: 0.0320 - accuracy: 0.9878 - val_loss: 0.0403 - val_accuracy: 0.9806
Epoch 103/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0319 - accuracy: 0.9688

13/13 [==============================] - 0s 8ms/step - loss: 0.0299 - accuracy: 0.9902 - val_loss: 0.0406 - val_accuracy: 0.9806
Epoch 104/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0051 - accuracy: 1.0000

13/13 [==============================] - 0s 7ms/step - loss: 0.0376 - accuracy: 0.9878 - val_loss: 0.0373 - val_accuracy: 0.9806
Epoch 105/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0043 - accuracy: 1.0000

13/13 [==============================] - 0s 8ms/step - loss: 0.0367 - accuracy: 0.9853 - val_loss: 0.0368 - val_accuracy: 0.9806
Epoch 106/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0075 - accuracy: 1.0000

13/13 [==============================] - 0s 8ms/step - loss: 0.0331 - accuracy: 0.9878 - val_loss: 0.0398 - val_accuracy: 0.9806
Epoch 107/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0807 - accuracy: 0.9688

13/13 [==============================] - ETA: 0s - loss: 0.0278 - accuracy: 0.9878

13/13 [==============================] - 0s 10ms/step - loss: 0.0278 - accuracy: 0.9878 - val_loss: 0.0428 - val_accuracy: 0.9806
Epoch 108/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0107 - accuracy: 1.0000

13/13 [==============================] - 0s 7ms/step - loss: 0.0252 - accuracy: 0.9951 - val_loss: 0.0432 - val_accuracy: 0.9806
Epoch 109/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0202 - accuracy: 1.0000

13/13 [==============================] - 0s 8ms/step - loss: 0.0317 - accuracy: 0.9829 - val_loss: 0.0400 - val_accuracy: 0.9806
Epoch 110/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0116 - accuracy: 1.0000

13/13 [==============================] - 0s 11ms/step - loss: 0.0307 - accuracy: 0.9927 - val_loss: 0.0403 - val_accuracy: 0.9806
Epoch 111/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0121 - accuracy: 1.0000

13/13 [==============================] - 0s 8ms/step - loss: 0.0210 - accuracy: 0.9927 - val_loss: 0.0414 - val_accuracy: 0.9806
Epoch 112/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0174 - accuracy: 1.0000

13/13 [==============================] - 0s 7ms/step - loss: 0.0240 - accuracy: 0.9927 - val_loss: 0.0418 - val_accuracy: 0.9806
Epoch 113/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0029 - accuracy: 1.0000

13/13 [==============================] - 0s 7ms/step - loss: 0.0287 - accuracy: 0.9927 - val_loss: 0.0408 - val_accuracy: 0.9806
Epoch 114/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0192 - accuracy: 1.0000

13/13 [==============================] - 0s 7ms/step - loss: 0.0263 - accuracy: 0.9927 - val_loss: 0.0427 - val_accuracy: 0.9806
Epoch 115/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0052 - accuracy: 1.0000

13/13 [==============================] - 0s 9ms/step - loss: 0.0307 - accuracy: 0.9902 - val_loss: 0.0408 - val_accuracy: 0.9806
Epoch 116/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0189 - accuracy: 1.0000

13/13 [==============================] - 0s 8ms/step - loss: 0.0249 - accuracy: 0.9902 - val_loss: 0.0435 - val_accuracy: 0.9806
Epoch 117/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0088 - accuracy: 1.0000

13/13 [==============================] - 0s 9ms/step - loss: 0.0266 - accuracy: 0.9902 - val_loss: 0.0425 - val_accuracy: 0.9806
Epoch 118/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0128 - accuracy: 1.0000

13/13 [==============================] - 0s 12ms/step - loss: 0.0178 - accuracy: 0.9927 - val_loss: 0.0413 - val_accuracy: 0.9806
Epoch 119/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0885 - accuracy: 0.9688

13/13 [==============================] - 0s 9ms/step - loss: 0.0297 - accuracy: 0.9878 - val_loss: 0.0397 - val_accuracy: 0.9806
Epoch 120/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0302 - accuracy: 1.0000

13/13 [==============================] - 0s 10ms/step - loss: 0.0223 - accuracy: 0.9951 - val_loss: 0.0389 - val_accuracy: 0.9806
Epoch 121/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0050 - accuracy: 1.0000

13/13 [==============================] - 0s 8ms/step - loss: 0.0183 - accuracy: 0.9927 - val_loss: 0.0406 - val_accuracy: 0.9806
Epoch 122/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0378 - accuracy: 0.9688

13/13 [==============================] - ETA: 0s - loss: 0.0262 - accuracy: 0.9902

13/13 [==============================] - 0s 9ms/step - loss: 0.0262 - accuracy: 0.9902 - val_loss: 0.0402 - val_accuracy: 0.9806
Epoch 123/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0417 - accuracy: 0.9688

13/13 [==============================] - 0s 9ms/step - loss: 0.0283 - accuracy: 0.9902 - val_loss: 0.0380 - val_accuracy: 0.9806
Epoch 124/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0072 - accuracy: 1.0000

13/13 [==============================] - 0s 8ms/step - loss: 0.0303 - accuracy: 0.9902 - val_loss: 0.0347 - val_accuracy: 0.9903
Epoch 125/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0601 - accuracy: 0.9688

13/13 [==============================] - 0s 8ms/step - loss: 0.0218 - accuracy: 0.9902 - val_loss: 0.0336 - val_accuracy: 0.9903
Epoch 126/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0072 - accuracy: 1.0000

13/13 [==============================] - ETA: 0s - loss: 0.0265 - accuracy: 0.9902

13/13 [==============================] - 0s 10ms/step - loss: 0.0265 - accuracy: 0.9902 - val_loss: 0.0333 - val_accuracy: 0.9806
Epoch 127/150
 1/13 [=>............................] - ETA: 0s - loss: 0.1305 - accuracy: 0.9375

13/13 [==============================] - 0s 9ms/step - loss: 0.0240 - accuracy: 0.9902 - val_loss: 0.0363 - val_accuracy: 0.9806
Epoch 128/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0152 - accuracy: 1.0000

13/13 [==============================] - ETA: 0s - loss: 0.0200 - accuracy: 0.9951

13/13 [==============================] - 0s 11ms/step - loss: 0.0200 - accuracy: 0.9951 - val_loss: 0.0368 - val_accuracy: 0.9806
Epoch 129/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0721 - accuracy: 0.9688

12/13 [==========================>...] - ETA: 0s - loss: 0.0158 - accuracy: 0.9974

13/13 [==============================] - 0s 10ms/step - loss: 0.0186 - accuracy: 0.9951 - val_loss: 0.0392 - val_accuracy: 0.9806
Epoch 130/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0576 - accuracy: 0.9688

13/13 [==============================] - 0s 8ms/step - loss: 0.0227 - accuracy: 0.9902 - val_loss: 0.0383 - val_accuracy: 0.9806
Epoch 131/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0090 - accuracy: 1.0000

13/13 [==============================] - 0s 8ms/step - loss: 0.0256 - accuracy: 0.9927 - val_loss: 0.0376 - val_accuracy: 0.9806
Epoch 132/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0672 - accuracy: 0.9688

13/13 [==============================] - 0s 9ms/step - loss: 0.0205 - accuracy: 0.9902 - val_loss: 0.0386 - val_accuracy: 0.9806
Epoch 133/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0080 - accuracy: 1.0000

13/13 [==============================] - 0s 9ms/step - loss: 0.0263 - accuracy: 0.9927 - val_loss: 0.0376 - val_accuracy: 0.9806
Epoch 134/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0020 - accuracy: 1.0000

13/13 [==============================] - 0s 10ms/step - loss: 0.0217 - accuracy: 0.9927 - val_loss: 0.0379 - val_accuracy: 0.9806
Epoch 135/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0049 - accuracy: 1.0000

11/13 [========================>.....] - ETA: 0s - loss: 0.0165 - accuracy: 0.9915

13/13 [==============================] - 0s 13ms/step - loss: 0.0153 - accuracy: 0.9927 - val_loss: 0.0386 - val_accuracy: 0.9806
Epoch 136/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0109 - accuracy: 1.0000

13/13 [==============================] - ETA: 0s - loss: 0.0287 - accuracy: 0.9902

13/13 [==============================] - 0s 17ms/step - loss: 0.0287 - accuracy: 0.9902 - val_loss: 0.0432 - val_accuracy: 0.9806
Epoch 137/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0587 - accuracy: 0.9375

12/13 [==========================>...] - ETA: 0s - loss: 0.0217 - accuracy: 0.9896

13/13 [==============================] - 0s 11ms/step - loss: 0.0205 - accuracy: 0.9902 - val_loss: 0.0434 - val_accuracy: 0.9806
Epoch 138/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0779 - accuracy: 0.9375

12/13 [==========================>...] - ETA: 0s - loss: 0.0200 - accuracy: 0.9896

13/13 [==============================] - 0s 12ms/step - loss: 0.0188 - accuracy: 0.9902 - val_loss: 0.0403 - val_accuracy: 0.9806
Epoch 139/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0070 - accuracy: 1.0000

13/13 [==============================] - ETA: 0s - loss: 0.0148 - accuracy: 0.9927

13/13 [==============================] - 0s 12ms/step - loss: 0.0148 - accuracy: 0.9927 - val_loss: 0.0412 - val_accuracy: 0.9806
Epoch 140/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0151 - accuracy: 1.0000

13/13 [==============================] - ETA: 0s - loss: 0.0210 - accuracy: 0.9902

13/13 [==============================] - 0s 10ms/step - loss: 0.0210 - accuracy: 0.9902 - val_loss: 0.0400 - val_accuracy: 0.9806
Epoch 141/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0019 - accuracy: 1.0000

13/13 [==============================] - ETA: 0s - loss: 0.0209 - accuracy: 0.9927

13/13 [==============================] - 0s 10ms/step - loss: 0.0209 - accuracy: 0.9927 - val_loss: 0.0432 - val_accuracy: 0.9806
Epoch 142/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0088 - accuracy: 1.0000

13/13 [==============================] - 0s 9ms/step - loss: 0.0153 - accuracy: 0.9927 - val_loss: 0.0447 - val_accuracy: 0.9806
Epoch 143/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0012 - accuracy: 1.0000

13/13 [==============================] - 0s 8ms/step - loss: 0.0215 - accuracy: 0.9902 - val_loss: 0.0448 - val_accuracy: 0.9806
Epoch 144/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0011 - accuracy: 1.0000

13/13 [==============================] - 0s 8ms/step - loss: 0.0294 - accuracy: 0.9902 - val_loss: 0.0483 - val_accuracy: 0.9806
Epoch 145/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0061 - accuracy: 1.0000

13/13 [==============================] - 0s 8ms/step - loss: 0.0160 - accuracy: 0.9927 - val_loss: 0.0529 - val_accuracy: 0.9806
Epoch 146/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0083 - accuracy: 1.0000

13/13 [==============================] - 0s 9ms/step - loss: 0.0236 - accuracy: 0.9927 - val_loss: 0.0380 - val_accuracy: 0.9806
Epoch 147/150
 1/13 [=>............................] - ETA: 0s - loss: 7.4786e-04 - accuracy: 1.0000

13/13 [==============================] - 0s 11ms/step - loss: 0.0178 - accuracy: 0.9927 - val_loss: 0.0348 - val_accuracy: 0.9806
Epoch 148/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0101 - accuracy: 1.0000

13/13 [==============================] - 0s 9ms/step - loss: 0.0202 - accuracy: 0.9951 - val_loss: 0.0359 - val_accuracy: 0.9806
Epoch 149/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0132 - accuracy: 1.0000

13/13 [==============================] - 0s 7ms/step - loss: 0.0123 - accuracy: 0.9951 - val_loss: 0.0355 - val_accuracy: 0.9806
Epoch 150/150
 1/13 [=>............................] - ETA: 0s - loss: 0.0107 - accuracy: 1.0000

13/13 [==============================] - 0s 8ms/step - loss: 0.0188 - accuracy: 0.9927 - val_loss: 0.0350 - val_accuracy: 0.9806

Predicciones#

# Predicción de los resultados del conjunto de pruebas
y_pred = classifier.predict(x_test)
# y_pred = (y_pred > 0.5)
y_pred[y_pred > 0.5] = 1
y_pred[y_pred <=0.5] = 0
1/2 [==============>...............] - ETA: 5s

2/2 [==============================] - 5s 0s/step

Matriz de confusión#

cm = confusion_matrix(y_test, y_pred)
print("Our accuracy is {}%".format(((cm[0][0] + cm[1][1])/y_test.shape[0])*100))
Our accuracy is 98.24561403508771%
sns.heatmap(cm, annot=True)
<AxesSubplot:>
../../_images/am-logistico-keras-cancer_42_1.png

Evaluación del modelo#

def plot_metric(history, metric):
    train_metrics = history.history[metric]
    val_metrics = history.history['val_'+metric]
    epochs = range(1, len(train_metrics) + 1)
    plt.plot(epochs, train_metrics, 'bo--')
    plt.plot(epochs, val_metrics, 'ro-')
    plt.title('Entrenamiento y validación '+ metric)
    plt.xlabel("Epochs")
    plt.ylabel(metric)
    plt.legend(["train_"+metric, 'val_'+metric])
    plt.show()
plot_metric(history, 'loss')
../../_images/am-logistico-keras-cancer_45_0.png
plot_metric(history, 'accuracy')
../../_images/am-logistico-keras-cancer_46_0.png