Skip to content

nicolofassina/kNAVe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Robustness Verification of k-Nearest Neighbors

kNAVe (kNN Abstract Verifier) is an abstract interpretation-based tool for proving robustness and stability properties of kNN classifiers.

Given a training set D and a test set T, together with a perturbation P, kNAVe symbolically computes an over-approximation of P(x), the region of (possibly infinite) vectors that corresponds to feature variations of x in T, and runs a sound abstract version of the kNN on it, returning a superset of the labels associated with vectors in P(x). Clearly, when kNAVe only returns one label, kNN is provably robust and stable for such a perturbation.

Requirements

  • Python3

Installation

To install kNAVe you need to clone or download this repository and run the commands:

cd src
pip install ./

This will install the following dependencies:

  • joblib
  • nptyping
  • numpy
  • pandas
  • pick
  • python-dateutil
  • pytz
  • scikit-learn
  • scipy
  • six
  • threadpoolctl
  • tqdm

Usage

To run kNAVe:

cd src
python3 knave.py <config_file.ini>

where config_file.ini is located in the config folder, or alternatively:

cd src
python3 knave.py <config_file.ini> log

to obtain also a log file in the logs folder. For more information on usage and configuration file, run help.py without arguments.

Note: You can use ... to match multiple files. For example:

python3 knave.py ...
python3 knave.py str...

match, respectively, all files and files starting with str in the config folder.

Results

Results are saved in 3 files:

  • details.csv: contains classifications for all processed feature vectors
  • robustness.csv: contains robustness results
  • stability.csv: contains stability results

Their location depends on the specifications given in the configuration file.

About

kNN Abstract Verification tool

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published