Python porting of the Isconna algorithm.
-
To install:
pip install --upgrade Isconna
-
The 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
-
cd
to the project rootIsconna.Python
-
If you already have a copy of datasets (e.g., from Isconna), you can set the environment variable
DATASET_DIR
to itsdata
folder-
Otherwise,
curl -OL https://github.com/liurui39660/Isconna/raw/master/data/data.zip
-
mkdir data && tar -xf data.zip -C data
(Windows)-
Or
unzip data.zip -d data
(Linux/macOS) -
Or
7z x data.zip -odata
-
You can see a directory like
data/CIC-IDS2018/processed
-
-
-
pip install -r requirements.txt
-
Or
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., acceleration -
numpy
: Make code concise, but no effect on speed-
Because you actually run on the jitted (translated) code
-
-
pyprojroot
: Detect project root path -
scikit-learn
: Metric -
tqdm
: 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 dataset -
Assign its path to
pathMeta
-
E.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
pathData
-
E.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
pathLabel
-
E.g.,
data/CIC-IDS2018/processed/Label.csv
-
-
Copy the directory
src/Isconna
to where you need-
Pip users can skip this step, it’s already installed
-
-
Import
Isconna
in the code -
Instantiate 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 includes-
Source (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
-