Python porting of the Isconna algorithm.
To install:
pip install --upgrade IsconnaThe demo is not included, see section External Dataset + Custom Runner for how to use Isconna
Please consider using the C++ version as the baseline, this porting may not receive timely updates.
Open a terminal
cdto the project rootIsconna.PythonIf you already have a copy of datasets (e.g., from Isconna), you can set the environment variable
DATASET_DIRto itsdatafolderOtherwise,
curl -OL https://github.com/liurui39660/Isconna/raw/master/data/data.zipmkdir data && tar -xf data.zip -C data(Windows)Or
unzip data.zip -d data(Linux/macOS)Or
7z x data.zip -odataYou can see a directory like
data/CIC-IDS2018/processed
pip install -r requirements.txtOr
conda install --file requirements.txt -y
set PYTHONPATH=src(Windows) orexport PYTHONPATH=src(Linux/macOS)python example/Demo.py
This runs Isconna-EO on CIC-IDS2018 ($DATASET_DIR/CIC-IDS2018/processed/Data.csv) and prints ROC-AUC.
All required packages are listed in requirements.txt.
Python 3.6+ should be fine.
numba: JIT, i.e., accelerationnumpy: Make code concise, but no effect on speedBecause you actually run on the jitted (translated) code
pyprojroot: Detect project root pathscikit-learn: Metrictqdm: Progress bar
Uncomment the section "Export raw scores" of example/Demo.py.
out/Score.txt has 1 column: the final anomaly score.
Cores are declared in the section "Do the magic" of example/Demo.py. Uncomment the desired core.
Parameters and dataset paths are specified in the section Parameter of example/Demo.py.
You need to prepare three files:
Meta file
Only includes an integer
n, the number of records in the datasetAssign its path to
pathMetaE.g.,
data/CIC-IDS2018/processed/Meta.txt
Data file
A header-less csv file with shape
[n,3]Each row includes 3 integers: source, destination and timestamp
Timestamps should start from 1 and be continuous
Assign its path to
pathDataE.g.,
data/CIC-IDS2018/processed/Data.csv
Label file
A header-less text file with shape
[n,1]Each row includes 1 integer: 0 if normal, 1 if anomalous
Assign its path to
pathLabelE.g.,
data/CIC-IDS2018/processed/Label.csv
Copy the directory
src/Isconnato where you needPip users can skip this step, it’s already installed
Import
Isconnain the codeInstantiate cores with required parameters
Number of CMS rows
Number of CMS columns
Decay factor (default is 0, i.e., keep nothing)
Call
Call()on individual records, the signature includesSource (categorical)
Destination (categorical)
Timestamp
Weight for the frequency score
Weight for the width score
Weight for the gap score
Return value is the anomaly score