Skip to content

Commit

Permalink
script for testing bad features
Browse files Browse the repository at this point in the history
  • Loading branch information
brifordwylie committed Nov 26, 2024
1 parent 3cb2865 commit edf24ae
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions scripts/bad_features_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

# Original dataset
X_original = pd.DataFrame(np.random.rand(1000, 10)) # 10 original features
y = (X_original.sum(axis=1) > 5).astype(int) # Simple binary target
y = (X_original.sum(axis=1) > 5).astype(int) # Simple binary target

# Add random noise features
X_noise = X_original.copy()
Expand All @@ -18,8 +18,8 @@
# Train and compare models
model = XGBClassifier()

original_score = cross_val_score(model, X_original, y, cv=5, scoring='accuracy').mean()
noise_score = cross_val_score(model, X_noise, y, cv=5, scoring='accuracy').mean()
original_score = cross_val_score(model, X_original, y, cv=5, scoring="accuracy").mean()
noise_score = cross_val_score(model, X_noise, y, cv=5, scoring="accuracy").mean()

print(f"Original CV Accuracy: {original_score:.4f}")
print(f"CV Accuracy with Adversarial Features: {noise_score:.4f}")
Expand Down

0 comments on commit edf24ae

Please sign in to comment.