Downloads · 30 days
12
24% of all-time downloads
debashis2007/cybersecuritytl-anomaly-detector
cybersecuritytl-anomaly-detector is a machine learning model from debashis2007. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as apache-2.0.
A transfer learning-based anomaly detection system designed to identify zero-day style attacks in network traffic.
Downloads · 30 days
12
24% of all-time downloads
All-time downloads
50
Public
Repo size
1.2 MB
Likes
1
Public
Click a slice to open those files.
.pkl1.1 MB · 85%
From the Hugging Face model README
A transfer learning-based anomaly detection system designed to identify zero-day style attacks in network traffic.
This model combines:
| Metric | Value |
|---|---|
| Accuracy | 82.95% |
| Precision | 74.38% |
| Recall | 22.50% |
| F1-Score | 34.55% |
| ROC-AUC | 0.96 |
All features are standardized via StandardScaler before model input.
import joblib
import numpy as np
from tensorflow import keras
# Load model components
detector = joblib.load("detector.pkl")
autoencoder = keras.models.load_model("autoencoder/model.h5")
# Prepare your data (shape: [n_samples, 7])
X_new = np.array([[...]]) # Your traffic features
# Get predictions
predictions, latent_scores, recon_errors = detector.predict(X_new)
# predictions: -1 = anomaly, 1 = normal
# latent_scores: anomaly scores in latent space
# recon_errors: reconstruction errors from autoencoder
python -m src.api.server
Then POST to /predict:
{
"src_ip": "192.168.1.100",
"dst_ip": "10.0.0.50",
"src_port": 54321,
"dst_port": 443,
"protocol": "TCP",
"packet_length": 512,
"inter_arrival": 0.001,
"flags": "SYN"
}
To adapt this model to your network:
from src.models.trainer import ModelTrainer
trainer = ModelTrainer()
# Your domain-specific traffic data
X_target = load_your_traffic_data() # shape: [n, 7]
# Fine-tune the autoencoder
history = trainer.finetune_with_strategy(
'freeze_encoder', # or 'progressive', 'layer_wise'
X_target=X_target,
epochs=10,
learning_rate=0.0001
)
# Retrain Isolation Forest on new latent space
trainer.train_transfer_learning(
X_pretrain=X_target, # Use your data
X_finetune=X_target,
ae_epochs=0, # Already fine-tuned
finetune_epochs=10
)
If you use this model in your research, please cite:
@software{{anomaly_detector_2025,
title={{Network Anomaly Detection - Transfer Learning Model}},
author={{CyberSecurityTL Contributors}},
year={{2025}},
url={{https://huggingface.co/{repo_name}}}
}}
Apache License 2.0 - See LICENSE file for details
This model is trained on network traffic patterns from 2009 (NSL-KDD dataset). It may not detect modern attack techniques. Always use in conjunction with other security tools and manual analysis.
Model created: 2025-12-21 10:22:44