0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Data Every Day: ライム病の発疹

Posted at

tldr

KggleのLyme Disease RashesLyme Disease Image Classification - Data Every Day #050に沿ってやっていきます。

実行環境はGoogle Colaboratorです。

インポート

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

import sklearn.preprocessing as sp
from sklearn.model_selection import train_test_split
import sklearn.linear_model as slm
import sklearn.svm as svm
import sklearn.neural_network as snn

import tensorflow as tf

データのダウンロード

Google Driveをマウントします。

from google.colab import drive
drive.mount('/content/drive')
Mounted at /content/drive

KaggleのAPIクライアントを初期化し、認証します。
認証情報はGoogle Drive内(/content/drive/My Drive/Colab Notebooks/Kaggle)にkaggle.jsonとして置いてあります。

import os
kaggle_path = "/content/drive/My Drive/Colab Notebooks/Kaggle"
os.environ['KAGGLE_CONFIG_DIR'] = kaggle_path

from kaggle.api.kaggle_api_extended import KaggleApi
api = KaggleApi()
api.authenticate() 

Kaggle APIを使ってデータをダウンロードします。

dataset_id = 'sshikamaru/lyme-disease-rashes'
dataset = api.dataset_list_files(dataset_id)
file_name = dataset.files[0].name
file_path = os.path.join(api.get_default_download_dir(), file_name)
file_path
'/content/RashData/Train/Train_2_Cases/Lyme_Negative/Pityriasis rosea rash125.jpg'
api.dataset_download_files(dataset_id, force=True, quiet=False)
  0%|          | 0.00/84.5M [00:00<?, ?B/s]

Downloading lyme-disease-rashes.zip to /content


100%|██████████| 84.5M/84.5M [00:01<00:00, 67.3MB/s]
import zipfile

zip_path = os.path.join(api.get_default_download_dir(), '{}.zip'.format('lyme-disease-rashes'))
with zipfile.ZipFile(zip_path) as existing_zip:
    existing_zip.extractall(api.get_default_download_dir())
import os
os.listdir('/content/RashData')
['Lyme_Positive_By_Diease', 'Lyme_Negative_By_Disease', 'Train', 'Validation']
train_dir = '/content/RashData/Train/Train_2_Cases'
val_dir = '/content/RashData/Validation/Validation_2_Cases'
batch_size = 32
img_height = 128
img_width = 128
train_ds = tf.keras.preprocessing.image_dataset_from_directory(
    train_dir,
    validation_split=0.2,
    seed=42,
    subset='training',
    batch_size=batch_size,
    image_size=(img_height, img_width),
)

val_ds = tf.keras.preprocessing.image_dataset_from_directory(
    train_dir,
    validation_split=0.2,
    seed=42,
    subset='validation',
    batch_size=batch_size,
    image_size=(img_height, img_width),
)


test_ds = tf.keras.preprocessing.image_dataset_from_directory(
    val_dir,
    batch_size=batch_size,
    image_size=(img_height, img_width),
)
Found 357 files belonging to 2 classes.
Using 286 files for training.
Found 357 files belonging to 2 classes.
Using 71 files for validation.
Found 87 files belonging to 2 classes.
class_names = train_ds.class_names
print(class_names)
['Lyme_Negative', 'Lyme_Positive']
for images, labels in train_ds.take(1):
    print(images.shape)
    print(class_names[labels[0]])
(32, 128, 128, 3)
Lyme_Negative

バッチサイズ: 32
画像サイズ: 128*128(RGB)

可視化

plt.figure(figsize=(10, 10))
for images, labels in train_ds.take(1):
    for i in range(9):
        plt.subplot(3, 3, i + 1)
        plt.imshow(images[i].numpy().astype('uint8'))
        plt.title(class_names[labels[i]])
    plt.show()

Lyme_Disease_Rashes_19_0.png

モデリング

AUTOTUNE = tf.data.experimental.AUTOTUNE

train_ds = train_ds.cache().shuffle(1000).prefetch(buffer_size=AUTOTUNE)
val_ds = val_ds.cache().shuffle(1000).prefetch(buffer_size=AUTOTUNE)
test_ds = test_ds.cache().shuffle(1000).prefetch(buffer_size=AUTOTUNE)
model = tf.keras.Sequential([
    tf.keras.layers.experimental.preprocessing.Rescaling(1./255, input_shape=(img_height, img_width, 3)),
    tf.keras.layers.Conv2D(16, 3, padding='same', activation='relu'),
    tf.keras.layers.MaxPool2D(),
    tf.keras.layers.BatchNormalization(),
    tf.keras.layers.Conv2D(32, 3, padding='same', activation='relu'),
    tf.keras.layers.MaxPool2D(),
    tf.keras.layers.BatchNormalization(),
    tf.keras.layers.Flatten(),
    tf.keras.layers.Dense(128, activation='relu'),
    tf.keras.layers.Dense(1, activation='sigmoid'),
])

model.summary()

model.compile(
    optimizer='adam',
    loss='binary_crossentropy',
    metrics=['accuracy', tf.keras.metrics.AUC(name='auc')],
)

epochs = 100

history = model.fit(
    train_ds,
    validation_data=val_ds,
    batch_size=batch_size,
    epochs=epochs,
)
Model: "sequential_3"
_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
rescaling_3 (Rescaling)      (None, 128, 128, 3)       0         
_________________________________________________________________
conv2d_6 (Conv2D)            (None, 128, 128, 16)      448       
_________________________________________________________________
max_pooling2d_6 (MaxPooling2 (None, 64, 64, 16)        0         
_________________________________________________________________
batch_normalization_2 (Batch (None, 64, 64, 16)        64        
_________________________________________________________________
conv2d_7 (Conv2D)            (None, 64, 64, 32)        4640      
_________________________________________________________________
max_pooling2d_7 (MaxPooling2 (None, 32, 32, 32)        0         
_________________________________________________________________
batch_normalization_3 (Batch (None, 32, 32, 32)        128       
_________________________________________________________________
flatten_3 (Flatten)          (None, 32768)             0         
_________________________________________________________________
dense_6 (Dense)              (None, 128)               4194432   
_________________________________________________________________
dense_7 (Dense)              (None, 1)                 129       
=================================================================
Total params: 4,199,841
Trainable params: 4,199,745
Non-trainable params: 96
_________________________________________________________________
Epoch 1/100
9/9 [==============================] - 1s 62ms/step - loss: 6.4882 - accuracy: 0.4510 - auc: 0.4840 - val_loss: 1.9348 - val_accuracy: 0.5493 - val_auc: 0.5156
Epoch 2/100
9/9 [==============================] - 0s 13ms/step - loss: 1.2934 - accuracy: 0.6617 - auc: 0.7530 - val_loss: 1.3784 - val_accuracy: 0.5070 - val_auc: 0.5561
Epoch 3/100
9/9 [==============================] - 0s 14ms/step - loss: 0.5160 - accuracy: 0.7101 - auc: 0.8111 - val_loss: 0.6844 - val_accuracy: 0.6056 - val_auc: 0.6306
Epoch 4/100
9/9 [==============================] - 0s 13ms/step - loss: 0.4934 - accuracy: 0.6726 - auc: 0.8217 - val_loss: 0.6810 - val_accuracy: 0.5493 - val_auc: 0.5797
Epoch 5/100
9/9 [==============================] - 0s 13ms/step - loss: 0.4005 - accuracy: 0.7577 - auc: 0.8710 - val_loss: 0.6882 - val_accuracy: 0.5352 - val_auc: 0.5857
Epoch 6/100
9/9 [==============================] - 0s 13ms/step - loss: 0.3817 - accuracy: 0.7559 - auc: 0.8725 - val_loss: 0.6850 - val_accuracy: 0.5352 - val_auc: 0.5745
Epoch 7/100
9/9 [==============================] - 0s 12ms/step - loss: 0.3068 - accuracy: 0.7923 - auc: 0.9447 - val_loss: 0.6884 - val_accuracy: 0.4930 - val_auc: 0.5373
Epoch 8/100
9/9 [==============================] - 0s 13ms/step - loss: 0.2817 - accuracy: 0.8721 - auc: 0.9550 - val_loss: 0.6808 - val_accuracy: 0.5352 - val_auc: 0.5641
Epoch 9/100
9/9 [==============================] - 0s 14ms/step - loss: 0.2294 - accuracy: 0.8989 - auc: 0.9718 - val_loss: 0.6758 - val_accuracy: 0.5634 - val_auc: 0.5869
Epoch 10/100
9/9 [==============================] - 0s 13ms/step - loss: 0.2111 - accuracy: 0.9135 - auc: 0.9855 - val_loss: 0.6944 - val_accuracy: 0.5493 - val_auc: 0.5741
Epoch 11/100
9/9 [==============================] - 0s 14ms/step - loss: 0.2111 - accuracy: 0.9516 - auc: 0.9892 - val_loss: 0.6975 - val_accuracy: 0.4930 - val_auc: 0.5252
Epoch 12/100
9/9 [==============================] - 0s 13ms/step - loss: 0.1745 - accuracy: 0.9067 - auc: 0.9961 - val_loss: 0.6969 - val_accuracy: 0.5915 - val_auc: 0.5893
Epoch 13/100
9/9 [==============================] - 0s 13ms/step - loss: 0.1692 - accuracy: 0.9567 - auc: 0.9972 - val_loss: 0.7061 - val_accuracy: 0.5211 - val_auc: 0.5853
Epoch 14/100
9/9 [==============================] - 0s 14ms/step - loss: 0.1435 - accuracy: 0.9802 - auc: 0.9977 - val_loss: 0.6635 - val_accuracy: 0.5775 - val_auc: 0.6450
Epoch 15/100
9/9 [==============================] - 0s 13ms/step - loss: 0.1055 - accuracy: 0.9937 - auc: 0.9992 - val_loss: 0.6587 - val_accuracy: 0.5634 - val_auc: 0.6430
Epoch 16/100
9/9 [==============================] - 0s 13ms/step - loss: 0.0767 - accuracy: 0.9825 - auc: 0.9991 - val_loss: 0.6699 - val_accuracy: 0.5352 - val_auc: 0.6538
Epoch 17/100
9/9 [==============================] - 0s 13ms/step - loss: 0.0476 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 0.6280 - val_accuracy: 0.6338 - val_auc: 0.6883
Epoch 18/100
9/9 [==============================] - 0s 13ms/step - loss: 0.0417 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 0.7108 - val_accuracy: 0.5352 - val_auc: 0.6571
Epoch 19/100
9/9 [==============================] - 0s 15ms/step - loss: 0.0201 - accuracy: 0.9989 - auc: 1.0000 - val_loss: 0.6255 - val_accuracy: 0.6479 - val_auc: 0.6859
Epoch 20/100
9/9 [==============================] - 0s 14ms/step - loss: 0.0174 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 0.6548 - val_accuracy: 0.6197 - val_auc: 0.7071
Epoch 21/100
9/9 [==============================] - 0s 14ms/step - loss: 0.0112 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 0.5995 - val_accuracy: 0.7042 - val_auc: 0.7240
Epoch 22/100
9/9 [==============================] - 0s 13ms/step - loss: 0.0109 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 0.6059 - val_accuracy: 0.6901 - val_auc: 0.7216
Epoch 23/100
9/9 [==============================] - 0s 13ms/step - loss: 0.0079 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 0.5988 - val_accuracy: 0.7042 - val_auc: 0.7308
Epoch 24/100
9/9 [==============================] - 0s 14ms/step - loss: 0.0056 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 0.5986 - val_accuracy: 0.7042 - val_auc: 0.7448
Epoch 25/100
9/9 [==============================] - 0s 14ms/step - loss: 0.0048 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 0.6026 - val_accuracy: 0.7042 - val_auc: 0.7412
Epoch 26/100
9/9 [==============================] - 0s 13ms/step - loss: 0.0044 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 0.6116 - val_accuracy: 0.7042 - val_auc: 0.7444
Epoch 27/100
9/9 [==============================] - 0s 14ms/step - loss: 0.0035 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 0.6074 - val_accuracy: 0.7042 - val_auc: 0.7464
Epoch 28/100
9/9 [==============================] - 0s 13ms/step - loss: 0.0051 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 0.6381 - val_accuracy: 0.6761 - val_auc: 0.7384
Epoch 29/100
9/9 [==============================] - 0s 14ms/step - loss: 0.0042 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 0.6371 - val_accuracy: 0.7183 - val_auc: 0.7364
Epoch 30/100
9/9 [==============================] - 0s 14ms/step - loss: 0.0032 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 0.6653 - val_accuracy: 0.6901 - val_auc: 0.7328
Epoch 31/100
9/9 [==============================] - 0s 13ms/step - loss: 0.0037 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 0.7009 - val_accuracy: 0.6620 - val_auc: 0.7284
Epoch 32/100
9/9 [==============================] - 0s 13ms/step - loss: 0.0026 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 0.7238 - val_accuracy: 0.7324 - val_auc: 0.7300
Epoch 33/100
9/9 [==============================] - 0s 13ms/step - loss: 0.0024 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 0.7622 - val_accuracy: 0.7324 - val_auc: 0.7288
Epoch 34/100
9/9 [==============================] - 0s 13ms/step - loss: 0.0021 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 0.8063 - val_accuracy: 0.7042 - val_auc: 0.7284
Epoch 35/100
9/9 [==============================] - 0s 13ms/step - loss: 0.0027 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 0.8437 - val_accuracy: 0.7042 - val_auc: 0.7320
Epoch 36/100
9/9 [==============================] - 0s 13ms/step - loss: 0.0021 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 0.8883 - val_accuracy: 0.6761 - val_auc: 0.7256
Epoch 37/100
9/9 [==============================] - 0s 13ms/step - loss: 0.0021 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 0.9376 - val_accuracy: 0.6620 - val_auc: 0.7220
Epoch 38/100
9/9 [==============================] - 0s 12ms/step - loss: 0.0020 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 0.9981 - val_accuracy: 0.6479 - val_auc: 0.7228
Epoch 39/100
9/9 [==============================] - 0s 13ms/step - loss: 0.0015 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 1.0560 - val_accuracy: 0.6620 - val_auc: 0.7115
Epoch 40/100
9/9 [==============================] - 0s 14ms/step - loss: 0.0018 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 1.1138 - val_accuracy: 0.6338 - val_auc: 0.7091
Epoch 41/100
9/9 [==============================] - 0s 13ms/step - loss: 0.0014 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 1.1678 - val_accuracy: 0.6479 - val_auc: 0.7111
Epoch 42/100
9/9 [==============================] - 0s 13ms/step - loss: 0.0014 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 1.2324 - val_accuracy: 0.6620 - val_auc: 0.7099
Epoch 43/100
9/9 [==============================] - 0s 30ms/step - loss: 0.0014 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 1.2949 - val_accuracy: 0.6901 - val_auc: 0.7163
Epoch 44/100
9/9 [==============================] - 0s 15ms/step - loss: 0.0015 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 1.3601 - val_accuracy: 0.6761 - val_auc: 0.7183
Epoch 45/100
9/9 [==============================] - 0s 13ms/step - loss: 0.0012 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 1.4324 - val_accuracy: 0.6761 - val_auc: 0.7212
Epoch 46/100
9/9 [==============================] - 0s 14ms/step - loss: 0.0014 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 1.4887 - val_accuracy: 0.6761 - val_auc: 0.7248
Epoch 47/100
9/9 [==============================] - 0s 13ms/step - loss: 0.0012 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 1.5575 - val_accuracy: 0.6761 - val_auc: 0.7284
Epoch 48/100
9/9 [==============================] - 0s 15ms/step - loss: 0.0012 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 1.6339 - val_accuracy: 0.6761 - val_auc: 0.7192
Epoch 49/100
9/9 [==============================] - 0s 14ms/step - loss: 0.0013 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 1.7035 - val_accuracy: 0.6761 - val_auc: 0.7196
Epoch 50/100
9/9 [==============================] - 0s 13ms/step - loss: 0.0013 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 1.7717 - val_accuracy: 0.6901 - val_auc: 0.7248
Epoch 51/100
9/9 [==============================] - 0s 14ms/step - loss: 9.3228e-04 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 1.8471 - val_accuracy: 0.6761 - val_auc: 0.7212
Epoch 52/100
9/9 [==============================] - 0s 13ms/step - loss: 0.0010 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 1.9138 - val_accuracy: 0.6901 - val_auc: 0.7232
Epoch 53/100
9/9 [==============================] - 0s 14ms/step - loss: 0.0010 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 1.9862 - val_accuracy: 0.7183 - val_auc: 0.7272
Epoch 54/100
9/9 [==============================] - 0s 15ms/step - loss: 0.0012 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 2.0603 - val_accuracy: 0.7042 - val_auc: 0.7284
Epoch 55/100
9/9 [==============================] - 0s 14ms/step - loss: 9.8786e-04 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 2.1399 - val_accuracy: 0.6901 - val_auc: 0.7364
Epoch 56/100
9/9 [==============================] - 0s 14ms/step - loss: 8.5569e-04 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 2.2179 - val_accuracy: 0.7324 - val_auc: 0.7304
Epoch 57/100
9/9 [==============================] - 0s 14ms/step - loss: 8.6896e-04 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 2.3019 - val_accuracy: 0.7324 - val_auc: 0.7328
Epoch 58/100
9/9 [==============================] - 0s 14ms/step - loss: 9.9618e-04 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 2.3754 - val_accuracy: 0.7324 - val_auc: 0.7344
Epoch 59/100
9/9 [==============================] - 0s 14ms/step - loss: 7.9414e-04 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 2.4516 - val_accuracy: 0.7042 - val_auc: 0.7356
Epoch 60/100
9/9 [==============================] - 0s 13ms/step - loss: 6.8582e-04 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 2.5276 - val_accuracy: 0.6901 - val_auc: 0.7368
Epoch 61/100
9/9 [==============================] - 0s 13ms/step - loss: 6.5435e-04 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 2.6030 - val_accuracy: 0.6901 - val_auc: 0.7380
Epoch 62/100
9/9 [==============================] - 0s 14ms/step - loss: 6.8066e-04 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 2.6829 - val_accuracy: 0.6901 - val_auc: 0.7372
Epoch 63/100
9/9 [==============================] - 0s 14ms/step - loss: 7.7666e-04 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 2.7543 - val_accuracy: 0.7042 - val_auc: 0.7396
Epoch 64/100
9/9 [==============================] - 0s 14ms/step - loss: 6.6361e-04 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 2.8264 - val_accuracy: 0.6901 - val_auc: 0.7448
Epoch 65/100
9/9 [==============================] - 0s 14ms/step - loss: 6.9111e-04 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 2.8996 - val_accuracy: 0.6901 - val_auc: 0.7448
Epoch 66/100
9/9 [==============================] - 0s 14ms/step - loss: 5.7020e-04 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 2.9771 - val_accuracy: 0.6901 - val_auc: 0.7460
Epoch 67/100
9/9 [==============================] - 0s 14ms/step - loss: 7.0239e-04 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 3.0475 - val_accuracy: 0.6901 - val_auc: 0.7432
Epoch 68/100
9/9 [==============================] - 0s 13ms/step - loss: 5.3068e-04 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 3.1167 - val_accuracy: 0.6901 - val_auc: 0.7400
Epoch 69/100
9/9 [==============================] - 0s 15ms/step - loss: 4.9762e-04 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 3.1823 - val_accuracy: 0.7042 - val_auc: 0.7420
Epoch 70/100
9/9 [==============================] - 0s 13ms/step - loss: 5.9091e-04 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 3.2489 - val_accuracy: 0.7042 - val_auc: 0.7424
Epoch 71/100
9/9 [==============================] - 0s 13ms/step - loss: 5.4181e-04 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 3.3221 - val_accuracy: 0.6901 - val_auc: 0.7308
Epoch 72/100
9/9 [==============================] - 0s 14ms/step - loss: 5.9010e-04 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 3.3755 - val_accuracy: 0.7042 - val_auc: 0.7332
Epoch 73/100
9/9 [==============================] - 0s 13ms/step - loss: 4.3831e-04 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 3.4373 - val_accuracy: 0.6901 - val_auc: 0.7312
Epoch 74/100
9/9 [==============================] - 0s 15ms/step - loss: 4.8843e-04 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 3.4985 - val_accuracy: 0.6901 - val_auc: 0.7284
Epoch 75/100
9/9 [==============================] - 0s 13ms/step - loss: 5.2265e-04 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 3.5523 - val_accuracy: 0.6901 - val_auc: 0.7252
Epoch 76/100
9/9 [==============================] - 0s 13ms/step - loss: 4.6827e-04 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 3.6091 - val_accuracy: 0.6901 - val_auc: 0.7276
Epoch 77/100
9/9 [==============================] - 0s 14ms/step - loss: 4.3389e-04 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 3.6519 - val_accuracy: 0.6901 - val_auc: 0.7268
Epoch 78/100
9/9 [==============================] - 0s 13ms/step - loss: 4.9754e-04 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 3.6938 - val_accuracy: 0.6901 - val_auc: 0.7304
Epoch 79/100
9/9 [==============================] - 0s 14ms/step - loss: 4.0575e-04 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 3.7425 - val_accuracy: 0.6901 - val_auc: 0.7296
Epoch 80/100
9/9 [==============================] - 0s 13ms/step - loss: 4.1413e-04 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 3.7826 - val_accuracy: 0.6901 - val_auc: 0.7244
Epoch 81/100
9/9 [==============================] - 0s 13ms/step - loss: 3.9489e-04 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 3.8244 - val_accuracy: 0.6901 - val_auc: 0.7171
Epoch 82/100
9/9 [==============================] - 0s 15ms/step - loss: 4.6814e-04 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 3.8579 - val_accuracy: 0.6901 - val_auc: 0.7171
Epoch 83/100
9/9 [==============================] - 0s 13ms/step - loss: 3.8877e-04 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 3.8865 - val_accuracy: 0.7042 - val_auc: 0.7171
Epoch 84/100
9/9 [==============================] - 0s 14ms/step - loss: 4.4917e-04 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 3.9212 - val_accuracy: 0.6901 - val_auc: 0.7159
Epoch 85/100
9/9 [==============================] - 0s 14ms/step - loss: 3.3383e-04 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 3.9539 - val_accuracy: 0.6901 - val_auc: 0.7192
Epoch 86/100
9/9 [==============================] - 0s 14ms/step - loss: 3.9012e-04 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 3.9770 - val_accuracy: 0.6901 - val_auc: 0.7196
Epoch 87/100
9/9 [==============================] - 0s 13ms/step - loss: 3.5120e-04 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 4.0039 - val_accuracy: 0.6901 - val_auc: 0.7196
Epoch 88/100
9/9 [==============================] - 0s 14ms/step - loss: 3.9191e-04 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 4.0245 - val_accuracy: 0.6901 - val_auc: 0.7192
Epoch 89/100
9/9 [==============================] - 0s 15ms/step - loss: 3.9131e-04 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 4.0488 - val_accuracy: 0.6901 - val_auc: 0.7091
Epoch 90/100
9/9 [==============================] - 0s 30ms/step - loss: 3.6262e-04 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 4.0725 - val_accuracy: 0.6901 - val_auc: 0.7079
Epoch 91/100
9/9 [==============================] - 0s 13ms/step - loss: 2.9462e-04 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 4.0921 - val_accuracy: 0.6901 - val_auc: 0.7079
Epoch 92/100
9/9 [==============================] - 0s 15ms/step - loss: 2.6391e-04 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 4.1123 - val_accuracy: 0.6901 - val_auc: 0.7067
Epoch 93/100
9/9 [==============================] - 0s 14ms/step - loss: 2.7211e-04 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 4.1287 - val_accuracy: 0.6901 - val_auc: 0.7071
Epoch 94/100
9/9 [==============================] - 0s 14ms/step - loss: 3.3072e-04 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 4.1432 - val_accuracy: 0.6901 - val_auc: 0.7071
Epoch 95/100
9/9 [==============================] - 0s 14ms/step - loss: 2.9676e-04 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 4.1621 - val_accuracy: 0.6901 - val_auc: 0.7059
Epoch 96/100
9/9 [==============================] - 0s 13ms/step - loss: 3.0123e-04 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 4.1733 - val_accuracy: 0.6901 - val_auc: 0.7063
Epoch 97/100
9/9 [==============================] - 0s 14ms/step - loss: 3.3341e-04 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 4.1815 - val_accuracy: 0.6901 - val_auc: 0.7063
Epoch 98/100
9/9 [==============================] - 0s 14ms/step - loss: 2.7530e-04 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 4.2012 - val_accuracy: 0.6901 - val_auc: 0.7055
Epoch 99/100
9/9 [==============================] - 0s 14ms/step - loss: 2.5506e-04 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 4.2160 - val_accuracy: 0.7042 - val_auc: 0.7051
Epoch 100/100
9/9 [==============================] - 0s 14ms/step - loss: 2.6284e-04 - accuracy: 1.0000 - auc: 1.0000 - val_loss: 4.2271 - val_accuracy: 0.7042 - val_auc: 0.7047

結果

plt.figure(figsize=(20, 10))

epochs_range = range(1, epochs+1)
train_loss = history.history['loss']
val_loss = history.history['val_loss']
train_auc = history.history['auc']
val_auc = history.history['val_auc']

plt.subplot(1, 2, 1)
plt.plot(epochs_range, train_loss, label='Training Loss')
plt.plot(epochs_range, val_loss, label='Validation Loss')

plt.xlabel('Epochs')
plt.ylabel('Loss')
plt.title('Training and Validation Loss')
plt.legend()

plt.subplot(1, 2, 2)
plt.plot(epochs_range, train_auc, label='Training AUC')
plt.plot(epochs_range, val_auc, label='Validation AUC')

plt.xlabel('Epochs')
plt.ylabel('AUC')
plt.title('Training and Validation AUC')
plt.legend()

plt.show()

Lyme_Disease_Rashes_24_0.png

model.evaluate(test_ds)
3/3 [==============================] - 0s 5ms/step - loss: 1.5354 - accuracy: 0.7011 - auc: 0.7565





[1.5353684425354004, 0.7011494040489197, 0.7565360069274902]
np.argmin(val_loss)
23
np.argmax(val_auc)
26
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?