Metadata-Version: 2.4
Name: graphids
Version: 0.1.0
Summary: Graph-based intrusion detection using GCN, Transformer autoencoder, and contrastive learning
Project-URL: Homepage, https://github.com/vijaygovindaraja/graphids
Project-URL: Paper, https://doi.org/10.1038/s41598-025-07956-w
Author-email: Vijay Govindarajan <vijay.govindarajan91@gmail.com>
License: MIT License
        
        Copyright (c) 2026 Vijay Govindarajan
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: cloud-security,contrastive-learning,graph-neural-network,intrusion-detection,network-security,transformer
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Security
Requires-Python: >=3.10
Requires-Dist: numpy>=1.24
Requires-Dist: pandas>=2.0
Requires-Dist: scikit-learn>=1.3
Requires-Dist: torch>=2.0
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == 'dev'
Provides-Extra: shap
Requires-Dist: shap>=0.43; extra == 'shap'
Description-Content-Type: text/markdown

# GraphIDS

Graph-based intrusion detection using GCN, Transformer autoencoder, and contrastive learning.

Reference implementation of the framework introduced in:

> Govindarajan, V. & Muzamal, J. H. (2025). Advanced cloud intrusion detection
> framework using graph based features transformers and contrastive learning.
> *Scientific Reports*, 15, 20511. DOI: [10.1038/s41598-025-07956-w](https://doi.org/10.1038/s41598-025-07956-w)

## Install

```bash
pip install graphids
```

## Quick start

```python
from graphids import GraphIDS

model = GraphIDS(n_features=41, n_classes=5)
model.train_pipeline(X_train, y_train)
result = model.evaluate(X_test, y_test)
print(f"Accuracy: {result.accuracy:.4f}")
```

## Architecture

Three-stage pipeline:

1. **GCN** — constructs a communication graph from flow data, extracts structural node embeddings via 3-layer graph convolution
2. **Transformer autoencoder** — refines embeddings through self-attention, identifies discriminative feature dimensions
3. **Contrastive classifier** — improves class separation for minority attack types (U2R, R2L), outputs multi-class predictions

## Results (from the paper)

| Dataset | Accuracy | Precision | Recall | F1 | FPR |
|---|---|---|---|---|---|
| NSL-KDD (5-class) | 99.97% | 99.94% | 99.92% | 99.93% | 0.05% |
| CIC-IDS (binary) | 99.96% | 99.93% | 99.91% | 99.92% | 0.06% |
| CIC-IDS (multi) | 99.95% | 99.92% | 99.90% | 99.91% | 0.07% |

## Citation

```bibtex
@article{govindarajan2025graphids,
    title   = {Advanced cloud intrusion detection framework using graph based
               features transformers and contrastive learning},
    author  = {Govindarajan, Vijay and Muzamal, Junaid Hussain},
    journal = {Scientific Reports},
    volume  = {15},
    pages   = {20511},
    year    = {2025},
    doi     = {10.1038/s41598-025-07956-w},
}
```

## License

MIT
