import pandas as pd
data = pd.read_csv('https://cursopypagina.github.io/CursoPy/milknew.csv')
data
pH | Temprature | Taste | Odor | Fat | Turbidity | Colour | Grade | |
---|---|---|---|---|---|---|---|---|
0 | 6.6 | 35 | 1 | 0 | 1 | 0 | 254 | high |
1 | 6.6 | 36 | 0 | 1 | 0 | 1 | 253 | high |
2 | 8.5 | 70 | 1 | 1 | 1 | 1 | 246 | low |
3 | 9.5 | 34 | 1 | 1 | 0 | 1 | 255 | low |
4 | 6.6 | 37 | 0 | 0 | 0 | 0 | 255 | medium |
... | ... | ... | ... | ... | ... | ... | ... | ... |
1054 | 6.7 | 45 | 1 | 1 | 0 | 0 | 247 | medium |
1055 | 6.7 | 38 | 1 | 0 | 1 | 0 | 255 | high |
1056 | 3.0 | 40 | 1 | 1 | 1 | 1 | 255 | low |
1057 | 6.8 | 43 | 1 | 0 | 1 | 0 | 250 | high |
1058 | 8.6 | 55 | 0 | 1 | 1 | 1 | 255 | low |
1059 rows × 8 columns
# Importaciones necesarias
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import confusion_matrix, ConfusionMatrixDisplay
from sklearn.metrics import f1_score, recall_score, precision_score, accuracy_score
from sklearn.preprocessing import OneHotEncoder
from keras.models import Sequential
from keras.layers.core import Activation
from keras.layers import Dense
import tensorflow as tf
import matplotlib.pyplot as plt
import matplotlib as mpl
import pandas as pd
import numpy as np
import warnings
# configuracion para no ver en salida las advertencias
warnings.simplefilter("ignore")
# Configuramos el estilo de graficacion
plt.style.use('seaborn')
# Instanciamos y configuramos one hot encoder
enc = OneHotEncoder(handle_unknown='ignore')
data.head()
pH | Temprature | Taste | Odor | Fat | Turbidity | Colour | Grade | |
---|---|---|---|---|---|---|---|---|
0 | 6.6 | 35 | 1 | 0 | 1 | 0 | 254 | high |
1 | 6.6 | 36 | 0 | 1 | 0 | 1 | 253 | high |
2 | 8.5 | 70 | 1 | 1 | 1 | 1 | 246 | low |
3 | 9.5 | 34 | 1 | 1 | 0 | 1 | 255 | low |
4 | 6.6 | 37 | 0 | 0 | 0 | 0 | 255 | medium |
# Definicion de las variables
X = data.drop('Grade', axis=1).values
y = data.Grade.values.reshape(-1,1)
# Conjuntos de entrenamiento y prueba
X_train, X_test, y_train, y_test = train_test_split(X, y,
test_size = 0.3,
shuffle = True,
random_state = 123)
# Aplicamos el one hot encoder a y_train y y_test
y_train = enc.fit_transform(y_train).toarray()
y_test = enc.fit_transform(y_test).toarray()
# Definimos una funcion para entrenar la red neuronal
# con distinto numero de neuronas, epocas y batch size
def train_eval_model(x1, y1, x2, y2, n1, n2, n, k):
"""Función para realizar el entrenamiento de la red neuronal. Asimismo,
se realiza la evaluación del mismo.
Parámetros:
* x1: X_train.
* y1: y_train.
* x2: X_test.
* y2: y_test.
* n1: número de neuronas en la primer capa oculta.
* n2: número de neuronas en la segunda capa oculta.
* n: número de épocas.
* k: batch_size."""
# Instanciamos el modelo secuencial
model = Sequential()
# Capa de entrada y primera capa oculta
model.add(Dense(n1, activation='relu', input_shape=(7,)))
# Capa oculta 2
model.add(Dense(n2, activation='relu'))
# Capa de salida
model.add(Dense(3, activation='softmax'))
# Copilacion del modelo
model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy'])
# Entrenamiento del modelo.
# Destinamos el 15% de los datos de entrenamiento para la validacion
history = model.fit(x1, y1, epochs=n, validation_split=0.15, batch_size=k)
# Evalucacion del modelo
scores = model.evaluate(x2, y2)
print('%s: %.4f%%' % (model.metrics_names[1], scores[1] * 100))
# Grafico de la precision del entrenamiento vs precision de la validacion
plt.plot(history.history['accuracy'])
plt.plot(history.history['val_accuracy'])
plt.title('Precisión del modelo')
plt.xlabel('Epoch')
plt.ylabel('Precisión')
plt.legend(['Train', 'Validación'])
plt.show()
train_eval_model(X_train, y_train, X_test, y_test, 56, 21, 5, 5)
Epoch 1/5 126/126 [==============================] - 2s 4ms/step - loss: 3.1685 - accuracy: 0.3386 - val_loss: 1.4411 - val_accuracy: 0.4018 Epoch 2/5 126/126 [==============================] - 0s 2ms/step - loss: 1.2068 - accuracy: 0.4420 - val_loss: 1.4002 - val_accuracy: 0.4643 Epoch 3/5 126/126 [==============================] - 0s 2ms/step - loss: 1.0785 - accuracy: 0.4722 - val_loss: 1.0307 - val_accuracy: 0.3750 Epoch 4/5 126/126 [==============================] - 0s 2ms/step - loss: 1.0600 - accuracy: 0.5087 - val_loss: 1.0377 - val_accuracy: 0.5446 Epoch 5/5 126/126 [==============================] - 0s 2ms/step - loss: 1.0842 - accuracy: 0.5167 - val_loss: 1.4827 - val_accuracy: 0.4464 10/10 [==============================] - 0s 1ms/step - loss: 1.3713 - accuracy: 0.4969 accuracy: 49.6855%
train_eval_model(X_train, y_train, X_test, y_test, 56, 21, 5, 10)
Epoch 1/5 63/63 [==============================] - 1s 4ms/step - loss: 4.7327 - accuracy: 0.4213 - val_loss: 0.9677 - val_accuracy: 0.5625 Epoch 2/5 63/63 [==============================] - 0s 2ms/step - loss: 1.0545 - accuracy: 0.4992 - val_loss: 1.0372 - val_accuracy: 0.4375 Epoch 3/5 63/63 [==============================] - 0s 2ms/step - loss: 0.9547 - accuracy: 0.5358 - val_loss: 1.0120 - val_accuracy: 0.5089 Epoch 4/5 63/63 [==============================] - 0s 2ms/step - loss: 0.9430 - accuracy: 0.5374 - val_loss: 1.0082 - val_accuracy: 0.5179 Epoch 5/5 63/63 [==============================] - 0s 2ms/step - loss: 0.9527 - accuracy: 0.5564 - val_loss: 1.0125 - val_accuracy: 0.4821 10/10 [==============================] - 0s 1ms/step - loss: 0.9320 - accuracy: 0.5755 accuracy: 57.5472%
train_eval_model(X_train, y_train, X_test, y_test, 56, 21, 15, 10)
Epoch 1/15 63/63 [==============================] - 1s 4ms/step - loss: 3.7845 - accuracy: 0.3577 - val_loss: 1.3080 - val_accuracy: 0.3304 Epoch 2/15 63/63 [==============================] - 0s 2ms/step - loss: 1.0080 - accuracy: 0.4897 - val_loss: 0.8929 - val_accuracy: 0.5714 Epoch 3/15 63/63 [==============================] - 0s 2ms/step - loss: 0.8928 - accuracy: 0.5739 - val_loss: 1.2841 - val_accuracy: 0.5089 Epoch 4/15 63/63 [==============================] - 0s 2ms/step - loss: 0.9794 - accuracy: 0.5930 - val_loss: 1.0313 - val_accuracy: 0.4375 Epoch 5/15 63/63 [==============================] - 0s 2ms/step - loss: 0.9300 - accuracy: 0.5501 - val_loss: 0.9576 - val_accuracy: 0.5089 Epoch 6/15 63/63 [==============================] - 0s 2ms/step - loss: 0.9003 - accuracy: 0.5914 - val_loss: 0.8889 - val_accuracy: 0.5357 Epoch 7/15 63/63 [==============================] - 0s 2ms/step - loss: 0.8047 - accuracy: 0.6391 - val_loss: 0.9561 - val_accuracy: 0.5714 Epoch 8/15 63/63 [==============================] - 0s 2ms/step - loss: 0.8513 - accuracy: 0.6328 - val_loss: 0.8716 - val_accuracy: 0.6429 Epoch 9/15 63/63 [==============================] - 0s 2ms/step - loss: 0.9319 - accuracy: 0.5946 - val_loss: 1.2490 - val_accuracy: 0.4732 Epoch 10/15 63/63 [==============================] - 0s 2ms/step - loss: 0.9445 - accuracy: 0.6105 - val_loss: 0.7887 - val_accuracy: 0.5714 Epoch 11/15 63/63 [==============================] - 0s 2ms/step - loss: 0.8398 - accuracy: 0.6264 - val_loss: 0.7716 - val_accuracy: 0.6339 Epoch 12/15 63/63 [==============================] - 0s 2ms/step - loss: 0.7838 - accuracy: 0.6439 - val_loss: 0.7622 - val_accuracy: 0.6250 Epoch 13/15 63/63 [==============================] - 0s 2ms/step - loss: 0.7908 - accuracy: 0.6391 - val_loss: 0.7817 - val_accuracy: 0.6696 Epoch 14/15 63/63 [==============================] - 0s 2ms/step - loss: 0.7179 - accuracy: 0.6741 - val_loss: 0.7689 - val_accuracy: 0.5804 Epoch 15/15 63/63 [==============================] - 0s 2ms/step - loss: 0.7957 - accuracy: 0.6455 - val_loss: 0.7369 - val_accuracy: 0.5982 10/10 [==============================] - 0s 1ms/step - loss: 0.6330 - accuracy: 0.6667 accuracy: 66.6667%
train_eval_model(X_train, y_train, X_test, y_test, 70, 40, 15, 10)
Epoch 1/15 63/63 [==============================] - 1s 5ms/step - loss: 2.6239 - accuracy: 0.3625 - val_loss: 1.0043 - val_accuracy: 0.4732 Epoch 2/15 63/63 [==============================] - 0s 2ms/step - loss: 1.2542 - accuracy: 0.4404 - val_loss: 1.1436 - val_accuracy: 0.5089 Epoch 3/15 63/63 [==============================] - 0s 2ms/step - loss: 1.0701 - accuracy: 0.5008 - val_loss: 0.9438 - val_accuracy: 0.5179 Epoch 4/15 63/63 [==============================] - 0s 2ms/step - loss: 1.0312 - accuracy: 0.5151 - val_loss: 1.2310 - val_accuracy: 0.5357 Epoch 5/15 63/63 [==============================] - 0s 2ms/step - loss: 1.1047 - accuracy: 0.5533 - val_loss: 1.6473 - val_accuracy: 0.5089 Epoch 6/15 63/63 [==============================] - 0s 2ms/step - loss: 1.2741 - accuracy: 0.4976 - val_loss: 1.3502 - val_accuracy: 0.4821 Epoch 7/15 63/63 [==============================] - 0s 2ms/step - loss: 1.1664 - accuracy: 0.5469 - val_loss: 1.6382 - val_accuracy: 0.5179 Epoch 8/15 63/63 [==============================] - 0s 2ms/step - loss: 0.9417 - accuracy: 0.6169 - val_loss: 1.0166 - val_accuracy: 0.5714 Epoch 9/15 63/63 [==============================] - 0s 2ms/step - loss: 1.5314 - accuracy: 0.5374 - val_loss: 1.3891 - val_accuracy: 0.5536 Epoch 10/15 63/63 [==============================] - 0s 2ms/step - loss: 0.9487 - accuracy: 0.5914 - val_loss: 1.3912 - val_accuracy: 0.5536 Epoch 11/15 63/63 [==============================] - 0s 2ms/step - loss: 1.2958 - accuracy: 0.5485 - val_loss: 0.8340 - val_accuracy: 0.5982 Epoch 12/15 63/63 [==============================] - 0s 2ms/step - loss: 0.7369 - accuracy: 0.6407 - val_loss: 0.7104 - val_accuracy: 0.5714 Epoch 13/15 63/63 [==============================] - 0s 2ms/step - loss: 0.7699 - accuracy: 0.6439 - val_loss: 0.9825 - val_accuracy: 0.6250 Epoch 14/15 63/63 [==============================] - 0s 2ms/step - loss: 1.0924 - accuracy: 0.5819 - val_loss: 1.0766 - val_accuracy: 0.5000 Epoch 15/15 63/63 [==============================] - 0s 2ms/step - loss: 0.9561 - accuracy: 0.6121 - val_loss: 0.7275 - val_accuracy: 0.6250 10/10 [==============================] - 0s 1ms/step - loss: 0.6356 - accuracy: 0.7075 accuracy: 70.7547%
train_eval_model(X_train, y_train, X_test, y_test, 70, 20, 15, 10)
Epoch 1/15 63/63 [==============================] - 1s 4ms/step - loss: 2.6935 - accuracy: 0.4372 - val_loss: 0.9719 - val_accuracy: 0.4643 Epoch 2/15 63/63 [==============================] - 0s 2ms/step - loss: 1.0157 - accuracy: 0.4928 - val_loss: 0.9554 - val_accuracy: 0.5536 Epoch 3/15 63/63 [==============================] - 0s 2ms/step - loss: 0.9899 - accuracy: 0.5278 - val_loss: 1.0383 - val_accuracy: 0.5982 Epoch 4/15 63/63 [==============================] - 0s 2ms/step - loss: 0.9386 - accuracy: 0.5533 - val_loss: 1.1095 - val_accuracy: 0.4911 Epoch 5/15 63/63 [==============================] - 0s 2ms/step - loss: 1.0454 - accuracy: 0.5215 - val_loss: 0.8732 - val_accuracy: 0.6250 Epoch 6/15 63/63 [==============================] - 0s 2ms/step - loss: 0.8858 - accuracy: 0.5771 - val_loss: 0.8798 - val_accuracy: 0.5714 Epoch 7/15 63/63 [==============================] - 0s 2ms/step - loss: 0.8394 - accuracy: 0.5994 - val_loss: 0.8703 - val_accuracy: 0.7232 Epoch 8/15 63/63 [==============================] - 0s 2ms/step - loss: 0.8251 - accuracy: 0.6137 - val_loss: 0.8250 - val_accuracy: 0.5625 Epoch 9/15 63/63 [==============================] - 0s 2ms/step - loss: 0.9355 - accuracy: 0.5755 - val_loss: 0.8456 - val_accuracy: 0.6250 Epoch 10/15 63/63 [==============================] - 0s 2ms/step - loss: 0.7967 - accuracy: 0.6312 - val_loss: 0.8838 - val_accuracy: 0.6071 Epoch 11/15 63/63 [==============================] - 0s 2ms/step - loss: 0.8424 - accuracy: 0.6407 - val_loss: 0.9869 - val_accuracy: 0.5000 Epoch 12/15 63/63 [==============================] - 0s 2ms/step - loss: 0.8194 - accuracy: 0.6137 - val_loss: 0.7939 - val_accuracy: 0.5536 Epoch 13/15 63/63 [==============================] - 0s 2ms/step - loss: 0.7914 - accuracy: 0.6439 - val_loss: 0.9326 - val_accuracy: 0.5536 Epoch 14/15 63/63 [==============================] - 0s 2ms/step - loss: 0.8101 - accuracy: 0.6264 - val_loss: 0.7857 - val_accuracy: 0.6607 Epoch 15/15 63/63 [==============================] - 0s 2ms/step - loss: 0.7860 - accuracy: 0.6423 - val_loss: 0.8437 - val_accuracy: 0.6518 10/10 [==============================] - 0s 2ms/step - loss: 0.7449 - accuracy: 0.7044 accuracy: 70.4403%
train_eval_model(X_train, y_train, X_test, y_test, 70, 20, 15, 20)
Epoch 1/15 32/32 [==============================] - 1s 7ms/step - loss: 2.2521 - accuracy: 0.4149 - val_loss: 1.1874 - val_accuracy: 0.4911 Epoch 2/15 32/32 [==============================] - 0s 2ms/step - loss: 0.9733 - accuracy: 0.4992 - val_loss: 1.0319 - val_accuracy: 0.5179 Epoch 3/15 32/32 [==============================] - 0s 2ms/step - loss: 0.9897 - accuracy: 0.4849 - val_loss: 0.9562 - val_accuracy: 0.5893 Epoch 4/15 32/32 [==============================] - 0s 2ms/step - loss: 0.8979 - accuracy: 0.5580 - val_loss: 1.3028 - val_accuracy: 0.4286 Epoch 5/15 32/32 [==============================] - 0s 3ms/step - loss: 0.9536 - accuracy: 0.5517 - val_loss: 1.1055 - val_accuracy: 0.4554 Epoch 6/15 32/32 [==============================] - 0s 2ms/step - loss: 0.8848 - accuracy: 0.5501 - val_loss: 0.9072 - val_accuracy: 0.6161 Epoch 7/15 32/32 [==============================] - 0s 2ms/step - loss: 0.8419 - accuracy: 0.6041 - val_loss: 0.9487 - val_accuracy: 0.5446 Epoch 8/15 32/32 [==============================] - 0s 2ms/step - loss: 0.9651 - accuracy: 0.5517 - val_loss: 0.9849 - val_accuracy: 0.5268 Epoch 9/15 32/32 [==============================] - 0s 2ms/step - loss: 0.8533 - accuracy: 0.6041 - val_loss: 0.9385 - val_accuracy: 0.5357 Epoch 10/15 32/32 [==============================] - 0s 2ms/step - loss: 0.9021 - accuracy: 0.5707 - val_loss: 0.9890 - val_accuracy: 0.5536 Epoch 11/15 32/32 [==============================] - 0s 2ms/step - loss: 0.8762 - accuracy: 0.5755 - val_loss: 0.9371 - val_accuracy: 0.5893 Epoch 12/15 32/32 [==============================] - 0s 2ms/step - loss: 0.8078 - accuracy: 0.6566 - val_loss: 0.8728 - val_accuracy: 0.5982 Epoch 13/15 32/32 [==============================] - 0s 2ms/step - loss: 0.8271 - accuracy: 0.6105 - val_loss: 1.0003 - val_accuracy: 0.5804 Epoch 14/15 32/32 [==============================] - 0s 2ms/step - loss: 0.8794 - accuracy: 0.5978 - val_loss: 0.9035 - val_accuracy: 0.6696 Epoch 15/15 32/32 [==============================] - 0s 2ms/step - loss: 0.7825 - accuracy: 0.6375 - val_loss: 0.9728 - val_accuracy: 0.5714 10/10 [==============================] - 0s 1ms/step - loss: 0.8282 - accuracy: 0.5975 accuracy: 59.7484%
train_eval_model(X_train, y_train, X_test, y_test, 70, 20, 50, 10)
Epoch 1/50 63/63 [==============================] - 1s 11ms/step - loss: 2.1733 - accuracy: 0.4881 - val_loss: 1.0057 - val_accuracy: 0.4911 Epoch 2/50 63/63 [==============================] - 0s 2ms/step - loss: 1.1373 - accuracy: 0.4515 - val_loss: 1.4169 - val_accuracy: 0.4464 Epoch 3/50 63/63 [==============================] - 0s 2ms/step - loss: 1.0717 - accuracy: 0.5151 - val_loss: 1.1205 - val_accuracy: 0.5089 Epoch 4/50 63/63 [==============================] - 0s 2ms/step - loss: 0.9602 - accuracy: 0.5437 - val_loss: 1.0729 - val_accuracy: 0.5268 Epoch 5/50 63/63 [==============================] - 0s 2ms/step - loss: 0.9187 - accuracy: 0.5723 - val_loss: 1.1219 - val_accuracy: 0.5357 Epoch 6/50 63/63 [==============================] - 0s 2ms/step - loss: 1.0370 - accuracy: 0.5787 - val_loss: 1.0303 - val_accuracy: 0.4821 Epoch 7/50 63/63 [==============================] - 0s 2ms/step - loss: 0.8515 - accuracy: 0.6105 - val_loss: 0.7796 - val_accuracy: 0.6339 Epoch 8/50 63/63 [==============================] - 0s 2ms/step - loss: 0.8056 - accuracy: 0.6359 - val_loss: 1.0217 - val_accuracy: 0.4286 Epoch 9/50 63/63 [==============================] - 0s 2ms/step - loss: 0.8857 - accuracy: 0.5946 - val_loss: 0.8369 - val_accuracy: 0.5446 Epoch 10/50 63/63 [==============================] - 0s 2ms/step - loss: 0.7470 - accuracy: 0.6534 - val_loss: 0.7234 - val_accuracy: 0.6339 Epoch 11/50 63/63 [==============================] - 0s 2ms/step - loss: 0.7177 - accuracy: 0.6550 - val_loss: 0.6930 - val_accuracy: 0.7054 Epoch 12/50 63/63 [==============================] - 0s 2ms/step - loss: 0.7718 - accuracy: 0.6614 - val_loss: 0.6827 - val_accuracy: 0.6607 Epoch 13/50 63/63 [==============================] - 0s 2ms/step - loss: 0.7125 - accuracy: 0.6709 - val_loss: 0.6563 - val_accuracy: 0.7321 Epoch 14/50 63/63 [==============================] - 0s 2ms/step - loss: 0.6580 - accuracy: 0.6995 - val_loss: 1.0750 - val_accuracy: 0.4732 Epoch 15/50 63/63 [==============================] - 0s 2ms/step - loss: 0.7156 - accuracy: 0.6804 - val_loss: 0.6423 - val_accuracy: 0.6786 Epoch 16/50 63/63 [==============================] - 0s 2ms/step - loss: 0.7135 - accuracy: 0.6836 - val_loss: 0.7776 - val_accuracy: 0.6518 Epoch 17/50 63/63 [==============================] - 0s 2ms/step - loss: 0.7664 - accuracy: 0.6471 - val_loss: 0.7031 - val_accuracy: 0.6161 Epoch 18/50 63/63 [==============================] - 0s 2ms/step - loss: 0.6253 - accuracy: 0.7154 - val_loss: 0.8211 - val_accuracy: 0.6161 Epoch 19/50 63/63 [==============================] - 0s 2ms/step - loss: 0.6740 - accuracy: 0.7059 - val_loss: 0.9292 - val_accuracy: 0.5536 Epoch 20/50 63/63 [==============================] - 0s 2ms/step - loss: 0.6304 - accuracy: 0.7122 - val_loss: 0.6291 - val_accuracy: 0.7411 Epoch 21/50 63/63 [==============================] - 0s 2ms/step - loss: 0.6111 - accuracy: 0.7329 - val_loss: 1.0594 - val_accuracy: 0.4732 Epoch 22/50 63/63 [==============================] - 0s 2ms/step - loss: 0.6608 - accuracy: 0.7059 - val_loss: 0.6953 - val_accuracy: 0.6429 Epoch 23/50 63/63 [==============================] - 0s 2ms/step - loss: 0.6052 - accuracy: 0.7393 - val_loss: 0.8263 - val_accuracy: 0.6071 Epoch 24/50 63/63 [==============================] - 0s 2ms/step - loss: 0.5594 - accuracy: 0.7583 - val_loss: 0.6065 - val_accuracy: 0.7321 Epoch 25/50 63/63 [==============================] - 0s 2ms/step - loss: 0.6282 - accuracy: 0.7059 - val_loss: 0.5127 - val_accuracy: 0.7946 Epoch 26/50 63/63 [==============================] - 0s 2ms/step - loss: 0.5634 - accuracy: 0.7456 - val_loss: 0.6908 - val_accuracy: 0.6875 Epoch 27/50 63/63 [==============================] - 0s 2ms/step - loss: 0.4948 - accuracy: 0.7758 - val_loss: 0.7551 - val_accuracy: 0.7500 Epoch 28/50 63/63 [==============================] - 0s 2ms/step - loss: 0.6791 - accuracy: 0.7027 - val_loss: 0.6721 - val_accuracy: 0.7500 Epoch 29/50 63/63 [==============================] - 0s 2ms/step - loss: 0.4952 - accuracy: 0.7917 - val_loss: 0.4764 - val_accuracy: 0.7500 Epoch 30/50 63/63 [==============================] - 0s 2ms/step - loss: 0.6671 - accuracy: 0.7250 - val_loss: 0.5425 - val_accuracy: 0.8125 Epoch 31/50 63/63 [==============================] - 0s 2ms/step - loss: 0.4858 - accuracy: 0.7886 - val_loss: 0.5404 - val_accuracy: 0.7500 Epoch 32/50 63/63 [==============================] - 0s 2ms/step - loss: 0.4597 - accuracy: 0.8076 - val_loss: 0.5148 - val_accuracy: 0.8036 Epoch 33/50 63/63 [==============================] - 0s 2ms/step - loss: 0.4940 - accuracy: 0.7997 - val_loss: 0.4788 - val_accuracy: 0.7768 Epoch 34/50 63/63 [==============================] - 0s 2ms/step - loss: 0.5209 - accuracy: 0.7631 - val_loss: 0.5457 - val_accuracy: 0.7321 Epoch 35/50 63/63 [==============================] - 0s 2ms/step - loss: 0.5848 - accuracy: 0.7456 - val_loss: 0.4299 - val_accuracy: 0.7946 Epoch 36/50 63/63 [==============================] - 0s 2ms/step - loss: 0.4850 - accuracy: 0.7774 - val_loss: 0.7103 - val_accuracy: 0.6696 Epoch 37/50 63/63 [==============================] - 0s 2ms/step - loss: 0.6031 - accuracy: 0.7329 - val_loss: 0.5480 - val_accuracy: 0.6786 Epoch 38/50 63/63 [==============================] - 0s 2ms/step - loss: 0.5247 - accuracy: 0.7854 - val_loss: 0.4151 - val_accuracy: 0.8393 Epoch 39/50 63/63 [==============================] - 0s 2ms/step - loss: 0.4943 - accuracy: 0.7854 - val_loss: 0.7193 - val_accuracy: 0.7232 Epoch 40/50 63/63 [==============================] - 0s 2ms/step - loss: 0.4043 - accuracy: 0.8156 - val_loss: 0.4433 - val_accuracy: 0.7321 Epoch 41/50 63/63 [==============================] - 0s 2ms/step - loss: 0.3982 - accuracy: 0.8347 - val_loss: 0.4272 - val_accuracy: 0.8304 Epoch 42/50 63/63 [==============================] - 0s 2ms/step - loss: 0.3788 - accuracy: 0.8442 - val_loss: 0.4213 - val_accuracy: 0.8125 Epoch 43/50 63/63 [==============================] - 0s 2ms/step - loss: 0.5400 - accuracy: 0.7663 - val_loss: 0.4300 - val_accuracy: 0.8304 Epoch 44/50 63/63 [==============================] - 0s 2ms/step - loss: 0.5264 - accuracy: 0.7806 - val_loss: 0.4973 - val_accuracy: 0.8125 Epoch 45/50 63/63 [==============================] - 0s 2ms/step - loss: 0.5108 - accuracy: 0.7742 - val_loss: 0.8640 - val_accuracy: 0.6518 Epoch 46/50 63/63 [==============================] - 0s 2ms/step - loss: 0.5019 - accuracy: 0.7933 - val_loss: 0.4425 - val_accuracy: 0.8393 Epoch 47/50 63/63 [==============================] - 0s 2ms/step - loss: 0.4211 - accuracy: 0.8203 - val_loss: 0.3530 - val_accuracy: 0.8839 Epoch 48/50 63/63 [==============================] - 0s 2ms/step - loss: 0.3360 - accuracy: 0.8521 - val_loss: 0.3794 - val_accuracy: 0.8393 Epoch 49/50 63/63 [==============================] - 0s 2ms/step - loss: 0.3938 - accuracy: 0.8378 - val_loss: 0.3881 - val_accuracy: 0.8125 Epoch 50/50 63/63 [==============================] - 0s 2ms/step - loss: 0.4570 - accuracy: 0.8108 - val_loss: 0.4446 - val_accuracy: 0.8036 10/10 [==============================] - 0s 1ms/step - loss: 0.3953 - accuracy: 0.8050 accuracy: 80.5031%
train_eval_model(X_train, y_train, X_test, y_test, 70, 30, 50, 10)
Epoch 1/50 63/63 [==============================] - 1s 4ms/step - loss: 1.5255 - accuracy: 0.4833 - val_loss: 0.9487 - val_accuracy: 0.4643 Epoch 2/50 63/63 [==============================] - 0s 2ms/step - loss: 0.9918 - accuracy: 0.5342 - val_loss: 1.1076 - val_accuracy: 0.4018 Epoch 3/50 63/63 [==============================] - 0s 2ms/step - loss: 0.9721 - accuracy: 0.5167 - val_loss: 1.4354 - val_accuracy: 0.4286 Epoch 4/50 63/63 [==============================] - 0s 2ms/step - loss: 0.9738 - accuracy: 0.5612 - val_loss: 0.9609 - val_accuracy: 0.5089 Epoch 5/50 63/63 [==============================] - 0s 2ms/step - loss: 1.1748 - accuracy: 0.5024 - val_loss: 1.5074 - val_accuracy: 0.4286 Epoch 6/50 63/63 [==============================] - 0s 2ms/step - loss: 0.9197 - accuracy: 0.5707 - val_loss: 0.9434 - val_accuracy: 0.4464 Epoch 7/50 63/63 [==============================] - 0s 2ms/step - loss: 0.8445 - accuracy: 0.5978 - val_loss: 0.9208 - val_accuracy: 0.5268 Epoch 8/50 63/63 [==============================] - 0s 2ms/step - loss: 0.8219 - accuracy: 0.5962 - val_loss: 1.0765 - val_accuracy: 0.4821 Epoch 9/50 63/63 [==============================] - 0s 2ms/step - loss: 0.7632 - accuracy: 0.6391 - val_loss: 1.2100 - val_accuracy: 0.5268 Epoch 10/50 63/63 [==============================] - 0s 2ms/step - loss: 0.8357 - accuracy: 0.6216 - val_loss: 0.8581 - val_accuracy: 0.6964 Epoch 11/50 63/63 [==============================] - 0s 2ms/step - loss: 0.8154 - accuracy: 0.6375 - val_loss: 0.8581 - val_accuracy: 0.5714 Epoch 12/50 63/63 [==============================] - 0s 2ms/step - loss: 0.7586 - accuracy: 0.6407 - val_loss: 0.8728 - val_accuracy: 0.5714 Epoch 13/50 63/63 [==============================] - 0s 2ms/step - loss: 0.8085 - accuracy: 0.6423 - val_loss: 0.9593 - val_accuracy: 0.6161 Epoch 14/50 63/63 [==============================] - 0s 2ms/step - loss: 0.7932 - accuracy: 0.6105 - val_loss: 1.1950 - val_accuracy: 0.4732 Epoch 15/50 63/63 [==============================] - 0s 2ms/step - loss: 0.9688 - accuracy: 0.6200 - val_loss: 0.8666 - val_accuracy: 0.6250 Epoch 16/50 63/63 [==============================] - 0s 2ms/step - loss: 0.8832 - accuracy: 0.6010 - val_loss: 0.6854 - val_accuracy: 0.6429 Epoch 17/50 63/63 [==============================] - 0s 2ms/step - loss: 0.7254 - accuracy: 0.6868 - val_loss: 0.6608 - val_accuracy: 0.6339 Epoch 18/50 63/63 [==============================] - 0s 2ms/step - loss: 0.7126 - accuracy: 0.6534 - val_loss: 0.6865 - val_accuracy: 0.7589 Epoch 19/50 63/63 [==============================] - 0s 2ms/step - loss: 0.6389 - accuracy: 0.6836 - val_loss: 0.6769 - val_accuracy: 0.6786 Epoch 20/50 63/63 [==============================] - 0s 2ms/step - loss: 0.7437 - accuracy: 0.6948 - val_loss: 0.8652 - val_accuracy: 0.6250 Epoch 21/50 63/63 [==============================] - 0s 2ms/step - loss: 0.6828 - accuracy: 0.6741 - val_loss: 0.6399 - val_accuracy: 0.6875 Epoch 22/50 63/63 [==============================] - 0s 2ms/step - loss: 0.6228 - accuracy: 0.7202 - val_loss: 0.6255 - val_accuracy: 0.7143 Epoch 23/50 63/63 [==============================] - 0s 2ms/step - loss: 0.6451 - accuracy: 0.7138 - val_loss: 0.6170 - val_accuracy: 0.7321 Epoch 24/50 63/63 [==============================] - 0s 2ms/step - loss: 0.6931 - accuracy: 0.6884 - val_loss: 0.9736 - val_accuracy: 0.5625 Epoch 25/50 63/63 [==============================] - 0s 2ms/step - loss: 0.7165 - accuracy: 0.6804 - val_loss: 0.8022 - val_accuracy: 0.5982 Epoch 26/50 63/63 [==============================] - 0s 2ms/step - loss: 0.6296 - accuracy: 0.7218 - val_loss: 0.6108 - val_accuracy: 0.7589 Epoch 27/50 63/63 [==============================] - 0s 2ms/step - loss: 0.6003 - accuracy: 0.7281 - val_loss: 0.6273 - val_accuracy: 0.6964 Epoch 28/50 63/63 [==============================] - 0s 2ms/step - loss: 0.6128 - accuracy: 0.7361 - val_loss: 0.5741 - val_accuracy: 0.7143 Epoch 29/50 63/63 [==============================] - 0s 2ms/step - loss: 0.5718 - accuracy: 0.7409 - val_loss: 0.5542 - val_accuracy: 0.7500 Epoch 30/50 63/63 [==============================] - 0s 2ms/step - loss: 0.6038 - accuracy: 0.7472 - val_loss: 0.6641 - val_accuracy: 0.7143 Epoch 31/50 63/63 [==============================] - 0s 2ms/step - loss: 0.9322 - accuracy: 0.6312 - val_loss: 0.7455 - val_accuracy: 0.6250 Epoch 32/50 63/63 [==============================] - 0s 2ms/step - loss: 0.5835 - accuracy: 0.7647 - val_loss: 0.5372 - val_accuracy: 0.7679 Epoch 33/50 63/63 [==============================] - 0s 2ms/step - loss: 0.5335 - accuracy: 0.7647 - val_loss: 0.6049 - val_accuracy: 0.7321 Epoch 34/50 63/63 [==============================] - 0s 2ms/step - loss: 0.5938 - accuracy: 0.7329 - val_loss: 0.5833 - val_accuracy: 0.7857 Epoch 35/50 63/63 [==============================] - 0s 2ms/step - loss: 0.5931 - accuracy: 0.7361 - val_loss: 0.7136 - val_accuracy: 0.5982 Epoch 36/50 63/63 [==============================] - 0s 2ms/step - loss: 0.6114 - accuracy: 0.7393 - val_loss: 0.7923 - val_accuracy: 0.7143 Epoch 37/50 63/63 [==============================] - 0s 2ms/step - loss: 0.6299 - accuracy: 0.7456 - val_loss: 0.7031 - val_accuracy: 0.6250 Epoch 38/50 63/63 [==============================] - 0s 2ms/step - loss: 0.6340 - accuracy: 0.7202 - val_loss: 0.9424 - val_accuracy: 0.5714 Epoch 39/50 63/63 [==============================] - 0s 2ms/step - loss: 0.6644 - accuracy: 0.7043 - val_loss: 0.5474 - val_accuracy: 0.7768 Epoch 40/50 63/63 [==============================] - 0s 2ms/step - loss: 0.6125 - accuracy: 0.7472 - val_loss: 0.5849 - val_accuracy: 0.6875 Epoch 41/50 63/63 [==============================] - 0s 2ms/step - loss: 0.7174 - accuracy: 0.6979 - val_loss: 0.6808 - val_accuracy: 0.6429 Epoch 42/50 63/63 [==============================] - 0s 2ms/step - loss: 0.5745 - accuracy: 0.7234 - val_loss: 0.6556 - val_accuracy: 0.6607 Epoch 43/50 63/63 [==============================] - 0s 2ms/step - loss: 0.5407 - accuracy: 0.7663 - val_loss: 0.5297 - val_accuracy: 0.7679 Epoch 44/50 63/63 [==============================] - 0s 2ms/step - loss: 0.6271 - accuracy: 0.7297 - val_loss: 0.5195 - val_accuracy: 0.7857 Epoch 45/50 63/63 [==============================] - 0s 2ms/step - loss: 0.5284 - accuracy: 0.7568 - val_loss: 0.5185 - val_accuracy: 0.7143 Epoch 46/50 63/63 [==============================] - 0s 2ms/step - loss: 0.4938 - accuracy: 0.7790 - val_loss: 0.7390 - val_accuracy: 0.5714 Epoch 47/50 63/63 [==============================] - 0s 2ms/step - loss: 0.5497 - accuracy: 0.7663 - val_loss: 0.5103 - val_accuracy: 0.7768 Epoch 48/50 63/63 [==============================] - 0s 2ms/step - loss: 0.4905 - accuracy: 0.7790 - val_loss: 0.5439 - val_accuracy: 0.7500 Epoch 49/50 63/63 [==============================] - 0s 2ms/step - loss: 0.4659 - accuracy: 0.7981 - val_loss: 0.5015 - val_accuracy: 0.7321 Epoch 50/50 63/63 [==============================] - 0s 2ms/step - loss: 0.4882 - accuracy: 0.7886 - val_loss: 0.4462 - val_accuracy: 0.8393 10/10 [==============================] - 0s 1ms/step - loss: 0.4030 - accuracy: 0.8208 accuracy: 82.0755%
train_eval_model(X_train, y_train, X_test, y_test, 70, 20, 50, 5)
Epoch 1/50 126/126 [==============================] - 1s 3ms/step - loss: 2.2969 - accuracy: 0.4658 - val_loss: 1.0942 - val_accuracy: 0.3482 Epoch 2/50 126/126 [==============================] - 0s 2ms/step - loss: 1.2946 - accuracy: 0.4897 - val_loss: 1.3835 - val_accuracy: 0.4554 Epoch 3/50 126/126 [==============================] - 0s 2ms/step - loss: 1.0316 - accuracy: 0.5517 - val_loss: 1.1133 - val_accuracy: 0.5446 Epoch 4/50 126/126 [==============================] - 0s 2ms/step - loss: 1.0053 - accuracy: 0.5405 - val_loss: 1.5301 - val_accuracy: 0.3661 Epoch 5/50 126/126 [==============================] - 0s 2ms/step - loss: 1.1976 - accuracy: 0.4992 - val_loss: 1.3718 - val_accuracy: 0.5268 Epoch 6/50 126/126 [==============================] - 0s 2ms/step - loss: 0.9976 - accuracy: 0.6041 - val_loss: 0.8587 - val_accuracy: 0.6071 Epoch 7/50 126/126 [==============================] - 0s 2ms/step - loss: 0.9875 - accuracy: 0.5612 - val_loss: 0.8082 - val_accuracy: 0.5357 Epoch 8/50 126/126 [==============================] - 0s 2ms/step - loss: 0.9743 - accuracy: 0.6073 - val_loss: 1.2549 - val_accuracy: 0.6161 Epoch 9/50 126/126 [==============================] - 0s 2ms/step - loss: 1.0828 - accuracy: 0.5739 - val_loss: 1.2670 - val_accuracy: 0.6071 Epoch 10/50 126/126 [==============================] - 0s 2ms/step - loss: 0.8257 - accuracy: 0.6407 - val_loss: 0.7619 - val_accuracy: 0.6429 Epoch 11/50 126/126 [==============================] - 0s 2ms/step - loss: 0.8343 - accuracy: 0.6518 - val_loss: 0.9719 - val_accuracy: 0.4554 Epoch 12/50 126/126 [==============================] - 0s 2ms/step - loss: 0.7716 - accuracy: 0.6566 - val_loss: 0.8714 - val_accuracy: 0.5714 Epoch 13/50 126/126 [==============================] - 0s 2ms/step - loss: 0.8616 - accuracy: 0.6439 - val_loss: 0.9842 - val_accuracy: 0.5089 Epoch 14/50 126/126 [==============================] - 0s 2ms/step - loss: 0.8348 - accuracy: 0.6566 - val_loss: 0.9364 - val_accuracy: 0.5804 Epoch 15/50 126/126 [==============================] - 0s 2ms/step - loss: 0.9033 - accuracy: 0.6359 - val_loss: 1.0993 - val_accuracy: 0.6071 Epoch 16/50 126/126 [==============================] - 0s 2ms/step - loss: 0.8557 - accuracy: 0.6757 - val_loss: 0.7676 - val_accuracy: 0.7589 Epoch 17/50 126/126 [==============================] - 0s 1ms/step - loss: 0.9861 - accuracy: 0.6343 - val_loss: 1.1690 - val_accuracy: 0.5536 Epoch 18/50 126/126 [==============================] - 0s 2ms/step - loss: 0.7353 - accuracy: 0.6661 - val_loss: 0.8854 - val_accuracy: 0.4821 Epoch 19/50 126/126 [==============================] - 0s 2ms/step - loss: 0.7780 - accuracy: 0.6693 - val_loss: 0.7520 - val_accuracy: 0.6786 Epoch 20/50 126/126 [==============================] - 0s 2ms/step - loss: 0.7692 - accuracy: 0.6550 - val_loss: 1.5458 - val_accuracy: 0.5000 Epoch 21/50 126/126 [==============================] - 0s 2ms/step - loss: 0.7443 - accuracy: 0.6836 - val_loss: 0.9122 - val_accuracy: 0.5625 Epoch 22/50 126/126 [==============================] - 0s 2ms/step - loss: 0.7676 - accuracy: 0.6693 - val_loss: 0.7744 - val_accuracy: 0.6786 Epoch 23/50 126/126 [==============================] - 0s 2ms/step - loss: 0.9857 - accuracy: 0.6280 - val_loss: 0.6674 - val_accuracy: 0.7589 Epoch 24/50 126/126 [==============================] - 0s 2ms/step - loss: 0.6180 - accuracy: 0.7154 - val_loss: 0.6384 - val_accuracy: 0.6875 Epoch 25/50 126/126 [==============================] - 0s 2ms/step - loss: 0.6265 - accuracy: 0.7345 - val_loss: 1.1862 - val_accuracy: 0.5536 Epoch 26/50 126/126 [==============================] - 0s 2ms/step - loss: 0.7139 - accuracy: 0.7011 - val_loss: 0.7768 - val_accuracy: 0.6339 Epoch 27/50 126/126 [==============================] - 0s 2ms/step - loss: 0.6417 - accuracy: 0.7186 - val_loss: 0.8193 - val_accuracy: 0.6964 Epoch 28/50 126/126 [==============================] - 0s 2ms/step - loss: 0.6751 - accuracy: 0.7186 - val_loss: 1.0391 - val_accuracy: 0.6071 Epoch 29/50 126/126 [==============================] - 0s 2ms/step - loss: 0.6137 - accuracy: 0.7122 - val_loss: 0.5784 - val_accuracy: 0.7589 Epoch 30/50 126/126 [==============================] - 0s 2ms/step - loss: 0.5978 - accuracy: 0.7536 - val_loss: 0.6572 - val_accuracy: 0.6429 Epoch 31/50 126/126 [==============================] - 0s 2ms/step - loss: 0.7032 - accuracy: 0.6852 - val_loss: 0.7599 - val_accuracy: 0.6518 Epoch 32/50 126/126 [==============================] - 0s 2ms/step - loss: 0.6265 - accuracy: 0.7409 - val_loss: 0.6630 - val_accuracy: 0.6429 Epoch 33/50 126/126 [==============================] - 0s 2ms/step - loss: 0.5831 - accuracy: 0.7234 - val_loss: 0.7104 - val_accuracy: 0.7500 Epoch 34/50 126/126 [==============================] - 0s 2ms/step - loss: 0.5484 - accuracy: 0.7520 - val_loss: 0.9040 - val_accuracy: 0.6875 Epoch 35/50 126/126 [==============================] - 0s 2ms/step - loss: 0.7247 - accuracy: 0.7027 - val_loss: 0.8677 - val_accuracy: 0.6607 Epoch 36/50 126/126 [==============================] - 0s 2ms/step - loss: 0.6097 - accuracy: 0.7568 - val_loss: 0.5553 - val_accuracy: 0.7946 Epoch 37/50 126/126 [==============================] - 0s 2ms/step - loss: 0.6167 - accuracy: 0.7504 - val_loss: 0.6844 - val_accuracy: 0.6518 Epoch 38/50 126/126 [==============================] - 0s 2ms/step - loss: 0.5720 - accuracy: 0.7631 - val_loss: 0.9864 - val_accuracy: 0.6429 Epoch 39/50 126/126 [==============================] - 0s 2ms/step - loss: 0.5315 - accuracy: 0.7838 - val_loss: 0.7744 - val_accuracy: 0.7054 Epoch 40/50 126/126 [==============================] - 0s 2ms/step - loss: 0.5787 - accuracy: 0.7583 - val_loss: 1.2071 - val_accuracy: 0.6696 Epoch 41/50 126/126 [==============================] - 0s 2ms/step - loss: 0.5392 - accuracy: 0.7727 - val_loss: 0.8501 - val_accuracy: 0.6696 Epoch 42/50 126/126 [==============================] - 0s 2ms/step - loss: 0.6014 - accuracy: 0.7456 - val_loss: 0.8210 - val_accuracy: 0.6250 Epoch 43/50 126/126 [==============================] - 0s 2ms/step - loss: 0.5601 - accuracy: 0.7822 - val_loss: 0.8997 - val_accuracy: 0.6518 Epoch 44/50 126/126 [==============================] - 0s 2ms/step - loss: 0.6416 - accuracy: 0.7409 - val_loss: 0.5710 - val_accuracy: 0.8214 Epoch 45/50 126/126 [==============================] - 0s 2ms/step - loss: 0.5283 - accuracy: 0.7663 - val_loss: 0.5559 - val_accuracy: 0.7857 Epoch 46/50 126/126 [==============================] - 0s 2ms/step - loss: 0.4936 - accuracy: 0.8045 - val_loss: 0.5160 - val_accuracy: 0.7946 Epoch 47/50 126/126 [==============================] - 0s 2ms/step - loss: 0.4995 - accuracy: 0.7901 - val_loss: 0.4545 - val_accuracy: 0.7411 Epoch 48/50 126/126 [==============================] - 0s 2ms/step - loss: 0.5199 - accuracy: 0.7631 - val_loss: 0.5730 - val_accuracy: 0.7143 Epoch 49/50 126/126 [==============================] - 0s 2ms/step - loss: 0.4907 - accuracy: 0.7997 - val_loss: 0.4100 - val_accuracy: 0.7946 Epoch 50/50 126/126 [==============================] - 0s 2ms/step - loss: 0.5715 - accuracy: 0.7870 - val_loss: 0.5409 - val_accuracy: 0.7500 10/10 [==============================] - 0s 1ms/step - loss: 0.4496 - accuracy: 0.7956 accuracy: 79.5597%
train_eval_model(X_train, y_train, X_test, y_test, 50, 20, 50, 10)
Epoch 1/50 63/63 [==============================] - 1s 4ms/step - loss: 6.9141 - accuracy: 0.3545 - val_loss: 1.0747 - val_accuracy: 0.4732 Epoch 2/50 63/63 [==============================] - 0s 2ms/step - loss: 1.0428 - accuracy: 0.4626 - val_loss: 0.9854 - val_accuracy: 0.4911 Epoch 3/50 63/63 [==============================] - 0s 2ms/step - loss: 1.0224 - accuracy: 0.4754 - val_loss: 1.0577 - val_accuracy: 0.5089 Epoch 4/50 63/63 [==============================] - 0s 2ms/step - loss: 1.0067 - accuracy: 0.5151 - val_loss: 1.0302 - val_accuracy: 0.4732 Epoch 5/50 63/63 [==============================] - 0s 2ms/step - loss: 0.9409 - accuracy: 0.5421 - val_loss: 0.9339 - val_accuracy: 0.5536 Epoch 6/50 63/63 [==============================] - 0s 2ms/step - loss: 0.9411 - accuracy: 0.5596 - val_loss: 1.1926 - val_accuracy: 0.4643 Epoch 7/50 63/63 [==============================] - 0s 2ms/step - loss: 0.9366 - accuracy: 0.5644 - val_loss: 0.9623 - val_accuracy: 0.6339 Epoch 8/50 63/63 [==============================] - 0s 2ms/step - loss: 0.9401 - accuracy: 0.5119 - val_loss: 1.1667 - val_accuracy: 0.4643 Epoch 9/50 63/63 [==============================] - 0s 2ms/step - loss: 0.8929 - accuracy: 0.5692 - val_loss: 1.0977 - val_accuracy: 0.4821 Epoch 10/50 63/63 [==============================] - 0s 2ms/step - loss: 0.8649 - accuracy: 0.5851 - val_loss: 0.9227 - val_accuracy: 0.5446 Epoch 11/50 63/63 [==============================] - 0s 2ms/step - loss: 0.8892 - accuracy: 0.5803 - val_loss: 0.8851 - val_accuracy: 0.5625 Epoch 12/50 63/63 [==============================] - 0s 2ms/step - loss: 0.8291 - accuracy: 0.6025 - val_loss: 0.9172 - val_accuracy: 0.6607 Epoch 13/50 63/63 [==============================] - 0s 2ms/step - loss: 0.8467 - accuracy: 0.6169 - val_loss: 0.9739 - val_accuracy: 0.5179 Epoch 14/50 63/63 [==============================] - 0s 2ms/step - loss: 0.8958 - accuracy: 0.5819 - val_loss: 0.9321 - val_accuracy: 0.5268 Epoch 15/50 63/63 [==============================] - 0s 2ms/step - loss: 0.8132 - accuracy: 0.6486 - val_loss: 0.9210 - val_accuracy: 0.7054 Epoch 16/50 63/63 [==============================] - 0s 2ms/step - loss: 0.8182 - accuracy: 0.6248 - val_loss: 0.8460 - val_accuracy: 0.6607 Epoch 17/50 63/63 [==============================] - 0s 2ms/step - loss: 0.7993 - accuracy: 0.6312 - val_loss: 0.8292 - val_accuracy: 0.5982 Epoch 18/50 63/63 [==============================] - 0s 2ms/step - loss: 0.7896 - accuracy: 0.6693 - val_loss: 0.8175 - val_accuracy: 0.5714 Epoch 19/50 63/63 [==============================] - 0s 2ms/step - loss: 0.7814 - accuracy: 0.6645 - val_loss: 0.8240 - val_accuracy: 0.6250 Epoch 20/50 63/63 [==============================] - 0s 2ms/step - loss: 0.7454 - accuracy: 0.6773 - val_loss: 0.8625 - val_accuracy: 0.6696 Epoch 21/50 63/63 [==============================] - 0s 2ms/step - loss: 0.7623 - accuracy: 0.6645 - val_loss: 0.8049 - val_accuracy: 0.6161 Epoch 22/50 63/63 [==============================] - 0s 2ms/step - loss: 0.7258 - accuracy: 0.6836 - val_loss: 0.7980 - val_accuracy: 0.6161 Epoch 23/50 63/63 [==============================] - 0s 2ms/step - loss: 0.7693 - accuracy: 0.6582 - val_loss: 0.8935 - val_accuracy: 0.7054 Epoch 24/50 63/63 [==============================] - 0s 2ms/step - loss: 0.7948 - accuracy: 0.6709 - val_loss: 0.8584 - val_accuracy: 0.7500 Epoch 25/50 63/63 [==============================] - 0s 2ms/step - loss: 0.7397 - accuracy: 0.6725 - val_loss: 0.7877 - val_accuracy: 0.5893 Epoch 26/50 63/63 [==============================] - 0s 2ms/step - loss: 0.7131 - accuracy: 0.6868 - val_loss: 0.8571 - val_accuracy: 0.5714 Epoch 27/50 63/63 [==============================] - 0s 2ms/step - loss: 0.7725 - accuracy: 0.6677 - val_loss: 0.7583 - val_accuracy: 0.6250 Epoch 28/50 63/63 [==============================] - 0s 2ms/step - loss: 0.6972 - accuracy: 0.6948 - val_loss: 0.8489 - val_accuracy: 0.5804 Epoch 29/50 63/63 [==============================] - 0s 2ms/step - loss: 0.6845 - accuracy: 0.6979 - val_loss: 0.7653 - val_accuracy: 0.6964 Epoch 30/50 63/63 [==============================] - 0s 2ms/step - loss: 0.6801 - accuracy: 0.6804 - val_loss: 0.8307 - val_accuracy: 0.5714 Epoch 31/50 63/63 [==============================] - 0s 2ms/step - loss: 0.6581 - accuracy: 0.6979 - val_loss: 0.7604 - val_accuracy: 0.6786 Epoch 32/50 63/63 [==============================] - 0s 2ms/step - loss: 0.6988 - accuracy: 0.6773 - val_loss: 0.7699 - val_accuracy: 0.5893 Epoch 33/50 63/63 [==============================] - 0s 2ms/step - loss: 0.6617 - accuracy: 0.7011 - val_loss: 0.7974 - val_accuracy: 0.7232 Epoch 34/50 63/63 [==============================] - 0s 2ms/step - loss: 0.7195 - accuracy: 0.6789 - val_loss: 0.7458 - val_accuracy: 0.7589 Epoch 35/50 63/63 [==============================] - 0s 2ms/step - loss: 0.6325 - accuracy: 0.7377 - val_loss: 0.7642 - val_accuracy: 0.6518 Epoch 36/50 63/63 [==============================] - 0s 2ms/step - loss: 0.6250 - accuracy: 0.7281 - val_loss: 0.6723 - val_accuracy: 0.6607 Epoch 37/50 63/63 [==============================] - 0s 2ms/step - loss: 0.6287 - accuracy: 0.7234 - val_loss: 0.6813 - val_accuracy: 0.6607 Epoch 38/50 63/63 [==============================] - 0s 2ms/step - loss: 0.7276 - accuracy: 0.6693 - val_loss: 0.7567 - val_accuracy: 0.7500 Epoch 39/50 63/63 [==============================] - 0s 2ms/step - loss: 0.6268 - accuracy: 0.7250 - val_loss: 0.7085 - val_accuracy: 0.7143 Epoch 40/50 63/63 [==============================] - 0s 2ms/step - loss: 0.5967 - accuracy: 0.7345 - val_loss: 0.6490 - val_accuracy: 0.7500 Epoch 41/50 63/63 [==============================] - 0s 2ms/step - loss: 0.5830 - accuracy: 0.7615 - val_loss: 0.7144 - val_accuracy: 0.7143 Epoch 42/50 63/63 [==============================] - 0s 2ms/step - loss: 0.6200 - accuracy: 0.7393 - val_loss: 0.8224 - val_accuracy: 0.5982 Epoch 43/50 63/63 [==============================] - 0s 2ms/step - loss: 0.6009 - accuracy: 0.7409 - val_loss: 0.6548 - val_accuracy: 0.7143 Epoch 44/50 63/63 [==============================] - 0s 2ms/step - loss: 0.5935 - accuracy: 0.7409 - val_loss: 0.6259 - val_accuracy: 0.7679 Epoch 45/50 63/63 [==============================] - 0s 2ms/step - loss: 0.6194 - accuracy: 0.7202 - val_loss: 0.6364 - val_accuracy: 0.7500 Epoch 46/50 63/63 [==============================] - 0s 2ms/step - loss: 0.6487 - accuracy: 0.6836 - val_loss: 0.6992 - val_accuracy: 0.6339 Epoch 47/50 63/63 [==============================] - 0s 2ms/step - loss: 0.5871 - accuracy: 0.7440 - val_loss: 0.6494 - val_accuracy: 0.7500 Epoch 48/50 63/63 [==============================] - 0s 2ms/step - loss: 0.6030 - accuracy: 0.7361 - val_loss: 0.6092 - val_accuracy: 0.7500 Epoch 49/50 63/63 [==============================] - 0s 2ms/step - loss: 0.6058 - accuracy: 0.7266 - val_loss: 0.7162 - val_accuracy: 0.7232 Epoch 50/50 63/63 [==============================] - 0s 2ms/step - loss: 0.6546 - accuracy: 0.7075 - val_loss: 0.7792 - val_accuracy: 0.6964 10/10 [==============================] - 0s 1ms/step - loss: 0.6935 - accuracy: 0.6981 accuracy: 69.8113%
train_eval_model(X_train, y_train, X_test, y_test, 70, 30, 50, 10)
Epoch 1/50 63/63 [==============================] - 1s 4ms/step - loss: 1.2850 - accuracy: 0.4785 - val_loss: 1.0657 - val_accuracy: 0.5357 Epoch 2/50 63/63 [==============================] - 0s 2ms/step - loss: 1.0277 - accuracy: 0.5278 - val_loss: 0.9072 - val_accuracy: 0.5536 Epoch 3/50 63/63 [==============================] - 0s 2ms/step - loss: 1.1075 - accuracy: 0.5580 - val_loss: 1.1300 - val_accuracy: 0.5714 Epoch 4/50 63/63 [==============================] - 0s 2ms/step - loss: 0.9652 - accuracy: 0.5676 - val_loss: 0.8283 - val_accuracy: 0.6161 Epoch 5/50 63/63 [==============================] - 0s 2ms/step - loss: 0.9778 - accuracy: 0.6264 - val_loss: 0.7938 - val_accuracy: 0.6250 Epoch 6/50 63/63 [==============================] - 0s 2ms/step - loss: 0.7436 - accuracy: 0.6534 - val_loss: 0.7402 - val_accuracy: 0.6875 Epoch 7/50 63/63 [==============================] - 0s 2ms/step - loss: 0.9680 - accuracy: 0.5739 - val_loss: 2.6478 - val_accuracy: 0.5982 Epoch 8/50 63/63 [==============================] - 0s 2ms/step - loss: 1.0699 - accuracy: 0.6025 - val_loss: 1.0171 - val_accuracy: 0.5536 Epoch 9/50 63/63 [==============================] - 0s 2ms/step - loss: 0.7589 - accuracy: 0.6598 - val_loss: 0.7226 - val_accuracy: 0.6696 Epoch 10/50 63/63 [==============================] - 0s 2ms/step - loss: 0.7224 - accuracy: 0.6550 - val_loss: 0.6754 - val_accuracy: 0.7500 Epoch 11/50 63/63 [==============================] - 0s 2ms/step - loss: 0.7915 - accuracy: 0.6661 - val_loss: 0.6432 - val_accuracy: 0.7232 Epoch 12/50 63/63 [==============================] - 0s 2ms/step - loss: 0.7140 - accuracy: 0.6916 - val_loss: 0.7559 - val_accuracy: 0.6339 Epoch 13/50 63/63 [==============================] - 0s 2ms/step - loss: 0.7792 - accuracy: 0.6741 - val_loss: 0.7355 - val_accuracy: 0.7321 Epoch 14/50 63/63 [==============================] - 0s 2ms/step - loss: 0.6354 - accuracy: 0.7250 - val_loss: 0.6398 - val_accuracy: 0.6786 Epoch 15/50 63/63 [==============================] - 0s 2ms/step - loss: 0.6683 - accuracy: 0.7011 - val_loss: 0.8241 - val_accuracy: 0.5804 Epoch 16/50 63/63 [==============================] - 0s 2ms/step - loss: 0.9224 - accuracy: 0.6328 - val_loss: 0.6183 - val_accuracy: 0.7589 Epoch 17/50 63/63 [==============================] - 0s 2ms/step - loss: 0.7452 - accuracy: 0.6852 - val_loss: 0.8730 - val_accuracy: 0.5982 Epoch 18/50 63/63 [==============================] - 0s 2ms/step - loss: 0.6585 - accuracy: 0.6773 - val_loss: 0.5799 - val_accuracy: 0.6161 Epoch 19/50 63/63 [==============================] - 0s 2ms/step - loss: 0.6210 - accuracy: 0.7122 - val_loss: 0.5767 - val_accuracy: 0.7589 Epoch 20/50 63/63 [==============================] - 0s 2ms/step - loss: 0.6530 - accuracy: 0.7186 - val_loss: 0.5541 - val_accuracy: 0.7857 Epoch 21/50 63/63 [==============================] - 0s 2ms/step - loss: 0.6533 - accuracy: 0.7043 - val_loss: 0.5661 - val_accuracy: 0.7143 Epoch 22/50 63/63 [==============================] - 0s 2ms/step - loss: 0.6405 - accuracy: 0.7107 - val_loss: 0.6083 - val_accuracy: 0.6161 Epoch 23/50 63/63 [==============================] - 0s 2ms/step - loss: 0.6114 - accuracy: 0.7297 - val_loss: 0.5235 - val_accuracy: 0.7768 Epoch 24/50 63/63 [==============================] - 0s 2ms/step - loss: 0.6343 - accuracy: 0.7027 - val_loss: 0.5130 - val_accuracy: 0.7768 Epoch 25/50 63/63 [==============================] - 0s 2ms/step - loss: 0.6415 - accuracy: 0.6852 - val_loss: 0.7315 - val_accuracy: 0.6786 Epoch 26/50 63/63 [==============================] - 0s 2ms/step - loss: 0.5825 - accuracy: 0.7281 - val_loss: 0.6207 - val_accuracy: 0.6607 Epoch 27/50 63/63 [==============================] - 0s 2ms/step - loss: 0.6347 - accuracy: 0.7234 - val_loss: 0.6045 - val_accuracy: 0.6696 Epoch 28/50 63/63 [==============================] - 0s 2ms/step - loss: 0.7236 - accuracy: 0.7122 - val_loss: 0.6759 - val_accuracy: 0.7143 Epoch 29/50 63/63 [==============================] - 0s 2ms/step - loss: 0.6271 - accuracy: 0.7122 - val_loss: 0.8235 - val_accuracy: 0.5804 Epoch 30/50 63/63 [==============================] - 0s 2ms/step - loss: 0.5849 - accuracy: 0.7250 - val_loss: 0.5284 - val_accuracy: 0.7768 Epoch 31/50 63/63 [==============================] - 0s 2ms/step - loss: 0.5001 - accuracy: 0.7758 - val_loss: 0.5528 - val_accuracy: 0.7500 Epoch 32/50 63/63 [==============================] - 0s 2ms/step - loss: 0.5198 - accuracy: 0.7520 - val_loss: 0.7127 - val_accuracy: 0.6875 Epoch 33/50 63/63 [==============================] - 0s 2ms/step - loss: 0.5207 - accuracy: 0.7615 - val_loss: 0.4854 - val_accuracy: 0.7679 Epoch 34/50 63/63 [==============================] - 0s 2ms/step - loss: 0.5396 - accuracy: 0.7552 - val_loss: 0.4613 - val_accuracy: 0.7857 Epoch 35/50 63/63 [==============================] - 0s 2ms/step - loss: 0.7100 - accuracy: 0.7250 - val_loss: 0.6244 - val_accuracy: 0.7232 Epoch 36/50 63/63 [==============================] - 0s 2ms/step - loss: 0.4870 - accuracy: 0.7806 - val_loss: 0.4958 - val_accuracy: 0.6786 Epoch 37/50 63/63 [==============================] - 0s 2ms/step - loss: 0.4635 - accuracy: 0.7806 - val_loss: 0.5129 - val_accuracy: 0.6964 Epoch 38/50 63/63 [==============================] - 0s 2ms/step - loss: 0.4842 - accuracy: 0.7933 - val_loss: 0.4889 - val_accuracy: 0.7500 Epoch 39/50 63/63 [==============================] - 0s 2ms/step - loss: 0.5184 - accuracy: 0.7679 - val_loss: 0.5545 - val_accuracy: 0.6964 Epoch 40/50 63/63 [==============================] - 0s 2ms/step - loss: 0.4808 - accuracy: 0.7727 - val_loss: 0.4919 - val_accuracy: 0.7500 Epoch 41/50 63/63 [==============================] - 0s 2ms/step - loss: 0.5093 - accuracy: 0.7695 - val_loss: 0.6251 - val_accuracy: 0.7054 Epoch 42/50 63/63 [==============================] - 0s 2ms/step - loss: 0.5745 - accuracy: 0.7504 - val_loss: 0.9578 - val_accuracy: 0.5982 Epoch 43/50 63/63 [==============================] - 0s 2ms/step - loss: 0.6014 - accuracy: 0.7599 - val_loss: 0.8229 - val_accuracy: 0.7232 Epoch 44/50 63/63 [==============================] - 0s 2ms/step - loss: 0.4658 - accuracy: 0.8013 - val_loss: 0.6169 - val_accuracy: 0.6875 Epoch 45/50 63/63 [==============================] - 0s 2ms/step - loss: 0.5121 - accuracy: 0.7727 - val_loss: 0.4469 - val_accuracy: 0.7768 Epoch 46/50 63/63 [==============================] - 0s 2ms/step - loss: 0.4361 - accuracy: 0.7933 - val_loss: 0.4424 - val_accuracy: 0.8304 Epoch 47/50 63/63 [==============================] - 0s 2ms/step - loss: 0.4278 - accuracy: 0.8108 - val_loss: 0.5071 - val_accuracy: 0.7232 Epoch 48/50 63/63 [==============================] - 0s 2ms/step - loss: 0.6029 - accuracy: 0.7568 - val_loss: 0.6997 - val_accuracy: 0.7143 Epoch 49/50 63/63 [==============================] - 0s 2ms/step - loss: 0.4248 - accuracy: 0.8060 - val_loss: 0.5877 - val_accuracy: 0.7768 Epoch 50/50 63/63 [==============================] - 0s 2ms/step - loss: 0.4842 - accuracy: 0.7774 - val_loss: 0.5205 - val_accuracy: 0.7768 10/10 [==============================] - 0s 1ms/step - loss: 0.4369 - accuracy: 0.8553 accuracy: 85.5346%
train_eval_model(X_train, y_train, X_test, y_test, 60, 30, 50, 15)
Epoch 1/50 42/42 [==============================] - 1s 6ms/step - loss: 7.8885 - accuracy: 0.3323 - val_loss: 2.1381 - val_accuracy: 0.4018 Epoch 2/50 42/42 [==============================] - 0s 2ms/step - loss: 1.2099 - accuracy: 0.4436 - val_loss: 1.0459 - val_accuracy: 0.4018 Epoch 3/50 42/42 [==============================] - 0s 2ms/step - loss: 0.9792 - accuracy: 0.5278 - val_loss: 1.0544 - val_accuracy: 0.4018 Epoch 4/50 42/42 [==============================] - 0s 2ms/step - loss: 0.9715 - accuracy: 0.5246 - val_loss: 0.9267 - val_accuracy: 0.5089 Epoch 5/50 42/42 [==============================] - 0s 2ms/step - loss: 0.9324 - accuracy: 0.5469 - val_loss: 0.9090 - val_accuracy: 0.6518 Epoch 6/50 42/42 [==============================] - 0s 2ms/step - loss: 0.8760 - accuracy: 0.5819 - val_loss: 0.9547 - val_accuracy: 0.4286 Epoch 7/50 42/42 [==============================] - 0s 2ms/step - loss: 0.9140 - accuracy: 0.5548 - val_loss: 0.9405 - val_accuracy: 0.6250 Epoch 8/50 42/42 [==============================] - 0s 2ms/step - loss: 0.9416 - accuracy: 0.5580 - val_loss: 0.8651 - val_accuracy: 0.6696 Epoch 9/50 42/42 [==============================] - 0s 2ms/step - loss: 1.0429 - accuracy: 0.5199 - val_loss: 1.6204 - val_accuracy: 0.4286 Epoch 10/50 42/42 [==============================] - 0s 2ms/step - loss: 1.0356 - accuracy: 0.5453 - val_loss: 0.9599 - val_accuracy: 0.5089 Epoch 11/50 42/42 [==============================] - 0s 2ms/step - loss: 0.9659 - accuracy: 0.5660 - val_loss: 0.8787 - val_accuracy: 0.5625 Epoch 12/50 42/42 [==============================] - 0s 2ms/step - loss: 0.7957 - accuracy: 0.6502 - val_loss: 0.8323 - val_accuracy: 0.7411 Epoch 13/50 42/42 [==============================] - 0s 2ms/step - loss: 0.8448 - accuracy: 0.6121 - val_loss: 0.8539 - val_accuracy: 0.5804 Epoch 14/50 42/42 [==============================] - 0s 2ms/step - loss: 0.7919 - accuracy: 0.6423 - val_loss: 0.8117 - val_accuracy: 0.5625 Epoch 15/50 42/42 [==============================] - 0s 2ms/step - loss: 0.8425 - accuracy: 0.6089 - val_loss: 1.0041 - val_accuracy: 0.5804 Epoch 16/50 42/42 [==============================] - 0s 2ms/step - loss: 0.8978 - accuracy: 0.5628 - val_loss: 0.8510 - val_accuracy: 0.6786 Epoch 17/50 42/42 [==============================] - 0s 2ms/step - loss: 0.7469 - accuracy: 0.6614 - val_loss: 0.7746 - val_accuracy: 0.7589 Epoch 18/50 42/42 [==============================] - 0s 2ms/step - loss: 0.8309 - accuracy: 0.6137 - val_loss: 0.7890 - val_accuracy: 0.5982 Epoch 19/50 42/42 [==============================] - 0s 2ms/step - loss: 0.7421 - accuracy: 0.6852 - val_loss: 0.7620 - val_accuracy: 0.7768 Epoch 20/50 42/42 [==============================] - 0s 2ms/step - loss: 0.8277 - accuracy: 0.6343 - val_loss: 1.1193 - val_accuracy: 0.5804 Epoch 21/50 42/42 [==============================] - 0s 2ms/step - loss: 0.6891 - accuracy: 0.7091 - val_loss: 0.7698 - val_accuracy: 0.6250 Epoch 22/50 42/42 [==============================] - 0s 2ms/step - loss: 0.7214 - accuracy: 0.6804 - val_loss: 0.9924 - val_accuracy: 0.5357 Epoch 23/50 42/42 [==============================] - 0s 2ms/step - loss: 0.7227 - accuracy: 0.6868 - val_loss: 0.7633 - val_accuracy: 0.6071 Epoch 24/50 42/42 [==============================] - 0s 2ms/step - loss: 0.6642 - accuracy: 0.7107 - val_loss: 0.7352 - val_accuracy: 0.6696 Epoch 25/50 42/42 [==============================] - 0s 2ms/step - loss: 0.7192 - accuracy: 0.6582 - val_loss: 0.7395 - val_accuracy: 0.6339 Epoch 26/50 42/42 [==============================] - 0s 2ms/step - loss: 0.6899 - accuracy: 0.6979 - val_loss: 0.8213 - val_accuracy: 0.6339 Epoch 27/50 42/42 [==============================] - 0s 2ms/step - loss: 0.6750 - accuracy: 0.6932 - val_loss: 0.6917 - val_accuracy: 0.6161 Epoch 28/50 42/42 [==============================] - 0s 2ms/step - loss: 0.6120 - accuracy: 0.7456 - val_loss: 0.6846 - val_accuracy: 0.8036 Epoch 29/50 42/42 [==============================] - 0s 2ms/step - loss: 0.5950 - accuracy: 0.7917 - val_loss: 0.6754 - val_accuracy: 0.7768 Epoch 30/50 42/42 [==============================] - 0s 2ms/step - loss: 0.6948 - accuracy: 0.6916 - val_loss: 0.9082 - val_accuracy: 0.6429 Epoch 31/50 42/42 [==============================] - 0s 2ms/step - loss: 0.7332 - accuracy: 0.6709 - val_loss: 0.7486 - val_accuracy: 0.6339 Epoch 32/50 42/42 [==============================] - 0s 3ms/step - loss: 0.7167 - accuracy: 0.6789 - val_loss: 1.0037 - val_accuracy: 0.5179 Epoch 33/50 42/42 [==============================] - 0s 2ms/step - loss: 0.5918 - accuracy: 0.7631 - val_loss: 0.6520 - val_accuracy: 0.6429 Epoch 34/50 42/42 [==============================] - 0s 2ms/step - loss: 0.5657 - accuracy: 0.7663 - val_loss: 0.6412 - val_accuracy: 0.7500 Epoch 35/50 42/42 [==============================] - 0s 2ms/step - loss: 0.6055 - accuracy: 0.7313 - val_loss: 0.6909 - val_accuracy: 0.6875 Epoch 36/50 42/42 [==============================] - 0s 2ms/step - loss: 0.7574 - accuracy: 0.6820 - val_loss: 0.8222 - val_accuracy: 0.7054 Epoch 37/50 42/42 [==============================] - 0s 2ms/step - loss: 0.6898 - accuracy: 0.7138 - val_loss: 0.7027 - val_accuracy: 0.6071 Epoch 38/50 42/42 [==============================] - 0s 2ms/step - loss: 0.5568 - accuracy: 0.7615 - val_loss: 0.6485 - val_accuracy: 0.6786 Epoch 39/50 42/42 [==============================] - 0s 2ms/step - loss: 0.6895 - accuracy: 0.7250 - val_loss: 0.6597 - val_accuracy: 0.6518 Epoch 40/50 42/42 [==============================] - 0s 2ms/step - loss: 0.5271 - accuracy: 0.7949 - val_loss: 0.6562 - val_accuracy: 0.6518 Epoch 41/50 42/42 [==============================] - 0s 2ms/step - loss: 0.6379 - accuracy: 0.7297 - val_loss: 0.5836 - val_accuracy: 0.7857 Epoch 42/50 42/42 [==============================] - 0s 2ms/step - loss: 0.5768 - accuracy: 0.7536 - val_loss: 0.5847 - val_accuracy: 0.8036 Epoch 43/50 42/42 [==============================] - 0s 2ms/step - loss: 0.5439 - accuracy: 0.7568 - val_loss: 0.5535 - val_accuracy: 0.7768 Epoch 44/50 42/42 [==============================] - 0s 2ms/step - loss: 0.5176 - accuracy: 0.7806 - val_loss: 0.8357 - val_accuracy: 0.7321 Epoch 45/50 42/42 [==============================] - 0s 2ms/step - loss: 0.5289 - accuracy: 0.7599 - val_loss: 0.5671 - val_accuracy: 0.7768 Epoch 46/50 42/42 [==============================] - 0s 3ms/step - loss: 0.5255 - accuracy: 0.7774 - val_loss: 0.6534 - val_accuracy: 0.7054 Epoch 47/50 42/42 [==============================] - 0s 2ms/step - loss: 0.5702 - accuracy: 0.7679 - val_loss: 0.5472 - val_accuracy: 0.8125 Epoch 48/50 42/42 [==============================] - 0s 2ms/step - loss: 0.5781 - accuracy: 0.7409 - val_loss: 0.7194 - val_accuracy: 0.5804 Epoch 49/50 42/42 [==============================] - 0s 2ms/step - loss: 0.5438 - accuracy: 0.7663 - val_loss: 0.6366 - val_accuracy: 0.6786 Epoch 50/50 42/42 [==============================] - 0s 2ms/step - loss: 0.5338 - accuracy: 0.7806 - val_loss: 0.6490 - val_accuracy: 0.7946 10/10 [==============================] - 0s 1ms/step - loss: 0.5310 - accuracy: 0.8145 accuracy: 81.4465%
train_eval_model(X_train, y_train, X_test, y_test, 55, 30, 50, 15)
Epoch 1/50 42/42 [==============================] - 1s 5ms/step - loss: 17.8443 - accuracy: 0.3657 - val_loss: 1.4768 - val_accuracy: 0.4018 Epoch 2/50 42/42 [==============================] - 0s 2ms/step - loss: 1.2789 - accuracy: 0.4070 - val_loss: 1.1073 - val_accuracy: 0.4018 Epoch 3/50 42/42 [==============================] - 0s 2ms/step - loss: 1.0814 - accuracy: 0.4738 - val_loss: 1.2951 - val_accuracy: 0.4018 Epoch 4/50 42/42 [==============================] - 0s 2ms/step - loss: 1.1580 - accuracy: 0.4674 - val_loss: 1.5469 - val_accuracy: 0.2946 Epoch 5/50 42/42 [==============================] - 0s 2ms/step - loss: 1.2102 - accuracy: 0.4722 - val_loss: 1.4464 - val_accuracy: 0.3571 Epoch 6/50 42/42 [==============================] - 0s 2ms/step - loss: 1.0155 - accuracy: 0.5246 - val_loss: 0.9911 - val_accuracy: 0.6071 Epoch 7/50 42/42 [==============================] - 0s 2ms/step - loss: 0.8978 - accuracy: 0.5771 - val_loss: 0.9413 - val_accuracy: 0.5982 Epoch 8/50 42/42 [==============================] - 0s 2ms/step - loss: 0.8977 - accuracy: 0.6089 - val_loss: 0.9143 - val_accuracy: 0.4911 Epoch 9/50 42/42 [==============================] - 0s 2ms/step - loss: 0.8544 - accuracy: 0.5676 - val_loss: 0.9727 - val_accuracy: 0.5089 Epoch 10/50 42/42 [==============================] - 0s 2ms/step - loss: 0.8415 - accuracy: 0.6010 - val_loss: 0.9044 - val_accuracy: 0.6429 Epoch 11/50 42/42 [==============================] - 0s 2ms/step - loss: 0.9571 - accuracy: 0.5739 - val_loss: 1.0746 - val_accuracy: 0.5446 Epoch 12/50 42/42 [==============================] - 0s 2ms/step - loss: 0.8441 - accuracy: 0.6121 - val_loss: 0.8581 - val_accuracy: 0.5089 Epoch 13/50 42/42 [==============================] - 0s 2ms/step - loss: 0.9127 - accuracy: 0.5644 - val_loss: 0.9773 - val_accuracy: 0.4821 Epoch 14/50 42/42 [==============================] - 0s 2ms/step - loss: 0.8313 - accuracy: 0.6232 - val_loss: 1.0047 - val_accuracy: 0.4464 Epoch 15/50 42/42 [==============================] - 0s 2ms/step - loss: 0.8349 - accuracy: 0.6089 - val_loss: 0.7974 - val_accuracy: 0.7232 Epoch 16/50 42/42 [==============================] - 0s 2ms/step - loss: 0.8043 - accuracy: 0.6407 - val_loss: 0.9041 - val_accuracy: 0.7054 Epoch 17/50 42/42 [==============================] - 0s 2ms/step - loss: 0.7919 - accuracy: 0.6391 - val_loss: 0.7596 - val_accuracy: 0.6429 Epoch 18/50 42/42 [==============================] - 0s 2ms/step - loss: 0.8036 - accuracy: 0.6280 - val_loss: 0.7814 - val_accuracy: 0.6607 Epoch 19/50 42/42 [==============================] - 0s 2ms/step - loss: 0.7364 - accuracy: 0.6455 - val_loss: 0.7235 - val_accuracy: 0.6518 Epoch 20/50 42/42 [==============================] - 0s 2ms/step - loss: 0.7479 - accuracy: 0.6677 - val_loss: 0.7065 - val_accuracy: 0.6250 Epoch 21/50 42/42 [==============================] - 0s 2ms/step - loss: 0.6815 - accuracy: 0.7043 - val_loss: 0.7105 - val_accuracy: 0.7232 Epoch 22/50 42/42 [==============================] - 0s 2ms/step - loss: 0.7053 - accuracy: 0.6979 - val_loss: 0.7220 - val_accuracy: 0.7500 Epoch 23/50 42/42 [==============================] - 0s 3ms/step - loss: 0.7192 - accuracy: 0.6725 - val_loss: 0.7412 - val_accuracy: 0.5625 Epoch 24/50 42/42 [==============================] - 0s 2ms/step - loss: 0.6894 - accuracy: 0.6900 - val_loss: 0.8086 - val_accuracy: 0.6071 Epoch 25/50 42/42 [==============================] - 0s 2ms/step - loss: 0.7546 - accuracy: 0.6423 - val_loss: 0.6987 - val_accuracy: 0.7589 Epoch 26/50 42/42 [==============================] - 0s 2ms/step - loss: 0.6755 - accuracy: 0.7043 - val_loss: 0.7751 - val_accuracy: 0.6607 Epoch 27/50 42/42 [==============================] - 0s 2ms/step - loss: 0.6426 - accuracy: 0.7011 - val_loss: 0.8959 - val_accuracy: 0.5804 Epoch 28/50 42/42 [==============================] - 0s 2ms/step - loss: 0.6607 - accuracy: 0.7107 - val_loss: 0.7024 - val_accuracy: 0.7054 Epoch 29/50 42/42 [==============================] - 0s 2ms/step - loss: 0.6383 - accuracy: 0.7154 - val_loss: 0.6420 - val_accuracy: 0.7054 Epoch 30/50 42/42 [==============================] - 0s 2ms/step - loss: 0.6402 - accuracy: 0.7027 - val_loss: 0.7040 - val_accuracy: 0.7232 Epoch 31/50 42/42 [==============================] - 0s 2ms/step - loss: 0.6582 - accuracy: 0.6916 - val_loss: 0.6676 - val_accuracy: 0.6607 Epoch 32/50 42/42 [==============================] - 0s 2ms/step - loss: 0.6301 - accuracy: 0.6963 - val_loss: 0.6399 - val_accuracy: 0.7143 Epoch 33/50 42/42 [==============================] - 0s 2ms/step - loss: 0.6320 - accuracy: 0.7154 - val_loss: 0.6226 - val_accuracy: 0.7143 Epoch 34/50 42/42 [==============================] - 0s 2ms/step - loss: 0.6810 - accuracy: 0.7027 - val_loss: 0.7565 - val_accuracy: 0.6161 Epoch 35/50 42/42 [==============================] - 0s 2ms/step - loss: 0.6625 - accuracy: 0.7122 - val_loss: 0.6503 - val_accuracy: 0.6429 Epoch 36/50 42/42 [==============================] - 0s 2ms/step - loss: 0.6237 - accuracy: 0.7091 - val_loss: 0.6127 - val_accuracy: 0.7321 Epoch 37/50 42/42 [==============================] - 0s 2ms/step - loss: 0.6962 - accuracy: 0.6582 - val_loss: 0.7192 - val_accuracy: 0.6696 Epoch 38/50 42/42 [==============================] - 0s 2ms/step - loss: 0.6046 - accuracy: 0.7218 - val_loss: 0.7005 - val_accuracy: 0.7143 Epoch 39/50 42/42 [==============================] - 0s 2ms/step - loss: 0.6431 - accuracy: 0.6916 - val_loss: 0.6302 - val_accuracy: 0.7500 Epoch 40/50 42/42 [==============================] - 0s 2ms/step - loss: 0.6209 - accuracy: 0.7297 - val_loss: 0.6239 - val_accuracy: 0.6875 Epoch 41/50 42/42 [==============================] - 0s 2ms/step - loss: 0.5763 - accuracy: 0.7218 - val_loss: 0.6262 - val_accuracy: 0.7321 Epoch 42/50 42/42 [==============================] - 0s 2ms/step - loss: 0.5786 - accuracy: 0.7409 - val_loss: 0.6459 - val_accuracy: 0.6964 Epoch 43/50 42/42 [==============================] - 0s 2ms/step - loss: 0.6030 - accuracy: 0.7281 - val_loss: 0.6941 - val_accuracy: 0.7500 Epoch 44/50 42/42 [==============================] - 0s 2ms/step - loss: 0.5604 - accuracy: 0.7472 - val_loss: 0.6279 - val_accuracy: 0.7500 Epoch 45/50 42/42 [==============================] - 0s 2ms/step - loss: 0.6183 - accuracy: 0.7234 - val_loss: 0.7836 - val_accuracy: 0.6518 Epoch 46/50 42/42 [==============================] - 0s 2ms/step - loss: 0.6234 - accuracy: 0.7186 - val_loss: 0.6689 - val_accuracy: 0.6786 Epoch 47/50 42/42 [==============================] - 0s 2ms/step - loss: 0.5716 - accuracy: 0.7440 - val_loss: 0.6753 - val_accuracy: 0.7232 Epoch 48/50 42/42 [==============================] - 0s 2ms/step - loss: 0.5511 - accuracy: 0.7711 - val_loss: 0.5650 - val_accuracy: 0.7500 Epoch 49/50 42/42 [==============================] - 0s 2ms/step - loss: 0.5582 - accuracy: 0.7615 - val_loss: 0.8085 - val_accuracy: 0.5982 Epoch 50/50 42/42 [==============================] - 0s 2ms/step - loss: 0.6742 - accuracy: 0.6963 - val_loss: 0.5591 - val_accuracy: 0.7857 10/10 [==============================] - 0s 1ms/step - loss: 0.4754 - accuracy: 0.8208 accuracy: 82.0755%
train_eval_model(X_train, y_train, X_test, y_test, 55, 30, 50, 15)
Epoch 1/150 42/42 [==============================] - 1s 6ms/step - loss: 2.6267 - accuracy: 0.3895 - val_loss: 1.2122 - val_accuracy: 0.4643 Epoch 2/150 42/42 [==============================] - 0s 2ms/step - loss: 0.9439 - accuracy: 0.5533 - val_loss: 1.1734 - val_accuracy: 0.5804 Epoch 3/150 42/42 [==============================] - 0s 2ms/step - loss: 0.9321 - accuracy: 0.5707 - val_loss: 0.9394 - val_accuracy: 0.5357 Epoch 4/150 42/42 [==============================] - 0s 2ms/step - loss: 0.9000 - accuracy: 0.5580 - val_loss: 1.0492 - val_accuracy: 0.5179 Epoch 5/150 42/42 [==============================] - 0s 2ms/step - loss: 0.8955 - accuracy: 0.6010 - val_loss: 1.2346 - val_accuracy: 0.5268 Epoch 6/150 42/42 [==============================] - 0s 2ms/step - loss: 0.8872 - accuracy: 0.5898 - val_loss: 0.9510 - val_accuracy: 0.5804 Epoch 7/150 42/42 [==============================] - 0s 2ms/step - loss: 0.8738 - accuracy: 0.6200 - val_loss: 0.9872 - val_accuracy: 0.5268 Epoch 8/150 42/42 [==============================] - 0s 2ms/step - loss: 0.8387 - accuracy: 0.5946 - val_loss: 1.1425 - val_accuracy: 0.5089 Epoch 9/150 42/42 [==============================] - 0s 2ms/step - loss: 0.8515 - accuracy: 0.6169 - val_loss: 0.9293 - val_accuracy: 0.5446 Epoch 10/150 42/42 [==============================] - 0s 2ms/step - loss: 0.9730 - accuracy: 0.5596 - val_loss: 1.5070 - val_accuracy: 0.5268 Epoch 11/150 42/42 [==============================] - 0s 2ms/step - loss: 0.9004 - accuracy: 0.5628 - val_loss: 0.9662 - val_accuracy: 0.4643 Epoch 12/150 42/42 [==============================] - 0s 2ms/step - loss: 0.7779 - accuracy: 0.6343 - val_loss: 1.0216 - val_accuracy: 0.5268 Epoch 13/150 42/42 [==============================] - 0s 2ms/step - loss: 0.8505 - accuracy: 0.6010 - val_loss: 0.8268 - val_accuracy: 0.6339 Epoch 14/150 42/42 [==============================] - 0s 2ms/step - loss: 0.8515 - accuracy: 0.6359 - val_loss: 0.9324 - val_accuracy: 0.5893 Epoch 15/150 42/42 [==============================] - 0s 2ms/step - loss: 0.8051 - accuracy: 0.6439 - val_loss: 0.8081 - val_accuracy: 0.7054 Epoch 16/150 42/42 [==============================] - 0s 2ms/step - loss: 0.7560 - accuracy: 0.6486 - val_loss: 1.0065 - val_accuracy: 0.5000 Epoch 17/150 42/42 [==============================] - 0s 3ms/step - loss: 0.7378 - accuracy: 0.6486 - val_loss: 0.7666 - val_accuracy: 0.6161 Epoch 18/150 42/42 [==============================] - 0s 2ms/step - loss: 0.7705 - accuracy: 0.6248 - val_loss: 0.8087 - val_accuracy: 0.6250 Epoch 19/150 42/42 [==============================] - 0s 2ms/step - loss: 0.7694 - accuracy: 0.6232 - val_loss: 0.8089 - val_accuracy: 0.6071 Epoch 20/150 42/42 [==============================] - 0s 2ms/step - loss: 0.7206 - accuracy: 0.6677 - val_loss: 0.7415 - val_accuracy: 0.6339 Epoch 21/150 42/42 [==============================] - 0s 2ms/step - loss: 0.7482 - accuracy: 0.6343 - val_loss: 0.7473 - val_accuracy: 0.6071 Epoch 22/150 42/42 [==============================] - 0s 2ms/step - loss: 0.7041 - accuracy: 0.6582 - val_loss: 0.7307 - val_accuracy: 0.6696 Epoch 23/150 42/42 [==============================] - 0s 2ms/step - loss: 0.7422 - accuracy: 0.6518 - val_loss: 0.7760 - val_accuracy: 0.5804 Epoch 24/150 42/42 [==============================] - 0s 2ms/step - loss: 0.6905 - accuracy: 0.6598 - val_loss: 0.7346 - val_accuracy: 0.5982 Epoch 25/150 42/42 [==============================] - 0s 2ms/step - loss: 0.6967 - accuracy: 0.6598 - val_loss: 0.7591 - val_accuracy: 0.6429 Epoch 26/150 42/42 [==============================] - 0s 2ms/step - loss: 0.6898 - accuracy: 0.6582 - val_loss: 0.7813 - val_accuracy: 0.6161 Epoch 27/150 42/42 [==============================] - 0s 2ms/step - loss: 0.7042 - accuracy: 0.6757 - val_loss: 0.7798 - val_accuracy: 0.6339 Epoch 28/150 42/42 [==============================] - 0s 2ms/step - loss: 0.7042 - accuracy: 0.6645 - val_loss: 0.8256 - val_accuracy: 0.5982 Epoch 29/150 42/42 [==============================] - 0s 2ms/step - loss: 0.7058 - accuracy: 0.6614 - val_loss: 0.7130 - val_accuracy: 0.6250 Epoch 30/150 42/42 [==============================] - 0s 2ms/step - loss: 0.6862 - accuracy: 0.6677 - val_loss: 0.7204 - val_accuracy: 0.7321 Epoch 31/150 42/42 [==============================] - 0s 2ms/step - loss: 0.6450 - accuracy: 0.6900 - val_loss: 0.7818 - val_accuracy: 0.5982 Epoch 32/150 42/42 [==============================] - 0s 2ms/step - loss: 0.8793 - accuracy: 0.5978 - val_loss: 0.7702 - val_accuracy: 0.6518 Epoch 33/150 42/42 [==============================] - 0s 2ms/step - loss: 0.7374 - accuracy: 0.6471 - val_loss: 0.6871 - val_accuracy: 0.6964 Epoch 34/150 42/42 [==============================] - 0s 2ms/step - loss: 0.6574 - accuracy: 0.6932 - val_loss: 0.8544 - val_accuracy: 0.6071 Epoch 35/150 42/42 [==============================] - 0s 2ms/step - loss: 0.6777 - accuracy: 0.6836 - val_loss: 0.7507 - val_accuracy: 0.5804 Epoch 36/150 42/42 [==============================] - 0s 2ms/step - loss: 0.6705 - accuracy: 0.7027 - val_loss: 0.6849 - val_accuracy: 0.6429 Epoch 37/150 42/42 [==============================] - 0s 2ms/step - loss: 0.6831 - accuracy: 0.6645 - val_loss: 0.6861 - val_accuracy: 0.5982 Epoch 38/150 42/42 [==============================] - 0s 2ms/step - loss: 0.6284 - accuracy: 0.6995 - val_loss: 0.6885 - val_accuracy: 0.5982 Epoch 39/150 42/42 [==============================] - 0s 3ms/step - loss: 0.7094 - accuracy: 0.6614 - val_loss: 0.6589 - val_accuracy: 0.6429 Epoch 40/150 42/42 [==============================] - 0s 2ms/step - loss: 0.6959 - accuracy: 0.6757 - val_loss: 0.7850 - val_accuracy: 0.5982 Epoch 41/150 42/42 [==============================] - 0s 2ms/step - loss: 0.6377 - accuracy: 0.7107 - val_loss: 0.6601 - val_accuracy: 0.6964 Epoch 42/150 42/42 [==============================] - 0s 2ms/step - loss: 0.6109 - accuracy: 0.7170 - val_loss: 0.6713 - val_accuracy: 0.6875 Epoch 43/150 42/42 [==============================] - 0s 2ms/step - loss: 0.6007 - accuracy: 0.7393 - val_loss: 0.6932 - val_accuracy: 0.7054 Epoch 44/150 42/42 [==============================] - 0s 2ms/step - loss: 0.6737 - accuracy: 0.6963 - val_loss: 0.7397 - val_accuracy: 0.7143 Epoch 45/150 42/42 [==============================] - 0s 2ms/step - loss: 0.6859 - accuracy: 0.6979 - val_loss: 0.7514 - val_accuracy: 0.6429 Epoch 46/150 42/42 [==============================] - 0s 2ms/step - loss: 0.6168 - accuracy: 0.7186 - val_loss: 0.8445 - val_accuracy: 0.6161 Epoch 47/150 42/42 [==============================] - 0s 2ms/step - loss: 0.7418 - accuracy: 0.6677 - val_loss: 0.7712 - val_accuracy: 0.5893 Epoch 48/150 42/42 [==============================] - 0s 2ms/step - loss: 0.6801 - accuracy: 0.7075 - val_loss: 0.6722 - val_accuracy: 0.7411 Epoch 49/150 42/42 [==============================] - 0s 2ms/step - loss: 0.5877 - accuracy: 0.7393 - val_loss: 0.6783 - val_accuracy: 0.6696 Epoch 50/150 42/42 [==============================] - 0s 2ms/step - loss: 0.6121 - accuracy: 0.7281 - val_loss: 0.6274 - val_accuracy: 0.7321 Epoch 51/150 42/42 [==============================] - 0s 2ms/step - loss: 0.6521 - accuracy: 0.6963 - val_loss: 0.6300 - val_accuracy: 0.7411 Epoch 52/150 42/42 [==============================] - 0s 2ms/step - loss: 0.5880 - accuracy: 0.7504 - val_loss: 0.6456 - val_accuracy: 0.6786 Epoch 53/150 42/42 [==============================] - 0s 2ms/step - loss: 0.6312 - accuracy: 0.7266 - val_loss: 0.8025 - val_accuracy: 0.5536 Epoch 54/150 42/42 [==============================] - 0s 2ms/step - loss: 0.6132 - accuracy: 0.7027 - val_loss: 0.7209 - val_accuracy: 0.6518 Epoch 55/150 42/42 [==============================] - 0s 2ms/step - loss: 0.6634 - accuracy: 0.6852 - val_loss: 0.7073 - val_accuracy: 0.6875 Epoch 56/150 42/42 [==============================] - 0s 2ms/step - loss: 0.6428 - accuracy: 0.7043 - val_loss: 0.6417 - val_accuracy: 0.6696 Epoch 57/150 42/42 [==============================] - 0s 2ms/step - loss: 0.6140 - accuracy: 0.7154 - val_loss: 0.6690 - val_accuracy: 0.6607 Epoch 58/150 42/42 [==============================] - 0s 2ms/step - loss: 0.5779 - accuracy: 0.7504 - val_loss: 0.6394 - val_accuracy: 0.6339 Epoch 59/150 42/42 [==============================] - 0s 2ms/step - loss: 0.5883 - accuracy: 0.7424 - val_loss: 0.5840 - val_accuracy: 0.7143 Epoch 60/150 42/42 [==============================] - 0s 2ms/step - loss: 0.5714 - accuracy: 0.7631 - val_loss: 0.8597 - val_accuracy: 0.6071 Epoch 61/150 42/42 [==============================] - 0s 2ms/step - loss: 0.6060 - accuracy: 0.7154 - val_loss: 0.9389 - val_accuracy: 0.5893 Epoch 62/150 42/42 [==============================] - 0s 2ms/step - loss: 0.6477 - accuracy: 0.7043 - val_loss: 0.6029 - val_accuracy: 0.6607 Epoch 63/150 42/42 [==============================] - 0s 2ms/step - loss: 0.5634 - accuracy: 0.7504 - val_loss: 0.6315 - val_accuracy: 0.6607 Epoch 64/150 42/42 [==============================] - 0s 2ms/step - loss: 0.5908 - accuracy: 0.7488 - val_loss: 0.6130 - val_accuracy: 0.7143 Epoch 65/150 42/42 [==============================] - 0s 2ms/step - loss: 0.5618 - accuracy: 0.7456 - val_loss: 0.5798 - val_accuracy: 0.7411 Epoch 66/150 42/42 [==============================] - 0s 2ms/step - loss: 0.5465 - accuracy: 0.7663 - val_loss: 0.6004 - val_accuracy: 0.7054 Epoch 67/150 42/42 [==============================] - 0s 2ms/step - loss: 0.6057 - accuracy: 0.7377 - val_loss: 0.6292 - val_accuracy: 0.7054 Epoch 68/150 42/42 [==============================] - 0s 2ms/step - loss: 0.6425 - accuracy: 0.7170 - val_loss: 0.5640 - val_accuracy: 0.7321 Epoch 69/150 42/42 [==============================] - 0s 2ms/step - loss: 0.6000 - accuracy: 0.7154 - val_loss: 0.5606 - val_accuracy: 0.7679 Epoch 70/150 42/42 [==============================] - 0s 2ms/step - loss: 0.5665 - accuracy: 0.7424 - val_loss: 0.5839 - val_accuracy: 0.7411 Epoch 71/150 42/42 [==============================] - 0s 2ms/step - loss: 0.5709 - accuracy: 0.7361 - val_loss: 0.5529 - val_accuracy: 0.7679 Epoch 72/150 42/42 [==============================] - 0s 2ms/step - loss: 0.5358 - accuracy: 0.7599 - val_loss: 0.7237 - val_accuracy: 0.7321 Epoch 73/150 42/42 [==============================] - 0s 2ms/step - loss: 0.5880 - accuracy: 0.7361 - val_loss: 0.5803 - val_accuracy: 0.7232 Epoch 74/150 42/42 [==============================] - 0s 2ms/step - loss: 0.5458 - accuracy: 0.7711 - val_loss: 0.5434 - val_accuracy: 0.7768 Epoch 75/150 42/42 [==============================] - 0s 2ms/step - loss: 0.5268 - accuracy: 0.7901 - val_loss: 0.5363 - val_accuracy: 0.7768 Epoch 76/150 42/42 [==============================] - 0s 2ms/step - loss: 0.5268 - accuracy: 0.7886 - val_loss: 0.5722 - val_accuracy: 0.7679 Epoch 77/150 42/42 [==============================] - 0s 2ms/step - loss: 0.6105 - accuracy: 0.7281 - val_loss: 0.5493 - val_accuracy: 0.8036 Epoch 78/150 42/42 [==============================] - 0s 2ms/step - loss: 0.5371 - accuracy: 0.7870 - val_loss: 0.5229 - val_accuracy: 0.7857 Epoch 79/150 42/42 [==============================] - 0s 2ms/step - loss: 0.5111 - accuracy: 0.7997 - val_loss: 0.5315 - val_accuracy: 0.8036 Epoch 80/150 42/42 [==============================] - 0s 2ms/step - loss: 0.5440 - accuracy: 0.7504 - val_loss: 0.5895 - val_accuracy: 0.7321 Epoch 81/150 42/42 [==============================] - 0s 2ms/step - loss: 0.5563 - accuracy: 0.7583 - val_loss: 0.5725 - val_accuracy: 0.7857 Epoch 82/150 42/42 [==============================] - 0s 2ms/step - loss: 0.5046 - accuracy: 0.8076 - val_loss: 0.5408 - val_accuracy: 0.7589 Epoch 83/150 42/42 [==============================] - 0s 2ms/step - loss: 0.5824 - accuracy: 0.7393 - val_loss: 0.8550 - val_accuracy: 0.5625 Epoch 84/150 42/42 [==============================] - 0s 2ms/step - loss: 0.5392 - accuracy: 0.7488 - val_loss: 0.5254 - val_accuracy: 0.8125 Epoch 85/150 42/42 [==============================] - 0s 2ms/step - loss: 0.5254 - accuracy: 0.7758 - val_loss: 0.5193 - val_accuracy: 0.8304 Epoch 86/150 42/42 [==============================] - 0s 2ms/step - loss: 0.5182 - accuracy: 0.7742 - val_loss: 0.5135 - val_accuracy: 0.7679 Epoch 87/150 42/42 [==============================] - 0s 2ms/step - loss: 0.4788 - accuracy: 0.8045 - val_loss: 0.5494 - val_accuracy: 0.7589 Epoch 88/150 42/42 [==============================] - 0s 2ms/step - loss: 0.4961 - accuracy: 0.7981 - val_loss: 0.7635 - val_accuracy: 0.5982 Epoch 89/150 42/42 [==============================] - 0s 2ms/step - loss: 0.5295 - accuracy: 0.7647 - val_loss: 0.6529 - val_accuracy: 0.6429 Epoch 90/150 42/42 [==============================] - 0s 2ms/step - loss: 0.5216 - accuracy: 0.7536 - val_loss: 0.5021 - val_accuracy: 0.7857 Epoch 91/150 42/42 [==============================] - 0s 2ms/step - loss: 0.4741 - accuracy: 0.8140 - val_loss: 0.4889 - val_accuracy: 0.7857 Epoch 92/150 42/42 [==============================] - 0s 2ms/step - loss: 0.5612 - accuracy: 0.7440 - val_loss: 0.7228 - val_accuracy: 0.7143 Epoch 93/150 42/42 [==============================] - 0s 2ms/step - loss: 0.5770 - accuracy: 0.7409 - val_loss: 0.6267 - val_accuracy: 0.6786 Epoch 94/150 42/42 [==============================] - 0s 2ms/step - loss: 0.5631 - accuracy: 0.7520 - val_loss: 0.5478 - val_accuracy: 0.7411 Epoch 95/150 42/42 [==============================] - 0s 2ms/step - loss: 0.5415 - accuracy: 0.7695 - val_loss: 0.7320 - val_accuracy: 0.6339 Epoch 96/150 42/42 [==============================] - 0s 2ms/step - loss: 0.5919 - accuracy: 0.7297 - val_loss: 0.6597 - val_accuracy: 0.6607 Epoch 97/150 42/42 [==============================] - 0s 2ms/step - loss: 0.5361 - accuracy: 0.7583 - val_loss: 0.5364 - val_accuracy: 0.7500 Epoch 98/150 42/42 [==============================] - 0s 2ms/step - loss: 0.5128 - accuracy: 0.7981 - val_loss: 0.5289 - val_accuracy: 0.7679 Epoch 99/150 42/42 [==============================] - 0s 2ms/step - loss: 0.4674 - accuracy: 0.8092 - val_loss: 0.4932 - val_accuracy: 0.8304 Epoch 100/150 42/42 [==============================] - 0s 2ms/step - loss: 0.5007 - accuracy: 0.7711 - val_loss: 0.4961 - val_accuracy: 0.7679 Epoch 101/150 42/42 [==============================] - 0s 2ms/step - loss: 0.4755 - accuracy: 0.8076 - val_loss: 0.4810 - val_accuracy: 0.8304 Epoch 102/150 42/42 [==============================] - 0s 2ms/step - loss: 0.5066 - accuracy: 0.7901 - val_loss: 0.4930 - val_accuracy: 0.8214 Epoch 103/150 42/42 [==============================] - 0s 2ms/step - loss: 0.4671 - accuracy: 0.8172 - val_loss: 0.5213 - val_accuracy: 0.7500 Epoch 104/150 42/42 [==============================] - 0s 2ms/step - loss: 0.4467 - accuracy: 0.8108 - val_loss: 0.4751 - val_accuracy: 0.8036 Epoch 105/150 42/42 [==============================] - 0s 2ms/step - loss: 0.4971 - accuracy: 0.7838 - val_loss: 0.5881 - val_accuracy: 0.7321 Epoch 106/150 42/42 [==============================] - 0s 2ms/step - loss: 0.5056 - accuracy: 0.7742 - val_loss: 0.4593 - val_accuracy: 0.8393 Epoch 107/150 42/42 [==============================] - 0s 2ms/step - loss: 0.4817 - accuracy: 0.8172 - val_loss: 0.7131 - val_accuracy: 0.6518 Epoch 108/150 42/42 [==============================] - 0s 2ms/step - loss: 0.4726 - accuracy: 0.8013 - val_loss: 0.5633 - val_accuracy: 0.7321 Epoch 109/150 42/42 [==============================] - 0s 2ms/step - loss: 0.4841 - accuracy: 0.7822 - val_loss: 0.4582 - val_accuracy: 0.8393 Epoch 110/150 42/42 [==============================] - 0s 2ms/step - loss: 0.4692 - accuracy: 0.8092 - val_loss: 0.5228 - val_accuracy: 0.7500 Epoch 111/150 42/42 [==============================] - 0s 2ms/step - loss: 0.4478 - accuracy: 0.8108 - val_loss: 0.4706 - val_accuracy: 0.7768 Epoch 112/150 42/42 [==============================] - 0s 2ms/step - loss: 0.4879 - accuracy: 0.7933 - val_loss: 0.5371 - val_accuracy: 0.7589 Epoch 113/150 42/42 [==============================] - 0s 2ms/step - loss: 0.4386 - accuracy: 0.8235 - val_loss: 0.4984 - val_accuracy: 0.7500 Epoch 114/150 42/42 [==============================] - 0s 2ms/step - loss: 0.4623 - accuracy: 0.7838 - val_loss: 0.5855 - val_accuracy: 0.7143 Epoch 115/150 42/42 [==============================] - 0s 2ms/step - loss: 0.4805 - accuracy: 0.7965 - val_loss: 0.4710 - val_accuracy: 0.8214 Epoch 116/150 42/42 [==============================] - 0s 2ms/step - loss: 0.4557 - accuracy: 0.8203 - val_loss: 0.4289 - val_accuracy: 0.8393 Epoch 117/150 42/42 [==============================] - 0s 2ms/step - loss: 0.4149 - accuracy: 0.8426 - val_loss: 0.4573 - val_accuracy: 0.8125 Epoch 118/150 42/42 [==============================] - 0s 2ms/step - loss: 0.4198 - accuracy: 0.8426 - val_loss: 0.5044 - val_accuracy: 0.8214 Epoch 119/150 42/42 [==============================] - 0s 2ms/step - loss: 0.4064 - accuracy: 0.8426 - val_loss: 0.4645 - val_accuracy: 0.8571 Epoch 120/150 42/42 [==============================] - 0s 2ms/step - loss: 0.4332 - accuracy: 0.8108 - val_loss: 0.4384 - val_accuracy: 0.8125 Epoch 121/150 42/42 [==============================] - 0s 2ms/step - loss: 0.4244 - accuracy: 0.8172 - val_loss: 0.4538 - val_accuracy: 0.8393 Epoch 122/150 42/42 [==============================] - 0s 2ms/step - loss: 0.5670 - accuracy: 0.7536 - val_loss: 0.5498 - val_accuracy: 0.7411 Epoch 123/150 42/42 [==============================] - 0s 2ms/step - loss: 0.6258 - accuracy: 0.7266 - val_loss: 0.4367 - val_accuracy: 0.8393 Epoch 124/150 42/42 [==============================] - 0s 2ms/step - loss: 0.4532 - accuracy: 0.8060 - val_loss: 0.4494 - val_accuracy: 0.8125 Epoch 125/150 42/42 [==============================] - 0s 2ms/step - loss: 0.4330 - accuracy: 0.8156 - val_loss: 0.7741 - val_accuracy: 0.6429 Epoch 126/150 42/42 [==============================] - 0s 2ms/step - loss: 0.5057 - accuracy: 0.7774 - val_loss: 0.4527 - val_accuracy: 0.8036 Epoch 127/150 42/42 [==============================] - 0s 3ms/step - loss: 0.4669 - accuracy: 0.8108 - val_loss: 0.4691 - val_accuracy: 0.8036 Epoch 128/150 42/42 [==============================] - 0s 2ms/step - loss: 0.4287 - accuracy: 0.8267 - val_loss: 0.4189 - val_accuracy: 0.8214 Epoch 129/150 42/42 [==============================] - 0s 2ms/step - loss: 0.4015 - accuracy: 0.8315 - val_loss: 0.5260 - val_accuracy: 0.7500 Epoch 130/150 42/42 [==============================] - 0s 2ms/step - loss: 0.4428 - accuracy: 0.8013 - val_loss: 0.5850 - val_accuracy: 0.6786 Epoch 131/150 42/42 [==============================] - 0s 2ms/step - loss: 0.4305 - accuracy: 0.8315 - val_loss: 0.5077 - val_accuracy: 0.7768 Epoch 132/150 42/42 [==============================] - 0s 2ms/step - loss: 0.4084 - accuracy: 0.8267 - val_loss: 0.4328 - val_accuracy: 0.8214 Epoch 133/150 42/42 [==============================] - 0s 2ms/step - loss: 0.3988 - accuracy: 0.8490 - val_loss: 0.4997 - val_accuracy: 0.7857 Epoch 134/150 42/42 [==============================] - 0s 2ms/step - loss: 0.4544 - accuracy: 0.8013 - val_loss: 0.4098 - val_accuracy: 0.8125 Epoch 135/150 42/42 [==============================] - 0s 2ms/step - loss: 0.3988 - accuracy: 0.8378 - val_loss: 0.4672 - val_accuracy: 0.8571 Epoch 136/150 42/42 [==============================] - 0s 2ms/step - loss: 0.3994 - accuracy: 0.8283 - val_loss: 0.5769 - val_accuracy: 0.7589 Epoch 137/150 42/42 [==============================] - 0s 3ms/step - loss: 0.4145 - accuracy: 0.8156 - val_loss: 0.4016 - val_accuracy: 0.8393 Epoch 138/150 42/42 [==============================] - 0s 2ms/step - loss: 0.3824 - accuracy: 0.8506 - val_loss: 0.5700 - val_accuracy: 0.7857 Epoch 139/150 42/42 [==============================] - 0s 2ms/step - loss: 0.3997 - accuracy: 0.8378 - val_loss: 0.4817 - val_accuracy: 0.7679 Epoch 140/150 42/42 [==============================] - 0s 2ms/step - loss: 0.3783 - accuracy: 0.8490 - val_loss: 0.4410 - val_accuracy: 0.8214 Epoch 141/150 42/42 [==============================] - 0s 2ms/step - loss: 0.3908 - accuracy: 0.8188 - val_loss: 0.5193 - val_accuracy: 0.7679 Epoch 142/150 42/42 [==============================] - 0s 2ms/step - loss: 0.4194 - accuracy: 0.8172 - val_loss: 0.4430 - val_accuracy: 0.7679 Epoch 143/150 42/42 [==============================] - 0s 2ms/step - loss: 0.4135 - accuracy: 0.8219 - val_loss: 0.4415 - val_accuracy: 0.7679 Epoch 144/150 42/42 [==============================] - 0s 2ms/step - loss: 0.4347 - accuracy: 0.8045 - val_loss: 0.5366 - val_accuracy: 0.7857 Epoch 145/150 42/42 [==============================] - 0s 2ms/step - loss: 0.4073 - accuracy: 0.8315 - val_loss: 0.4410 - val_accuracy: 0.8214 Epoch 146/150 42/42 [==============================] - 0s 2ms/step - loss: 0.4026 - accuracy: 0.8394 - val_loss: 0.4013 - val_accuracy: 0.8661 Epoch 147/150 42/42 [==============================] - 0s 2ms/step - loss: 0.3793 - accuracy: 0.8458 - val_loss: 0.5085 - val_accuracy: 0.7946 Epoch 148/150 42/42 [==============================] - 0s 2ms/step - loss: 0.4227 - accuracy: 0.8347 - val_loss: 0.4853 - val_accuracy: 0.8214 Epoch 149/150 42/42 [==============================] - 0s 2ms/step - loss: 0.4286 - accuracy: 0.8235 - val_loss: 0.4343 - val_accuracy: 0.7946 Epoch 150/150 42/42 [==============================] - 0s 2ms/step - loss: 0.3879 - accuracy: 0.8410 - val_loss: 0.5773 - val_accuracy: 0.7768 10/10 [==============================] - 0s 999us/step - loss: 0.4838 - accuracy: 0.7704 accuracy: 77.0440%
def train_eval_model_2(x1, y1, x2, y2, n1, n2, n):
"""Función para realizar el entrenamiento de la red neuronal. Asimismo,
se realiza la evaluación del mismo.
Parámetros:
* x1: X_train.
* y1: y_train.
* x2: X_test.
* y2: y_test.
* n1: número de neuronas en la primer capa oculta.
* n2: número de neuronas en la segunda capa oculta.
* n: número de épocas.
* k: batch_size."""
# Instanciamos el modelo secuencial
model = Sequential()
# Capa de entrada y primera capa oculta
model.add(Dense(n1, activation='relu', input_shape=(7,)))
# Capa oculta 2
model.add(Dense(n2, activation='relu'))
# Capa de salida
model.add(Dense(3, activation='softmax'))
# Copilacion del modelo
model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy'])
# Entrenamiento del modelo.
# Destinamos el 15% de los datos de entrenamiento para la validacion
history = model.fit(x1, y1, epochs=n, validation_split=0.15)
# Evalucacion del modelo
scores = model.evaluate(x2, y2)
print('%s: %.4f%%' % (model.metrics_names[1], scores[1] * 100))
# Grafico de la precision del entrenamiento vs precision de la validacion
plt.plot(history.history['accuracy'])
plt.plot(history.history['val_accuracy'])
plt.title('Precisión del modelo')
plt.xlabel('Epoch')
plt.ylabel('Precisión')
plt.legend(['Train', 'Validación'])
plt.show()
train_eval_model_2(X_train, y_train, X_test, y_test, 55, 30, 50)
Epoch 1/50 20/20 [==============================] - 1s 12ms/step - loss: 13.9900 - accuracy: 0.4324 - val_loss: 1.7509 - val_accuracy: 0.4554 Epoch 2/50 20/20 [==============================] - 0s 3ms/step - loss: 2.0137 - accuracy: 0.4356 - val_loss: 1.3986 - val_accuracy: 0.4554 Epoch 3/50 20/20 [==============================] - 0s 3ms/step - loss: 1.0370 - accuracy: 0.5326 - val_loss: 1.0501 - val_accuracy: 0.5714 Epoch 4/50 20/20 [==============================] - 0s 3ms/step - loss: 0.9475 - accuracy: 0.5040 - val_loss: 1.0329 - val_accuracy: 0.5625 Epoch 5/50 20/20 [==============================] - 0s 3ms/step - loss: 0.9353 - accuracy: 0.5310 - val_loss: 1.0442 - val_accuracy: 0.4732 Epoch 6/50 20/20 [==============================] - 0s 3ms/step - loss: 0.9629 - accuracy: 0.5882 - val_loss: 1.0296 - val_accuracy: 0.5089 Epoch 7/50 20/20 [==============================] - 0s 3ms/step - loss: 0.8972 - accuracy: 0.5660 - val_loss: 1.0180 - val_accuracy: 0.4196 Epoch 8/50 20/20 [==============================] - 0s 3ms/step - loss: 0.8920 - accuracy: 0.5453 - val_loss: 0.9817 - val_accuracy: 0.5357 Epoch 9/50 20/20 [==============================] - 0s 4ms/step - loss: 0.8891 - accuracy: 0.6169 - val_loss: 0.9729 - val_accuracy: 0.5446 Epoch 10/50 20/20 [==============================] - 0s 3ms/step - loss: 0.9232 - accuracy: 0.5644 - val_loss: 1.0491 - val_accuracy: 0.5893 Epoch 11/50 20/20 [==============================] - 0s 4ms/step - loss: 0.8816 - accuracy: 0.5898 - val_loss: 0.9585 - val_accuracy: 0.5714 Epoch 12/50 20/20 [==============================] - 0s 3ms/step - loss: 0.8319 - accuracy: 0.6121 - val_loss: 1.0043 - val_accuracy: 0.7411 Epoch 13/50 20/20 [==============================] - 0s 3ms/step - loss: 0.8580 - accuracy: 0.5739 - val_loss: 0.9523 - val_accuracy: 0.5357 Epoch 14/50 20/20 [==============================] - 0s 3ms/step - loss: 0.8705 - accuracy: 0.5739 - val_loss: 0.9486 - val_accuracy: 0.4732 Epoch 15/50 20/20 [==============================] - 0s 4ms/step - loss: 0.8285 - accuracy: 0.6025 - val_loss: 0.8891 - val_accuracy: 0.6339 Epoch 16/50 20/20 [==============================] - 0s 3ms/step - loss: 0.7847 - accuracy: 0.6471 - val_loss: 0.8775 - val_accuracy: 0.6339 Epoch 17/50 20/20 [==============================] - 0s 3ms/step - loss: 0.7952 - accuracy: 0.6010 - val_loss: 0.8938 - val_accuracy: 0.6071 Epoch 18/50 20/20 [==============================] - 0s 3ms/step - loss: 0.9453 - accuracy: 0.5612 - val_loss: 0.8804 - val_accuracy: 0.6429 Epoch 19/50 20/20 [==============================] - 0s 3ms/step - loss: 0.8910 - accuracy: 0.5930 - val_loss: 0.8523 - val_accuracy: 0.6607 Epoch 20/50 20/20 [==============================] - 0s 3ms/step - loss: 0.7737 - accuracy: 0.6614 - val_loss: 1.0001 - val_accuracy: 0.5357 Epoch 21/50 20/20 [==============================] - 0s 3ms/step - loss: 0.8252 - accuracy: 0.6184 - val_loss: 0.8519 - val_accuracy: 0.5982 Epoch 22/50 20/20 [==============================] - 0s 3ms/step - loss: 0.7756 - accuracy: 0.6518 - val_loss: 0.8990 - val_accuracy: 0.5804 Epoch 23/50 20/20 [==============================] - 0s 3ms/step - loss: 0.7292 - accuracy: 0.6630 - val_loss: 0.9244 - val_accuracy: 0.5804 Epoch 24/50 20/20 [==============================] - 0s 3ms/step - loss: 0.7804 - accuracy: 0.6534 - val_loss: 0.8490 - val_accuracy: 0.5982 Epoch 25/50 20/20 [==============================] - 0s 3ms/step - loss: 0.7038 - accuracy: 0.6900 - val_loss: 0.7875 - val_accuracy: 0.6786 Epoch 26/50 20/20 [==============================] - 0s 3ms/step - loss: 0.7197 - accuracy: 0.6932 - val_loss: 0.7820 - val_accuracy: 0.6607 Epoch 27/50 20/20 [==============================] - 0s 3ms/step - loss: 0.7119 - accuracy: 0.6757 - val_loss: 0.7811 - val_accuracy: 0.6964 Epoch 28/50 20/20 [==============================] - 0s 3ms/step - loss: 0.7007 - accuracy: 0.6900 - val_loss: 0.9782 - val_accuracy: 0.6161 Epoch 29/50 20/20 [==============================] - 0s 3ms/step - loss: 0.7207 - accuracy: 0.6709 - val_loss: 0.8066 - val_accuracy: 0.6696 Epoch 30/50 20/20 [==============================] - 0s 3ms/step - loss: 0.6713 - accuracy: 0.7202 - val_loss: 0.7609 - val_accuracy: 0.7232 Epoch 31/50 20/20 [==============================] - 0s 3ms/step - loss: 0.6945 - accuracy: 0.7154 - val_loss: 0.7744 - val_accuracy: 0.6161 Epoch 32/50 20/20 [==============================] - 0s 3ms/step - loss: 0.6479 - accuracy: 0.7361 - val_loss: 0.7649 - val_accuracy: 0.6518 Epoch 33/50 20/20 [==============================] - 0s 3ms/step - loss: 0.6417 - accuracy: 0.7424 - val_loss: 0.7904 - val_accuracy: 0.6964 Epoch 34/50 20/20 [==============================] - 0s 3ms/step - loss: 0.6375 - accuracy: 0.7377 - val_loss: 0.7164 - val_accuracy: 0.6964 Epoch 35/50 20/20 [==============================] - 0s 3ms/step - loss: 0.6823 - accuracy: 0.7011 - val_loss: 0.7212 - val_accuracy: 0.7500 Epoch 36/50 20/20 [==============================] - 0s 3ms/step - loss: 0.6411 - accuracy: 0.7345 - val_loss: 0.7957 - val_accuracy: 0.6429 Epoch 37/50 20/20 [==============================] - 0s 3ms/step - loss: 0.6638 - accuracy: 0.7043 - val_loss: 0.7528 - val_accuracy: 0.6607 Epoch 38/50 20/20 [==============================] - 0s 3ms/step - loss: 0.7517 - accuracy: 0.6661 - val_loss: 1.0432 - val_accuracy: 0.6161 Epoch 39/50 20/20 [==============================] - 0s 3ms/step - loss: 0.7115 - accuracy: 0.6963 - val_loss: 0.7995 - val_accuracy: 0.6607 Epoch 40/50 20/20 [==============================] - 0s 3ms/step - loss: 0.7378 - accuracy: 0.6884 - val_loss: 0.7625 - val_accuracy: 0.6786 Epoch 41/50 20/20 [==============================] - 0s 3ms/step - loss: 0.6710 - accuracy: 0.6979 - val_loss: 0.6685 - val_accuracy: 0.7411 Epoch 42/50 20/20 [==============================] - 0s 3ms/step - loss: 0.5998 - accuracy: 0.7536 - val_loss: 0.6730 - val_accuracy: 0.7321 Epoch 43/50 20/20 [==============================] - 0s 3ms/step - loss: 0.6273 - accuracy: 0.7138 - val_loss: 0.6488 - val_accuracy: 0.7500 Epoch 44/50 20/20 [==============================] - 0s 3ms/step - loss: 0.6136 - accuracy: 0.7377 - val_loss: 0.7308 - val_accuracy: 0.6607 Epoch 45/50 20/20 [==============================] - 0s 3ms/step - loss: 0.5797 - accuracy: 0.7631 - val_loss: 0.6640 - val_accuracy: 0.7768 Epoch 46/50 20/20 [==============================] - 0s 3ms/step - loss: 0.6055 - accuracy: 0.7329 - val_loss: 0.7130 - val_accuracy: 0.6518 Epoch 47/50 20/20 [==============================] - 0s 3ms/step - loss: 0.6008 - accuracy: 0.7695 - val_loss: 0.6252 - val_accuracy: 0.7679 Epoch 48/50 20/20 [==============================] - 0s 3ms/step - loss: 0.5672 - accuracy: 0.7917 - val_loss: 0.6275 - val_accuracy: 0.7321 Epoch 49/50 20/20 [==============================] - 0s 3ms/step - loss: 0.5455 - accuracy: 0.7901 - val_loss: 0.6077 - val_accuracy: 0.7857 Epoch 50/50 20/20 [==============================] - 0s 3ms/step - loss: 0.5331 - accuracy: 0.7901 - val_loss: 0.6720 - val_accuracy: 0.7946 10/10 [==============================] - 0s 1ms/step - loss: 0.5806 - accuracy: 0.7925 accuracy: 79.2453%
from sklearn.ensemble import RandomForestClassifier
# Configuramos
# Tomamos 20 arboles.
# Criterio a considerar: gini.
b_aleatorio = RandomForestClassifier(n_estimators=20, criterion='gini', max_depth=None, min_samples_split=2)
# Entrenamiento
model = b_aleatorio.fit(X_train, y_train)
# METRICAS
# Hacemos las predicciones
y_pred = model.predict(X_test)
print(f"f1 score: {f1_score(y_test, y_pred, average='weighted')}")
print(f"Recall score: {recall_score(y_test, y_pred, average='weighted')}")
print(f"precision score: {precision_score(y_test, y_pred, average='weighted')}")
print(f"accuracy score: {accuracy_score(y_test, y_pred)}")
f1 score: 0.9984217396463746 Recall score: 0.9968553459119497 precision score: 1.0 accuracy score: 0.9968553459119497
# Creamos un dataframe con los valores de y_test y y_pred
aux_df = pd.DataFrame(enc.inverse_transform(y_pred))
aux_df['y_test'] = enc.inverse_transform(y_test)
aux_df = aux_df.rename(columns={0: 'y_pred'})
# veamos
aux_df
y_pred | y_test | |
---|---|---|
0 | medium | medium |
1 | medium | medium |
2 | low | low |
3 | low | low |
4 | medium | medium |
... | ... | ... |
313 | low | low |
314 | low | low |
315 | high | high |
316 | low | low |
317 | low | low |
318 rows × 2 columns
def clasificador(x):
if x == 'low':
return 0
elif x == 'medium':
return 1
else:
return 2
aux_df['value1'] = aux_df.y_pred.apply(lambda x: clasificador(x))
aux_df['value2'] = aux_df.y_test.apply(lambda x: clasificador(x))
# Creamos una columna nueva donde, si la resta entre las columnas value1 y value2
# es de cero, entonces el clasificador ha predicho bien el resultado, caso contrario
# el clasificador ha errado:
aux_df['correcto'] = aux_df.value1 - aux_df.value2
aux_df
y_pred | y_test | value1 | value2 | correcto | |
---|---|---|---|---|---|
0 | medium | medium | 1 | 1 | 0 |
1 | medium | medium | 1 | 1 | 0 |
2 | low | low | 0 | 0 | 0 |
3 | low | low | 0 | 0 | 0 |
4 | medium | medium | 1 | 1 | 0 |
... | ... | ... | ... | ... | ... |
313 | low | low | 0 | 0 | 0 |
314 | low | low | 0 | 0 | 0 |
315 | high | high | 2 | 2 | 0 |
316 | low | low | 0 | 0 | 0 |
317 | low | low | 0 | 0 | 0 |
318 rows × 5 columns
# Veamos cuantos ceros obtuvimos, es decir, cuantos valores bien predichos
# hemos obtenido con base en el clasificador
aux_df.correcto.value_counts()
0 317 2 1 Name: correcto, dtype: int64
aux_df[aux_df.correcto != 0]
y_pred | y_test | value1 | value2 | correcto | |
---|---|---|---|---|---|
240 | None | low | 2 | 0 | 2 |