text_plain_output_1.png
from sklearn.metrics import accuracy_score

import numpy as np

lda = LDA(n_components=1)
X_train_r2 = lda.fit(X_train, y_train)

y_pred = lda.predict(X_test)

w = lda.coef_
w.shape

w0 = lda.intercept_
np.transpose(w0).shape

X_test_final = X_test.to_numpy(dtype='uint8')

X_attack = X_test_final - (X_test_final @ np.transpose(w) + w0) @ w / np.linalg.norm(w)

print(X_attack.shape)