Skip to main content Switch to mobile version tabular-model-robustness 0.1.0 How cheaply can an attacker get past your fraud, bot or abuse model? Cost-aware evasion tests for XGBoost, LightGBM and scikit-learn models with realistic attacker constraints, plus hardening (adversarial training, feature removal) with the accuracy, robustness and inference-energy trade-off measured.
pip install tabular-model-robustness Copy PIP instructions
How cheaply can an attacker get past your fraud, bot or abuse model? This tool attacks your own XGBoost, LightGBM or scikit-learn model the way a real attacker would: changing only what they control, within realistic limits, and counting what it costs them. Then it hardens the model and shows the trade-off between accuracy, robustness and inference energy.
Fraud and bot models are tested on accuracy. Attackers do not care about accuracy: they care about what it costs to get a fraudulent order or a scraping bot through. In the demo, a model with 0.97 AUC lets 64% of bots through when each bot spends one unit of effort, mostly by faking a few mouse events.
Tree ensembles are known to be easy to evade: Kantchelian, Tygar and Joseph (ICML 2016) found boosted trees more brittle than the other model families they tested, and showed that retraining on evading examples ("adversarial boosting") makes them much harder to evade. In tabular data, what matters is the attacker's cost, not how "close" the fake input is to a real one (Kireev, Kulynych and Troncoso, NDSS 2023). This tool is built around that.
Describe the attacker
A JSON file lists the features the attacker controls and what changing them costs (examples/bot-constraints.json):
{ "budget": 10, "features": { "requests_per_min": {"min": 0, "direction": "decrease", "cost": 0.05}, "mouse_events": {"min": 0, "direction": "increase", "integer": true, "cost": 0.05}, "distinct_ips_24h": {"min": 1, "direction": "decrease", "integer": true, "cost": 3}, "account_age_days": {"mutable": false} } } Field Meaning mutable Whether the attacker can change it. Features you list are mutable unless you say false; unlisted features are fixed (or set "default_mutable": true). min, max Allowed range max_change, max_change_rel Largest change, absolute or as a share of the current value direction increase, decrease or both (a bot can slow down but cannot make its account older) integer Whole numbers only cost Attacker cost per unit of change; budget caps the total Costs are in any unit you choose: dollars, minutes of effort, or a simple 1-to-10 scale. Agree them with the people who see the attacks.
For each row the model flags, a greedy search changes one attacker-controlled feature at a time, picking the change that lowers the score most per unit of cost, until the row falls under the threshold or the budget runs out. For tree models the only values it tries are just either side of the model's own split points, read from the model (XGBoost, LightGBM, scikit-learn trees, forests and HistGradientBoosting), because nothing in between can change a tree ensemble's output. That makes the search fast and precise; on a one-split model it finds the exact minimum cost (tested). For other models, a grid of data values is used.
The results are lower bounds: a greedy search can miss a cheaper path, so a determined attacker may do better. Exact methods for tree ensembles (mixed-integer programming, Kantchelian et al. 2016) or verification (Chen et al., NeurIPS 2019) are stronger and much slower.
You get the evasion rate at each budget, the median cost to evade, which features attackers would change, and examples.
Harden and measure the cost
tabular-model-robustness harden --model bot_model.joblib --train train.csv --test test.csv --label is_bot --constraints bot-constraints.json --budgets 1,5,10 Adversarial training: attack training positives under the same constraints, add the evading versions with their true label, retrain, repeat (--rounds).
Dropping cheap features: retrain without the features attacks used most (--drop to choose). In the demo this only moved the attack to other cheap signals: when everything the model relies on is cheap to fake, it needs signals that are costly to fake, such as account age, payment history or verified identity.
Each version is scored on held-out data (AUC, recall and false-positive rate at the threshold), attacked again, and benchmarked with greeninfer for single-prediction latency and energy per 1,000 rows. Robustness that doubles inference cost may not be worth it on a busy checkout; the table makes that visible. The quick benchmark in harden is noisy on shared machines; for published numbers, benchmark the final models with greeninfer and several repeats.
from tabular_robustness import Constraints, evaluate, compare cons = Constraints.load("constraints.json", feature_names) report = evaluate(model, X_test[y_test == 1], cons, budgets=[1, 5, 10]) print(report["evasion_rate"], report["median_cost"], report["features_used"]) Responsible use
Test models you own or are allowed to test. The output shows where your own model is weak so you can fix it; the constraint file describes what an attacker can do, which you should treat as sensitive.
This tool supports SDG target 9.1 (reliable, resilient infrastructure): fraud and bot defences that hold up under realistic attacks keep online stores and payment systems trustworthy. It also supports target 9.5 (enhance scientific research): it measures robustness and inference energy together, a combination rarely reported in studies of defended tree models.
Kantchelian A., Tygar J. D., Joseph A. D. (2016). Evasion and Hardening of Tree Ensemble Classifiers. ICML. arXiv:1509.07892
Kireev K., Kulynych B., Troncoso C. (2023). Adversarial Robustness for Tabular Data through Cost and Utility Awareness. NDSS. arXiv:2208.13058
Chen H., Zhang H., Si S., Li Y., Boning D., Hsieh C.-J. (2019). Robustness Verification of Tree-based Models. NeurIPS.
Built by Ahmad Zia, an AI and e-commerce consultant and researcher in efficient and secure inference for gradient-boosted tree models. MIT licensed.
Guide, help and author
Full guide with examples and FAQs: www.ahmadzia.com/tools/tabular-model-robustness
Background reading: Is pickle safe? ML model file scanners compared
All 30 free tools and agent skills: ahmadzia.com/tools · ahmadzia.com/skills
Want it set up, fixed or tuned for your store? Book a free call
Built by Ahmad Zia (Muhammad Ahmad Zia), an AI consultant for ecommerce since 2020 and green AI researcher at the University of Lahore. Research · Google Scholar · ORCID · LinkedIn · GitHub
More AI and store security tools
shopbot-shield: Prompt injection protection for ecommerce chatbots and AI shopping assistants
model-file-guard: Scan pickle, PyTorch, joblib and other ML model files for hidden code before you load them
llm-store-review: Security review of AI chatbots and agents in your code, mapped to the OWASP LLM Top 10 2026
rag-content-guard: Find hidden instructions and poisoned documents before they reach your RAG index or AI agent
storeguard: Free security scanner for vibe-coded online stores
All 30 tools and agent skills: github.com/MuhammadAhmadZia · ahmadzia.com/tools
Released: Dec 5, 2026
Author: Muhammad Ahmad Zia
Both files in this release have provenance metadata.
View provenance details
MIT View SPDX License List
adversarial-machine-learning bot-detection evasion fraud-detection gradient-boosting green-ai lightgbm ml-security robustness security tabular xgboost
Development Status 3 - Alpha
Intended Audience Developers
Programming Language Python :: 3
Topic Scientific/Engineering :: Artificial Intelligence
Release files for tabular-model-robustness 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
Built distribution (wheel)
Total release size: 41.7 kB
Release files / tabular_model_robustness-0.1.0.tar.gz
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 5, 2026.
Security for tabular-model-robustness 0.1.0
Both files in this release have been uploaded with provenance metadata.
With provenance tabular_model_robustness-0.1.0.tar.gz Dec 5, 2026
Attestation for tabular_model_robustness-0.1.0.tar.gz
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.
Release history Release notifications | RSS feed
Dec 5, 2026 2 release files Full provenance
"PyPI", "Python Package Index", and the blocks logos are registered trademarks of the Python Software Foundation.
© 2026 Python Software Foundation
Deployed from 4d99e05











