<jupyter_start><jupyter_text>Load data<jupyter_code>current_path = os.path.join(os.getcwd(), '..')
process_data_path = os.path.join(
    current_path, 'data/processed'
)

X_base = pd.read_csv(f'{process_data_path}/train_X.csv', sep=';', header=None)

# remove dir
X_train = X_base.iloc[:, 1:]
Y_train = pd.read_csv(f'{process_data_path}/train_Y.csv', sep=';', header=None)


val_X_base = pd.read_csv(f'{process_data_path}/validation_X.csv', sep=';', header=None)
X_val = val_X_base.iloc[:, 1:]
Y_val = pd.read_csv(f'{process_data_path}/validation_Y.csv', sep=';', header=None)
X_train.head()
X_train.shape<jupyter_output><empty_output><jupyter_text>Define SVM model<jupyter_code>model = GaussianNB(var_smoothing=1e-09)
model.fit(X_train, np.ravel(Y_train))
X_val.head()
acc = model.score(X_val, Y_val)
print(f'Acurácia Naive Bayes Validação: {acc}')

all_classes = ['cat', 'dog']

predictions = model.predict(X_val)
cm = confusion_matrix(Y_val, predictions)
df_cm = pd.DataFrame(cm, index=[all_classes], columns=all_classes)
sns.heatmap(df_cm, annot=True)
plt.title(f'Confusion Matrix --> Naive Bayes')
plt.ylabel('True label')
plt.xlabel('Predicted label')
plt.show()

from IPython.display import Image, display

predicated_proba = model.predict_proba(X_val)

# aux for find proba for class
aux = 0
for predicated, expected in zip(predictions, Y_val.iterrows()):
    if expected[1][0] != predicated:
        img_dir = val_X_base[0][expected[0]]
        percent = predicated_proba[aux]
        print(f'Confundiu {expected[1][0]}: {img_dir} com {predicated}, proba: {percent}')
        display(Image(filename=img_dir))
    aux += 1<jupyter_output>Confundiu cat: /Users/lucaspaim/PycharmProjects/deep_learning_cats_dogs/notebooks/../data/raw/cats_and_dogs_filtered/validation/cats/cat.2337.jpg com dog, proba: [0. 1.]
{'fraction_non_alphanumeric': 0.15757575757575756, 'fraction_numerical': 0.01046831955922865, 'mean_word_length': 6.2063492063492065, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 9, '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': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '523149', 'license': 'MIT', 'n_tokens_mistral': 742, 'n_tokens_neox': 712, 'n_words': 115, 'path': 'notebooks/transfer_learning_shallow.ipynb', 'repo_name': 'lucasmpaim/deep_learning_cats_and_dogs_study', 'size': '1815'}