A library for Secure and Explainable Machine Learning
SecML: A library for Secure and Explainable Machine Learning
SecML is an open-source Python library for the security evaluation of Machine Learning (ML) algorithms.
It comes with a set of powerful features:
- Wide range of supported ML algorithms. All supervised learning algorithms
scikit-learnare available, as well as Neural Networks (NNs) through PyTorch deep learning platform.
- Built-in attack algorithms. Evasion and poisoning attacks based on a custom-developed fast solver. In addition, we provide connectors to other third-party Adversarial Machine Learning libraries.
- Dense/Sparse data support. We provide full, transparent support for both
numpylibrary) and sparse data (through
scipylibrary) in a single data structure.
- Visualize your results. We provide visualization and plotting framework, based on the widely-known library matplotlib.
- Explain your results. Explainable ML methods to interpret model decisions via influential features and prototypes.
- Model Zoo. Use our pre-trained models to save time and easily replicate scientific results.
- Multi-processing. Do you want to save time further? We provide full
compatibility with all the multi-processing features of
pytorch, along with built-in support of the joblib library.
- Extensible. Easily create new components, like ML models or attack algorithms, by extending the provided abstract interfaces.
SecML is currently in development.
We recommend instaling SecML in a specific environment along with its dependencies.
Common frameworks to create and manage envs are virtualenv and conda. Both alternatives provide convenient user guides on how to properly setup the envs, so this guide will not cover the configuration procedure.
Operating System requirements
SecML can run under Python >= 3.5 with no additional configuration steps required, as all its dependencies are available as wheel packages for the primary macOS versions and Linux distributions.
However, to support additional advanced features more packages can be necessary depending on the Operating System used:
Linux (Ubuntu >= 16.04 or equivalent dist)
macOS (macOS >= 10.12 Sierra)
- Nothing to note.
Before starting the installation process try to obtain the latest version
pip manager by calling:
pip install -U pip
The setup process is managed by the Python package
Be sure to obtain the latest version by calling:
pip install -U setuptools
Once the environment is set up, SecML can installed and run by multiple means:
Install from official PyPI repository:
pip install secml
Install from wheel/zip package (https://pypi.python.org/pypi/secml#files):
pip install <package-file>
In all cases, the setup process will try to install the correct dependencies.
In case something goes wrong during the install process, try to install
the dependencies first by calling:
pip install -r requirements.txt
SecML should now be importable in python via:
To update a current installation using any of the previous methods,
-U parameter after the
pip install directive.
Please see our Update Guides for specific
upgrade intructions depending on the source and target version.
SecML comes with a set of extras components that can be installed if desired.
To specify the extra components to install, add the section
extras will be a comma-separated list of components
you want to install. Example:
pip install secml[extra1,extra2]
All the installation procedures via
pip described above allow definition
Available extra components
pytorch: Neural Networks (NNs) through PyTorch deep learning platform.
torch >= 1.1,
torchvision >= 0.2.2
cleverhans: Wrapper of CleverHans, a Python library to benchmark vulnerability of machine learning systems to adversarial examples. Will install:
tensorflow >= 1.14.*, < 2,
tf-gpu: Shortcut for installing
TensorFlowpackage with GPU support.
tensorflow-gpu >= 1.14.*, < 2
As a result, most of the interfaces of the library should be pretty familiar to frequent users of those packages.
The primary data class is the
(currently limited to 2 dimensions) array structure which embeds both dense
and sparse data accepting as input
(more sparse formats will be supported soon). This structure is the standard
input and output of all other classes in the library.
secml.ml package contains all the Machine Learning algorithms and
support classes, including classifiers, loss and regularizer functions,
kernels and performance evaluation functions. Also, a zoo of pre-trained
models is provided by the
secml.adv package contains evasion and poisoning attacks based on a
custom-developed solver, along with classes to easily perform security
evaluation of Machine Learning algorithms.
secml.explanation package contains different explainable
Machine Learning methods that allow interpreting classifiers decisions
by analyzing the relevant components such as features or training prototypes.
secml.figure package contains a visualization and plotting framework
based on matplotlib.
Developers and Contributors
The contributing and developer's guide is available at: https://secml.gitlab.io/developers/
This library is maintained by PRALab - Pattern Recognition and Applications Lab.
List of contributors:
- Marco Melis (maintainer) 
- Ambra Demontis 
- Maura Pintor , 
- Battista Biggio , 
 Department of Electrical and Electronic Engineering, University of Cagliari, Italy
 Pluribus One, Italy
numpyTravis E, Oliphant. "A guide to NumPy", USA: Trelgol Publishing, 2006.
scipyTravis E. Oliphant. "Python for Scientific Computing", Computing in Science & Engineering, 9, 10-20, 2007.
scikit-learnPedregosa et al., "Scikit-learn: Machine Learning in Python", JMLR 12, pp. 2825-2830, 2011.
matplotlibJ. D. Hunter, "Matplotlib: A 2D Graphics Environment", Computing in Science & Engineering, vol. 9, no. 3, pp. 90-95, 2007.
pytorchPaszke, Adam, et al. "Automatic differentiation in pytorch.", NIPS-W, 2017.
cleverhansPapernot, Nicolas, et al. "Technical Report on the CleverHans v2.1.0 Adversarial Examples Library." arXiv preprint arXiv:1610.00768 (2018).
SecML has been partially developed with the support of European Union’s ALOHA project Horizon 2020 Research and Innovation programme, grant agreement No. 780788.
Release history Release notifications
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size secml-0.11.2-py2.py3-none-any.whl (408.4 kB)||File type Wheel||Python version py2.py3||Upload date||Hashes View hashes|
|Filename, size secml-0.11.2.zip (420.6 kB)||File type Source||Python version None||Upload date||Hashes View hashes|
Hashes for secml-0.11.2-py2.py3-none-any.whl