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

Final detector is evaluated on data it has been trained on? #5

Open
davidglavas opened this issue Dec 7, 2018 · 1 comment
Open

Comments

@davidglavas
Copy link

The code that creates the detector (linear regression classifier):

## Build detector
values, labels, lr = train_lr(
densities_pos=densities_adv_z,
densities_neg=np.concatenate((densities_normal_z, densities_noisy_z)),
uncerts_pos=uncerts_adv_z,
uncerts_neg=np.concatenate((uncerts_normal_z, uncerts_noisy_z))
)

Variables values and labels returned by train_lr() represent the training data that the model has been trained on:

def train_lr(densities_pos, densities_neg, uncerts_pos, uncerts_neg):
    # [...data preparing code left out...]
    
    lr = LogisticRegressionCV(n_jobs=-1).fit(values, labels)
    return values, labels, lr

At the end the detector is evaluated on the data it was trained on (line 159 uses values which is the training data returned by train_lr):

## Evaluate detector
# Compute logistic regression model predictions
probs = lr.predict_proba(values)[:, 1]
# Compute AUC
n_samples = len(X_test)
# The first 2/3 of 'probs' is the negative class (normal and noisy samples),
# and the last 1/3 is the positive class (adversarial samples).
_, _, auc_score = compute_roc(
probs_neg=probs[:2 * n_samples],
probs_pos=probs[2 * n_samples:]
)
print('Detector ROC-AUC score: %0.4f' % auc_score)

Evaluating on training data leads to a biased result. Did I miss anything?

@davidglavas davidglavas changed the title Logistic regression classifier is evaluated on data it has been trained on? Final logistic regression classifier is evaluated on data it has been trained on? Dec 7, 2018
@davidglavas davidglavas changed the title Final logistic regression classifier is evaluated on data it has been trained on? Final detector is evaluated on data it has been trained on? Dec 7, 2018
@yoheikikuta
Copy link

That's what I thought.
It seems that the ROC-AUC evaluation uses the same data that was used in the training of a model.
Is this implementation as the authors intended?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants