No project description provided
Project description
DeepBridge
DeepBridge is a comprehensive Python library for advanced machine learning model validation, distillation, and performance analysis. It provides powerful tools to manage experiments, validate models, create more efficient model versions, and conduct in-depth performance evaluations.
Installation
You can install DeepBridge using pip:
pip install deepbridge
Or install from source:
git clone https://github.com/DeepBridge-Validation/DeepBridge.git
cd deepbridge
pip install -e .
Key Features
Experiment Framework
- Modular Architecture: Component-based design with specialized managers
- Comprehensive Testing: Robustness, uncertainty, and resilience evaluation
- Feature Selection: Focus testing on specific features with the
features_selectparameter - Test Configuration Levels: Quick, medium, or full test suites via the
suiteparameter - Visualization System: Integrated visualization capabilities
- Reporting Engine: Detailed HTML report generation
Model Validation
- Multi-faceted Evaluation: Assess models across multiple dimensions
- Alternative Model Comparison: Generate and compare different model types
- Metrics Analysis: Comprehensive performance metrics
- Visualization Tools: Interactive plots for model analysis
Model Distillation
- Knowledge Distillation: Transfer knowledge from complex to simpler models
- Surrogate Modeling: Create lightweight approximations of complex models
- Hyperparameter Optimization: Automated tuning of student models
- Distribution Matching: Ensure student models faithfully reproduce teacher distributions
Advanced Analytics
- Robustness Testing: Evaluate model stability under perturbations
- Uncertainty Quantification: Assess model confidence and calibration
- Resilience Analysis: Test models under adverse conditions
- Hyperparameter Importance: Identify critical hyperparameters
Architecture Overview
DeepBridge has been redesigned with a modular, component-based architecture:
┌─────────────────┐
│ Experiment │
└───────┬─────────┘
│
▼
┌─────────────────────────────────────────────────────────┐
│ │
│ ┌───────────┐ ┌────────────┐ ┌──────────────┐ │
│ │DataManager│ │ModelManager│ │TestRunner │ │
│ └───────────┘ └────────────┘ └──────────────┘ │
│ │
│ ┌───────────┐ ┌─────────────┐ ┌────────────────┐ │
│ │ModelEval │ │ReportGen │ │VisualizationMgr│ │
│ └───────────┘ └─────────────┘ └────────────────┘ │
│ │
└─────────────────────────────────────────────────────────┘
Key Components
- Experiment: Central coordinator managing the experiment workflow
- DataManager: Handles data preparation and splitting
- ModelManager: Creates and manages models and distillation
- TestRunner: Coordinates test execution across managers
- ModelEvaluation: Calculates metrics and evaluates models
- ReportGenerator: Creates HTML reports with results
- VisualizationManager: Coordinates visualization creation
Quick Start
Comprehensive Experiment
from deepbridge.core.experiment import Experiment
from deepbridge.core.db_data import DBDataset
# Create dataset
dataset = DBDataset(
data=df,
target_column='target',
features=features
)
# Initialize experiment with tests
experiment = Experiment(
dataset=dataset,
experiment_type='binary_classification',
tests=['robustness', 'uncertainty'],
features_select=['feature1', 'feature2', 'feature3'], # Optional: Specify features to focus on
suite='medium' # Optional: Run tests immediately with this configuration
)
# Train a distilled model
experiment.fit(
student_model_type='random_forest',
distillation_method='knowledge_distillation',
temperature=2.0
)
# If suite parameter wasn't provided, run tests manually
# experiment.run_tests(config_name='medium')
robustness_plot = experiment.plot_robustness_comparison()
# Save comprehensive report
experiment.save_report('experiment_report.html')
Direct Model Distillation
from deepbridge.distillation.techniques.knowledge_distillation import KnowledgeDistillation
# Create distiller directly
distiller = KnowledgeDistillation(
teacher_model=teacher_model,
student_model_type='gbm',
temperature=2.0,
alpha=0.5
)
# Train the distilled model
distiller.fit(X_train, y_train)
# Make predictions
predictions = distiller.predict(X_test)
Automated Distillation
from deepbridge.auto_distiller import AutoDistiller
from deepbridge.db_data import DBDataset
# Create dataset with probabilities
dataset = DBDataset(
data=df,
target_column='target',
features=features,
prob_cols=['prob_class_0', 'prob_class_1']
)
# Run automated distillation
distiller = AutoDistiller(
dataset=dataset,
output_dir='results',
test_size=0.2,
n_trials=10
)
results = distiller.run(use_probabilities=True)
Command-Line Interface
# Create experiment
deepbridge validation create my_experiment --path ./experiments
# Train distilled model
deepbridge distill train gbm predictions.csv features.csv -s ./models
# Run robustness tests
deepbridge validation test robustness my_experiment --config medium
New Features in This Release
Simplified Experiment Configuration
The Experiment class now supports two new parameters to streamline your workflow:
-
features_select: Focus your analysis on specific features of interest
# Only test these specific features experiment = Experiment( dataset=dataset, experiment_type='binary_classification', tests=['robustness'], features_select=['feature_1', 'feature_2', 'feature_3'] )
-
suite: Automatically run tests at initialization with a specific configuration level
# Tests run automatically with 'quick' configuration experiment = Experiment( dataset=dataset, experiment_type='binary_classification', tests=['robustness'], suite='quick' ) # Results are immediately available in experiment.full_results
-
Combined usage: Use both parameters together for maximum efficiency
experiment = Experiment( dataset=dataset, experiment_type='binary_classification', tests=['robustness', 'uncertainty'], features_select=['feature_1', 'feature_2'], suite='medium' ) # Now run the report generation directly experiment.full_results.save_report("report.html")
Documentation
Full documentation available at: DeepBridge Documentation
The documentation includes:
- API Reference
- Architecture Guides
- Tutorial Notebooks
- Examples
Requirements
- Python 3.8+
- Key Dependencies:
- numpy
- pandas
- scikit-learn
- xgboost
- scipy
- plotly
- optuna
Contributing
We welcome contributions! Please see our contribution guidelines for details on how to submit pull requests, report issues, and contribute to the project.
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Open a Pull Request
Development Setup
# Clone the repository
git clone https://github.com/DeepBridge-Validation/DeepBridge.git
cd deepbridge
# Create virtual environment
python -m venv venv
source venv/bin/activate
# Install dependencies
pip install -r requirements.txt
Running Tests
pytest tests/
License
MIT License
Citation
If you use DeepBridge in your research, please cite:
@software{deepbridge2025,
title = {DeepBridge: Advanced Model Validation and Distillation Library},
author = {Gustavo Haase, Paulo Dourado},
year = {2025},
url = {https://github.com/DeepBridge-Validation/DeepBridge}
}
Contact
- GitHub Issues: DeepBridge Issues
- Email: gustavo.haase@gmail.com
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file deepbridge-0.1.19.tar.gz.
File metadata
- Download URL: deepbridge-0.1.19.tar.gz
- Upload date:
- Size: 194.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.0.1 CPython/3.12.5 Linux/5.15.167.4-microsoft-standard-WSL2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f55ad074d34fd703cb4149403d341e2f48555b1fc03294e3a5da249372b58f15
|
|
| MD5 |
95fcd94a75f0deb679f2094646ccf588
|
|
| BLAKE2b-256 |
e0b25a18ba4fc08af94607595dea0180c06d974538de4857008a2cf9ed12d06f
|
File details
Details for the file deepbridge-0.1.19-py3-none-any.whl.
File metadata
- Download URL: deepbridge-0.1.19-py3-none-any.whl
- Upload date:
- Size: 259.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.0.1 CPython/3.12.5 Linux/5.15.167.4-microsoft-standard-WSL2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0ddedc035c7bdaa162c90d0538176d5b73c2634490b7cca06349ec91cda3b3a9
|
|
| MD5 |
ae4882c1dfb65132df85687dafef8856
|
|
| BLAKE2b-256 |
a973ebe381b64c8b7843859a217d40e5bc1d2e4cfb45f5e716c9e887860ccf16
|