<jupyter_start><jupyter_text>Load Data<jupyter_code>X = np.load("X.npy")
y = np.load("y.npy")<jupyter_output><empty_output><jupyter_text>Normalize features.<jupyter_code>X = tf.keras.utils.normalize(X)<jupyter_output><empty_output><jupyter_text>`Model`<jupyter_code>NAME = "{}-conv-{}-nodes-{}-dense-{}".format(3, 128, 1, int(time.time()))
tensorboard = TensorBoard(log_dir='bcd_3logs')
print(NAME)

model = Sequential()

model.add(Conv2D(128, (3,3), input_shape = X.shape[1:]))
model.add(Activation('relu'))
model.add(MaxPooling2D(2,2))

model.add(Conv2D(128, (3,3)))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(2,2)))

model.add(Conv2D(128, (3,3)))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(2,2)))

model.add(Flatten())

model.add(Dense(512))
model.add(Activation('relu'))
model.add(Dropout(0.2))


model.add(Dense(1))
model.add(Activation('sigmoid'))

opt = tf.keras.optimizers.Adam(learning_rate=0.001)

model.compile(loss='binary_crossentropy',
              optimizer=opt,
              metrics=['accuracy'])

model.fit(X, y, batch_size=48, epochs=10, validation_split=0.3, callbacks=[tensorboard])<jupyter_output>3-conv-128-nodes-1-dense-1618846287
Epoch 1/10
50/50 [==============================] - 52s 1s/step - loss: 0.6341 - accuracy: 0.6942 - val_loss: 0.5642 - val_accuracy: 0.7463
Epoch 2/10
50/50 [==============================] - 52s 1s/step - loss: 0.5968 - accuracy: 0.7123 - val_loss: 0.5651 - val_accuracy: 0.7414
Epoch 3/10
50/50 [==============================] - 52s 1s/step - loss: 0.5996 - accuracy: 0.7085 - val_loss: 0.5647 - val_accuracy: 0.7444
Epoch 4/10
50/50 [==============================] - 53s 1s/step - loss: 0.5873 - accuracy: 0.7190 - val_loss: 0.5757 - val_accuracy: 0.7326
Epoch 5/10
50/50 [==============================] - 53s 1s/step - loss: 0.5806 - accuracy: 0.7144 - val_loss: 0.5465 - val_accuracy: 0.7453
Epoch 6/10
50/50 [==============================] - 53s 1s/step - loss: 0.5658 - accuracy: 0.7228 - val_loss: 0.5565 - val_accuracy: 0.7316
Epoch 7/10
50/50 [==============================] - 54s 1s/step - loss: 0.5647 - accuracy: 0.7144 - val_loss: 0.5486 - val_a[...]<jupyter_text>Saving<jupyter_code>model.save('bcd_model.h5')<jupyter_output><empty_output><jupyter_text>Testing<jupyter_code>import cv2
import tensorflow as tf

CATEGORIES = ["Cancer", "Normal"]

def prepare(filepath):
    IMG_SIZE = 100
    img_arr = cv2.imread(filepath, cv2.IMREAD_GRAYSCALE)
    new_arr = cv2.resize(img_arr, (IMG_SIZE, IMG_SIZE))
    return new_arr.reshape(-1, IMG_SIZE, IMG_SIZE, 1)

model = tf.keras.models.load_model('bcd_model.h5')
prediction = model.predict([prepare('test_samples/Cancer/c_2.png')])
print(CATEGORIES[int(prediction[0][0])])
print(int(prediction[0][0]))
prediction = model.predict([prepare('test_samples/Normal/n_1.png')])
print(CATEGORIES[int(prediction[0][0])])
print(int(prediction[0][0]))<jupyter_output>Normal
1
{'fraction_non_alphanumeric': 0.24102564102564103, 'fraction_numerical': 0.09982905982905983, 'mean_word_length': 5.680365296803653, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '33821', 'license': 'MIT', 'n_tokens_mistral': 1367, 'n_tokens_neox': 1184, 'n_words': 172, 'path': 'models/Breast Cancer/Diagnosis/Conv.ipynb', 'repo_name': 'Ammar-Raneez/SDGP-MEDIC-IN-ONE', 'size': '2925'}