A comprehensive machine learning project for malware detection and classification using advanced ensemble methods and gradient boosting algorithms. This project achieves 99.42% accuracy with state-of-the-art models like LightGBM and XGBoost.
This project implements a robust malware classification system that analyzes Portable Executable (PE) files to distinguish between malware and benign software. Using a dataset of 5,184 samples with 70 engineered features, the system employs 13 different machine learning algorithms to achieve exceptional detection accuracy.
| Model | Accuracy | ROC-AUC | F1 Score | Training Time |
|---|---|---|---|---|
| LGBMClassifier | 99.42% | 0.9944 | 0.9945 | 0.38s |
| XGBClassifier | 99.42% | 0.9943 | 0.9945 | 0.14s |
| CatBoostClassifier | 99.33% | 0.9932 | 0.9936 | 1.49s |
| HistGradientBoostingClassifier | 99.33% | 0.9934 | 0.9936 | 0.70s |
| RandomForest | 99.23% | 0.9923 | 0.9927 | 0.49s |
- Data Processing: pandas, numpy
- Machine Learning: scikit-learn
- Gradient Boosting: XGBoost, LightGBM, CatBoost
- Visualization: matplotlib, seaborn
- Advanced Analytics: UMAP, LIME
- Model Evaluation: Cross-validation, ROC-AUC, Cohen-Kappa
- Support Vector Machine (SVM)
- Logistic Regression
- K-Nearest Neighbors
- Decision Tree
- Random Forest
- XGBoost Classifier
- AdaBoost Classifier
- Gradient Boosting Classifier
- Histogram Gradient Boosting
- LightGBM Classifier
- CatBoost Classifier
- Multi-layer Perceptron (MLP)
- Linear Discriminant Analysis
The dataset contains 70 engineered features extracted from PE files:
- PE File Headers: e_cblp, e_cp, e_cparhdr, e_maxalloc, e_sp, e_lfanew
- File Characteristics: NumberOfSections, CreationYear, filesize
- Entropy Measures: E_text, E_data, E_file (measuring randomness/encryption)
- Section Analysis: sus_sections, non_sus_sections (suspicious section detection)
- Packer Information: packer, packer_type (compression/obfuscation detection)
- File Properties: fileinfo (additional metadata)
- Label encoding for categorical variables
- Standard scaling for numerical features
- Feature engineering and selection
- Cross-Validation: K-fold validation for robust performance estimation
- Comprehensive Metrics: Accuracy, Precision, Recall, F1-Score, ROC-AUC, Cohen-Kappa
- Performance Monitoring: Training time, prediction time, memory usage
- Statistical Analysis: Standard deviation across folds for stability assessment
- Systematic evaluation of 13 different algorithms
- Performance ranking based on multiple metrics
- Efficiency analysis (speed vs. accuracy trade-offs)
- LightGBM: Best overall performance with 99.42% accuracy and fastest prediction time
- XGBoost: Tied for best accuracy with superior training speed (0.14s)
- CatBoost: Excellent stability with lowest standard deviation (0.33%)
- Gradient Boosting methods significantly outperform traditional algorithms
- Ensemble methods (Random Forest, Boosting) show superior generalization
- Tree-based models excel at capturing non-linear patterns in PE file features
- Memory efficiency varies significantly across models (69KB to 12MB)
pip install catboost xgboost lightgbm umap-learn lime
pip install pandas numpy scikit-learn matplotlib seaborn- Clone the repository
- Install required dependencies
- Place your dataset as
Raw.csvin the project directory - Run the Jupyter notebook
main_V2.ipynb
# Load and preprocess data
df = pd.read_csv('Raw.csv')
# Train models (example with LightGBM)
from lightgbm import LGBMClassifier
model = LGBMClassifier()
model.fit(X_train, y_train)
# Evaluate performance
accuracy = model.score(X_test, y_test)The project employs comprehensive evaluation metrics:
- Accuracy: Overall classification correctness
- ROC-AUC: Area under the ROC curve for binary classification
- Precision: True positive rate (malware correctly identified)
- Recall: Sensitivity (malware detection rate)
- F1-Score: Harmonic mean of precision and recall
- Cohen-Kappa: Agreement measure accounting for chance
- Cross-Validation: K-fold validation for robust performance estimation
- LIME Integration: Local interpretable model-agnostic explanations
- Feature Analysis: Understanding which PE file characteristics drive predictions
- UMAP Visualization: Dimensionality reduction for data exploration
- Cybersecurity: Real-time malware detection systems
- Antivirus Software: Integration with security solutions
- Threat Intelligence: Large-scale malware analysis
- Research: Academic studies in machine learning and cybersecurity
- Deep Learning: Neural network architectures for complex pattern recognition
- Real-time Processing: Stream processing for live malware detection
- Feature Engineering: Additional PE file characteristics
- Adversarial Robustness: Defense against evasion attacks
- Model Deployment: Production-ready API endpoints
Contributions are welcome! Please feel free to submit pull requests, report bugs, or suggest features.
This project is open-source and available under the MIT License.
Amitabh Thakur
- Computer Science (AI & ML) Student
- B.Tech at Dayananda Sagar University
- Founder & Managing Director, Humans Care Foundation
- Location: Bengaluru, Karnataka, India
Built with passion for cybersecurity and machine learning excellence.