Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Poisoning Multiclass dataset #15

Open
GiorgosMandi opened this issue Nov 9, 2022 · 0 comments
Open

Poisoning Multiclass dataset #15

GiorgosMandi opened this issue Nov 9, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@GiorgosMandi
Copy link

I am trying to poison a multiclass dataset, however, whichever poisoning strategy I use I get an error that looks like this:

ValueError: The data (x,y) has more than two classes.

or in the case of CAttackPoisoningSVM

ValueError: input labels should be binary in {0, +1} interval

I have tried to wrap my secml classifier with CClassifierMulticlassOVA but then I get:

NotImplementedError: We cannot poisoning that classifier

So, does secml supports the poisoning of multiclass datasets? and If yes how?

Thank you in advance.

Steps to reproduce

# x_train is a np.ndarray
# y_train is a np.ndarray consisting of multiple classes
dataset_train = CDataset(x_train, y_train)
clf = CClassifierSVM(kernel=CKernelRBF(gamma=0.001), C=1)
clf.fit(dataset_train.X, dataset_train.Y)
lb, ub = dataset_train.X.min(), dataset_train.X.max()
solver_params = {
    'eta': eps,
    'max_iter': max_iter,
    'eps': eps
}
pois_attack = CAttackPoisoningSVM(classifier=clf,
                                  training_data=dataset_train,
                                  val=dataset_train,
                                  lb=lb, ub=ub,
                                  dmax=1,
                                  solver_type='pgd',
                                  solver_params=solver_params)

pois_attack.n_points = adversarial_points_indices.shape[0]
pois_y_pred, pois_scores, pois_ds, f_opt = pois_attack.run(x=dataset_train.X, y=dataset_train.Y)

Output:

ValueError: input labels should be binary in {0, +1} interval
@GiorgosMandi GiorgosMandi added the bug Something isn't working label Nov 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant